oracle/graal · warning · IllegalArgumentException

Unexpected enum type: %s

Error message

Unexpected enum type: %s

What it means

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.

Source

Thrown at compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/annotation/AnnotationValue.java:356

     * @throws IllegalArgumentException if this annotation has no element named {@code name}
     */
    public EnumElement getEnum(String name) {
        return get(name, EnumElement.class);
    }

    /**
     * Gets the enum element denoted by {@code name}, resolved to an {@code enumClass} constant.
     *
     * @throws ClassCastException if the element is not an enum
     * @throws IllegalArgumentException if this annotation has no element named {@code name}, if
     *             {@code enumClass} does not match the expected enum type or {@code enumClass} has
     *             no constant with the specified name
     */
    public <T extends Enum<T>> T getEnum(String name, Class<T> enumClass) {
        EnumElement enumElement = getEnum(name);
        String foundType = enumElement.enumType.toClassName();
        if (!foundType.equals(enumClass.getName())) {
            throw new IllegalArgumentException("Unexpected enum type: " + foundType);
        }
        return Enum.valueOf(enumClass, enumElement.name);
    }

    /**
     * Gets an unmodifiable view of the elements in this annotation value. The type for each value
     * in the returned map is specified by {@link #get(String, Class)}.
     */
    public Map<String, Object> getElements() {
        checkError();
        return elements;
    }

    @Override
    public String toString() {
        if (error != null) {
            return "!<" + error + ">";
        }

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Do not instantiate VmLocatorSymbol; reference the static field VmLocatorSymbol.SYMBOL (package-private, so use it from within org.graalvm.home.impl).
  2. Exclude the org.graalvm.home.impl package from reflective bean/classpath scanning.
  3. If a framework triggers it, register a custom instantiator/skip-list entry for the class.
Defensive patterns

Strategy: validation

Prevention

When it happens

Trigger: 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.

Common situations: Over-broad classpath scanning by DI or JSON frameworks that instantiate every discovered class; test utilities that reflectively construct 'all' classes of a package.

Related errors


AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14). Data as JSON: /api/errors/8d8d2ec3347d3b38. Report an issue: GitHub.