{"record":{"id":"8d8d2ec3347d3b38","repo":"oracle/graal","slug":"unexpected-enum-type-s","errorCode":null,"errorMessage":"Unexpected enum type: %s","messagePattern":"Unexpected enum type: (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"warning","filePath":"compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/annotation/AnnotationValue.java","lineNumber":356,"sourceCode":"     * @throws IllegalArgumentException if this annotation has no element named {@code name}\n     */\n    public EnumElement getEnum(String name) {\n        return get(name, EnumElement.class);\n    }\n\n    /**\n     * Gets the enum element denoted by {@code name}, resolved to an {@code enumClass} constant.\n     *\n     * @throws ClassCastException if the element is not an enum\n     * @throws IllegalArgumentException if this annotation has no element named {@code name}, if\n     *             {@code enumClass} does not match the expected enum type or {@code enumClass} has\n     *             no constant with the specified name\n     */\n    public <T extends Enum<T>> T getEnum(String name, Class<T> enumClass) {\n        EnumElement enumElement = getEnum(name);\n        String foundType = enumElement.enumType.toClassName();\n        if (!foundType.equals(enumClass.getName())) {\n            throw new IllegalArgumentException(\"Unexpected enum type: \" + foundType);\n        }\n        return Enum.valueOf(enumClass, enumElement.name);\n    }\n\n    /**\n     * Gets an unmodifiable view of the elements in this annotation value. The type for each value\n     * in the returned map is specified by {@link #get(String, Class)}.\n     */\n    public Map<String, Object> getElements() {\n        checkError();\n        return elements;\n    }\n\n    @Override\n    public String toString() {\n        if (error != null) {\n            return \"!<\" + error + \">\";\n        }","sourceCodeStart":338,"sourceCodeEnd":374,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/annotation/AnnotationValue.java#L338-L374","documentation":"VmLocatorSymbol is a package-private holder for a single CEntryPointLiteral; its private constructor throws IllegalStateException so the class can never be instantiated. Seeing this exception means something bypassed normal usage and forced an instance into existence. Normal code only touches the static SYMBOL field.","triggerScenarios":"Reflection calling newInstance()/Constructor.setAccessible(true).newInstance() on VmLocatorSymbol; a serialization or bean framework (JSON deserializer, XStream) trying to instantiate it because it appeared on a classpath scan.","commonSituations":"Over-broad classpath scanning by DI or JSON frameworks that instantiate every discovered class; test utilities that reflectively construct 'all' classes of a package.","solutions":["Do not instantiate VmLocatorSymbol; reference the static field VmLocatorSymbol.SYMBOL (package-private, so use it from within org.graalvm.home.impl).","Exclude the org.graalvm.home.impl package from reflective bean/classpath scanning.","If a framework triggers it, register a custom instantiator/skip-list entry for the class."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use only static members of holder classes like VmLocatorSymbol.","Exclude org.graalvm.* internals from reflective bean/classpath scanning in DI and serialization frameworks."],"tags":["utility-class","reflection","native-image","graalvm-sdk"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}