{"record":{"id":"3ba7115164b86b45","repo":"oracle/graal","slug":"expected-guest-annotation-object-got","errorCode":null,"errorMessage":"Expected guest annotation object, got {}","messagePattern":"Expected guest annotation object, got (.+?)","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"espresso-compiler-stub/src/com.oracle.truffle.espresso.vmaccess/src/com/oracle/truffle/espresso/vmaccess/EspressoExternalHostProxies.java","lineNumber":634,"sourceCode":"    }\n\n    /**\n     * Converts an {@link AnnotationValue} returned by a host method into a guest-owned annotation\n     * compatible with the guest method's declared return type.\n     */\n    @SuppressWarnings(\"unused\")\n    private Value annotationValueAsGuestAnnotation(ResolvedJavaType expectedAnnotationType, AnnotationValue annotationValue) {\n        if (annotationValue == null) {\n            return null;\n        }\n        if (annotationValue.isError()) {\n            throw annotationValue.getError();\n        }\n        ResolvedJavaType actualAnnotationType = annotationValue.getAnnotationType();\n        validateAnnotationType(expectedAnnotationType, actualAnnotationType, \"guest return type\");\n        JavaConstant annotationConstant = Objects.requireNonNull(createGuestAnnotation(annotationValue));\n        if (!(annotationConstant instanceof EspressoExternalObjectConstant objectConstant)) {\n            throw new IllegalArgumentException(\"Expected guest annotation object, got \" + annotationConstant);\n        }\n        return objectConstant.getValue();\n    }\n\n    /**\n     * Verifies that an annotation value names an annotation interface assignable to the declared\n     * guest type.\n     */\n    private static void validateAnnotationType(ResolvedJavaType expectedAnnotationType, ResolvedJavaType actualAnnotationType, String expectedTypeDescription) {\n        if (!actualAnnotationType.isAnnotation()) {\n            throw new IllegalArgumentException(\"Annotation value type \" + actualAnnotationType.toJavaName() + \" is not an annotation interface\");\n        }\n        if (!expectedAnnotationType.isAssignableFrom(actualAnnotationType)) {\n            throw new IllegalArgumentException(\n                            \"Annotation value type \" + actualAnnotationType.toJavaName() + \" is not assignable to \" + expectedTypeDescription + \" \" + expectedAnnotationType.toJavaName());\n        }\n    }\n","sourceCodeStart":616,"sourceCodeEnd":652,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso-compiler-stub/src/com.oracle.truffle.espresso.vmaccess/src/com/oracle/truffle/espresso/vmaccess/EspressoExternalHostProxies.java#L616-L652","documentation":"Error \"Expected guest annotation object, got {}\" thrown in oracle/graal.","triggerScenarios":"Thrown at espresso-compiler-stub/src/com.oracle.truffle.espresso.vmaccess/src/com/oracle/truffle/espresso/vmaccess/EspressoExternalHostProxies.java:634 when the library encounters an invalid state.","commonSituations":"Occurs when a caller violates the contract guarded by this check: Expected guest annotation object, got {}","solutions":["Fix the condition reported by the error: Expected guest annotation object, got {}","Check the throwing call site and ensure its documented preconditions (argument values, types, environment, or configuration) are satisfied before the call."],"exampleFix":"Validate inputs and environment so that the failing condition does not occur: Expected guest annotation object, got {}","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}