{"record":{"id":"5ca474c05b378dce","repo":"oracle/graal","slug":"unsupported-annotation-error-element-s","errorCode":null,"errorMessage":"Unsupported annotation error element: %s","messagePattern":"Unsupported annotation error element: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler.vmaccess/src/jdk/graal/compiler/vmaccess/HostAnnotationValueConverter.java","lineNumber":141,"sourceCode":"            memberValues.put(memberName, annotationValueElementAsHostValue(member, member.getReturnType(), memberValue, typeToClass));\n        }\n        return annotationType.cast(AnnotationParser.annotationForMap(annotationType, memberValues));\n    }\n\n    /**\n     * Converts one JVMCI annotation element representation to the value expected by the JDK\n     * annotation invocation handler.\n     */\n    @SuppressWarnings({\"unchecked\", \"rawtypes\"})\n    private static Object annotationValueElementAsHostValue(Method member, Class<?> targetType, Object value, Function<ResolvedJavaType, Class<?>> typeToClass) {\n        if (value instanceof MissingType missingType) {\n            return new TypeNotPresentExceptionProxy(missingType.getTypeName(), missingType.getCause());\n        }\n        if (value instanceof ElementTypeMismatch mismatch) {\n            return new DeferredAnnotationTypeMismatchExceptionProxy(member, mismatch.getFoundType());\n        }\n        if (value instanceof ErrorElement) {\n            throw new IllegalArgumentException(\"Unsupported annotation error element: \" + value);\n        }\n        if (targetType.isArray()) {\n            Class<?> componentType = targetType.getComponentType();\n            List<?> elements = (List<?>) value;\n            Object array = Array.newInstance(componentType, elements.size());\n            for (int i = 0; i < elements.size(); i++) {\n                Object element = annotationValueElementAsHostValue(member, componentType, elements.get(i), typeToClass);\n                if (element instanceof ExceptionProxy) {\n                    return element;\n                }\n                Array.set(array, i, element);\n            }\n            return array;\n        }\n        if (targetType == Class.class) {\n            ResolvedJavaType classType = (ResolvedJavaType) value;\n            Class<?> clazz = typeToClass.apply(classType);\n            if (clazz == null) {","sourceCodeStart":123,"sourceCodeEnd":159,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler.vmaccess/src/jdk/graal/compiler/vmaccess/HostAnnotationValueConverter.java#L123-L159","documentation":"While converting individual annotation element values to the JDK proxy's expected forms, HostAnnotationValueConverter handles the known error-element kinds (MissingType -> TypeNotPresentExceptionProxy, ElementTypeMismatch -> DeferredAnnotationTypeMismatchExceptionProxy) but throws on any other ErrorElement subclass. The JDK annotation handler can only defer errors via specific proxies, so unrecognized error payloads cannot be represented and are rejected.","triggerScenarios":"A JVMCI implementation (or replay data) puts an ErrorElement subclass other than MissingType/ElementTypeMismatch into an annotation's element map, and conversion of that member reaches annotationValueElementAsHostValue.","commonSituations":"Custom or experimental JVMCI providers introducing new ErrorElement kinds; deserialized/replayed annotation metadata containing legacy or future error markers; partial-classloading states recorded into snapshots.","solutions":["Ensure the JVMCI provider only emits MissingType or ElementTypeMismatch error elements (or none).","Filter ErrorElement-valued members (or replace with MissingType) before conversion if your consumer can tolerate their absence.","Align the producer's ErrorElement vocabulary with the converter version you run against.","If introducing a new ErrorElement kind, add a corresponding ExceptionProxy mapping in the converter first."],"exampleFix":"// before: elements.put(\"value\", new GenericErrorElement(...));\n// after: elements.put(\"value\", new MissingType(typeName, cause));","handlingStrategy":"validation","validationCode":"Object v = elements.get(member);\nif (v instanceof ErrorElement && !(v instanceof MissingType) && !(v instanceof ElementTypeMismatch)) {\n    // replace or drop the member before conversion\n}","typeGuard":"static boolean isSupportedErrorElement(Object v) { return v instanceof MissingType || v instanceof ElementTypeMismatch; }","tryCatchPattern":"try { convertElement(member, target, value, fn); } catch (IllegalArgumentException e) { if (e.getMessage().startsWith(\"Unsupported annotation error element\")) { /* drop member or degrade gracefully */ } else throw e; }","preventionTips":["Only emit MissingType / ElementTypeMismatch error elements in custom JVMCI providers.","Filter unknown ErrorElement payloads at the metadata boundary.","Keep the ErrorElement vocabulary in sync with the converter version."],"tags":["graalvm","jvmci","annotations","error-elements"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}