oracle/graal · error · IllegalArgumentException

Annotation value type {} is not an annotation interface

Error message

Annotation value type {} is not an annotation interface

What it means

Error "Annotation value type {} is not an annotation interface" thrown in oracle/graal.

Source

Thrown at espresso-compiler-stub/src/com.oracle.truffle.espresso.vmaccess/src/com/oracle/truffle/espresso/vmaccess/EspressoExternalHostProxies.java:645

        if (annotationValue.isError()) {
            throw annotationValue.getError();
        }
        ResolvedJavaType actualAnnotationType = annotationValue.getAnnotationType();
        validateAnnotationType(expectedAnnotationType, actualAnnotationType, "guest return type");
        JavaConstant annotationConstant = Objects.requireNonNull(createGuestAnnotation(annotationValue));
        if (!(annotationConstant instanceof EspressoExternalObjectConstant objectConstant)) {
            throw new IllegalArgumentException("Expected guest annotation object, got " + annotationConstant);
        }
        return objectConstant.getValue();
    }

    /**
     * Verifies that an annotation value names an annotation interface assignable to the declared
     * guest type.
     */
    private static void validateAnnotationType(ResolvedJavaType expectedAnnotationType, ResolvedJavaType actualAnnotationType, String expectedTypeDescription) {
        if (!actualAnnotationType.isAnnotation()) {
            throw new IllegalArgumentException("Annotation value type " + actualAnnotationType.toJavaName() + " is not an annotation interface");
        }
        if (!expectedAnnotationType.isAssignableFrom(actualAnnotationType)) {
            throw new IllegalArgumentException(
                            "Annotation value type " + actualAnnotationType.toJavaName() + " is not assignable to " + expectedTypeDescription + " " + expectedAnnotationType.toJavaName());
        }
    }

    /**
     * Materializes a guest-owned JDK annotation proxy from JVMCI annotation metadata. Explicit
     * elements are validated, defaults are supplied from the guest annotation type, absent required
     * members remain absent, and malformed members are represented by deferred guest exception
     * proxies.
     */
    private JavaConstant createGuestAnnotation(AnnotationValue annotationValue) {
        ResolvedJavaType actualAnnotationType = annotationValue.getAnnotationType();
        JavaConstant annotationClass = access.getProviders().getConstantReflection().asJavaClass(actualAnnotationType);
        JavaConstant elements = access.invoke(access.java_util_HashMap_init, null);
        Map<String, Object> annotationElements = annotationValue.getElements();

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Fix the condition reported by the error: Annotation value type {} is not an annotation interface
  2. Check the throwing call site and ensure its documented preconditions (argument values, types, environment, or configuration) are satisfied before the call.

Example fix

Validate inputs and environment so that the failing condition does not occur: Annotation value type {} is not an annotation interface

When it happens

Trigger: Thrown at espresso-compiler-stub/src/com.oracle.truffle.espresso.vmaccess/src/com/oracle/truffle/espresso/vmaccess/EspressoExternalHostProxies.java:645 when the library encounters an invalid state.

Common situations: Occurs when a caller violates the contract guarded by this check: Annotation value type {} is not an annotation interface


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