{"record":{"id":"be4c4ceb92363240","repo":"oracle/graal","slug":"element-should-be-an-espresso-object-constant-go","errorCode":null,"errorMessage":"Element  should be an espresso object constant, got ","messagePattern":"Element  should be an espresso object constant, 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":647,"sourceCode":"        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             */\n            if (element instanceof EspressoExternalObjectConstant objectConstant && !componentType.isAssignableFrom(objectConstant.getType())) {\n                throw new IllegalArgumentException(\"Element \" + element + \" of type \" + objectConstant.getType() + \" is not assignable to \" + componentType, e);\n            }\n            // Unrelated exception, just rethrow it.\n            throw e;\n        }\n    }","sourceCodeStart":629,"sourceCodeEnd":665,"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#L629-L665","documentation":"Error \"Element  should be an espresso object constant, 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:647 when the library encounters an invalid state.","commonSituations":"Occurs when a caller violates the contract guarded by this check: Element  should be an espresso object constant, got","solutions":["Fix the condition reported by the error: Element  should be an espresso object constant, 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 an espresso object constant, 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"}