{"record":{"id":"d13e85d2def71638","repo":"oracle/graal","slug":"cannot-look-up-s-annotation-at-native-image-runti","errorCode":null,"errorMessage":"Cannot look up %s annotation at Native Image runtime","messagePattern":"Cannot look up (.+?) annotation at Native Image runtime","errorType":"exception","errorClass":"GraalError","httpStatus":null,"severity":"warning","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/annotation/AnnotationValueSupport.java","lineNumber":193,"sourceCode":"        JavaType returnType = method.getSignature().getReturnType(container);\n        ResolvedJavaType memberType;\n        try {\n            memberType = returnType.resolve(container);\n        } catch (NoClassDefFoundError e) {\n            return new MissingType(returnType.getName(), e);\n        }\n        return AnnotationValueParser.parseMemberValue(memberType, ByteBuffer.wrap(info.bytes()), info.constPool(), container);\n    }\n\n    /**\n     * Gets the annotation value of type {@code annotationType} present on {@code annotated}. This\n     * method must only be called in jargraal as it requires the ability convert a {@link Class}\n     * value to a {@link ResolvedJavaType} value.\n     */\n    @LibGraalSupport.HostedOnly\n    public static AnnotationValue getAnnotationValue(Annotated annotated, Class<? extends Annotation> annotationType) {\n        if (inRuntimeCode()) {\n            throw new GraalError(\"Cannot look up %s annotation at Native Image runtime\", annotationType.getName());\n        }\n        boolean inherited = annotationType.getAnnotation(Inherited.class) != null;\n        return getAnnotationValue0(annotated, annotationType, inherited);\n    }\n\n    /**\n     * Looks for an entry in {@code values} whose {@linkplain AnnotationValue#getAnnotationType()\n     * type} matches {@code annotationType}.\n     *\n     * @param container used to resolve type names in {@code values}\n     */\n    @LibGraalSupport.HostedOnly\n    public static AnnotationValue findAnnotationValue(List<AnnotationValue> values, Class<? extends Annotation> annotationType, ResolvedJavaType container) {\n        if (inRuntimeCode()) {\n            throw new GraalError(\"Cannot look up %s annotation at Native Image runtime\", annotationType.getName());\n        }\n        String internalName = \"L\" + annotationType.getName().replace(\".\", \"/\") + \";\";\n        for (var e : values) {","sourceCodeStart":175,"sourceCodeEnd":211,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/annotation/AnnotationValueSupport.java#L175-L211","documentation":"JNI is a pure constants/declarations class for the JNI interface; its private constructor throws IllegalStateException to prevent instantiation. Reaching this exception requires reflection or a bean/serialization framework to bypass the private constructor. All members are static and meant to be referenced on the class itself.","triggerScenarios":"Constructor.newInstance() on JNI via reflection; classpath-scanning DI or JSON frameworks (Jackson subtype scanning, Spring component scan with aggressive filters) attempting to instantiate every class in org.graalvm.jniutils.","commonSituations":"Framework auto-discovery sweeping the SDK jar; test utilities that instantiate all classes of a package; misuse of reflection helpers that ignore private visibility.","solutions":["Reference JNI constants statically (JNI.JNI_OK, JNI.JNIEnv, ...) and never instantiate the class.","Exclude org.graalvm.jniutils from classpath/bean scanning in your DI or serialization framework.","Fix reflective test utilities to skip classes with private throwing constructors."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Reference JNI's static constants directly; never reflectively instantiate utility classes.","Keep DI/serialization frameworks from scanning org.graalvm.jniutils."],"tags":["utility-class","reflection","jni","graalvm-sdk"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}