{"record":{"id":"cf5eeb5f4b3ec243","repo":"oracle/graal","slug":"element-should-be-a-got-cf5eeb","errorCode":null,"errorMessage":"Element  should be a , got ","messagePattern":"Element  should be a , got ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"espresso-compiler-stub/src/com.oracle.truffle.espresso.vmaccess/src/com/oracle/truffle/espresso/vmaccess/EspressoExternalVMAccess.java","lineNumber":640,"sourceCode":"            }\n            throw e;\n        }\n    }\n\n    @Override\n    public void writeArrayElement(JavaConstant array, int index, JavaConstant element) {\n        if (!(array instanceof EspressoExternalObjectConstant espressoArray)) {\n            throw new IllegalArgumentException(\"Expected an EspressoExternalObjectConstant, got \" + safeGetClass(array));\n        }\n        EspressoResolvedObjectType arrayType = espressoArray.getType();\n        if (!arrayType.isArray()) {\n            throw new IllegalArgumentException(\"Expected an array type, got \" + arrayType);\n        }\n        ResolvedJavaType componentType = arrayType.getComponentType();\n        Object unwrappedValue;\n        if (componentType.isPrimitive()) {\n            if (componentType.getJavaKind() != element.getJavaKind()) {\n                throw new IllegalArgumentException(\"Element \" + element + \" should be a \" + componentType.getJavaKind() + \", got \" + element.getJavaKind());\n            }\n            unwrappedValue = element.asBoxedPrimitive();\n        } else if (element.isNull()) {\n            unwrappedValue = null;\n        } else {\n            if (!(element instanceof EspressoExternalObjectConstant objectElement)) {\n                throw new IllegalArgumentException(\"Element \" + element + \" should be an espresso object constant, got \" + safeGetClass(element));\n            }\n            unwrappedValue = objectElement.getValue();\n        }\n        try {\n            espressoArray.getValue().setArrayElement(index, unwrappedValue);\n        } catch (ClassCastException e) {\n            /*\n             * This exception suggests that the element is not assignable to the component type of\n             * the array, but let's double-check to make sure we do not re-interpret an unrelated\n             * exception.\n             */","sourceCodeStart":622,"sourceCodeEnd":658,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso-compiler-stub/src/com.oracle.truffle.espresso.vmaccess/src/com/oracle/truffle/espresso/vmaccess/EspressoExternalVMAccess.java#L622-L658","documentation":"Error \"Element  should be a , got \" thrown in oracle/graal.","triggerScenarios":"Thrown at espresso-compiler-stub/src/com.oracle.truffle.espresso.vmaccess/src/com/oracle/truffle/espresso/vmaccess/EspressoExternalVMAccess.java:640 when the library encounters an invalid state.","commonSituations":"Occurs when a caller violates the contract guarded by this check: Element  should be a , got","solutions":["Fix the condition reported by the error: Element  should be a , 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: Element  should be a , 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-15T17:31:12.345Z"}