oracle/graal · error · IllegalArgumentException

Annotation value type {} is not assignable to {} {}

Error message

Annotation value type {} is not assignable to {} {}

What it means

Error "Annotation value type {} is not assignable to {} {}" thrown in oracle/graal.

Source

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

        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();
        AnnotationValueType annotationValueType = AnnotationValueType.getInstance(actualAnnotationType);
        AnnotationValueValidation.validateElements(annotationValue, annotationValueType);
        Map<String, Object> memberDefaults = annotationValueType.memberDefaults();

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Fix the condition reported by the error: Annotation value type {} is not assignable to {} {}
  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 assignable to {} {}

When it happens

Trigger: Thrown at espresso-compiler-stub/src/com.oracle.truffle.espresso.vmaccess/src/com/oracle/truffle/espresso/vmaccess/EspressoExternalHostProxies.java:648 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 assignable to {} {}


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