{"record":{"id":"cbe0af2da930688d","repo":"oracle/graal","slug":"element-of-type-is-not-assignable-to","errorCode":null,"errorMessage":"Element  of type  is not assignable to ","messagePattern":"Element  of type  is not assignable to ","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":660,"sourceCode":"            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    }\n\n    @Override\n    public ResolvedJavaMethod asResolvedJavaMethod(Constant constant) {\n        if (constant instanceof EspressoExternalObjectConstant espressoConstant) {\n            // j.l.r.Executable?\n            Value value = espressoConstant.getValue();\n            String name = value.getMetaObject().getMetaQualifiedName();\n            if (\"java.lang.reflect.Method\".equals(name) || \"java.lang.reflect.Constructor\".equals(name)) {\n                return EspressoExternalConstantReflectionProvider.methodAsJavaResolvedMethod(value, this);\n            }\n        }\n        return null;\n    }","sourceCodeStart":642,"sourceCodeEnd":678,"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#L642-L678","documentation":"Error \"Element  of type  is not assignable to \" thrown in oracle/graal.","triggerScenarios":"Thrown at espresso-compiler-stub/src/com.oracle.truffle.espresso.vmaccess/src/com/oracle/truffle/espresso/vmaccess/EspressoExternalVMAccess.java:660 when the library encounters an invalid state.","commonSituations":"Occurs when a caller violates the contract guarded by this check: Element  of type  is not assignable to","solutions":["Fix the condition reported by the error: Element  of type  is not assignable to","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  of type  is not assignable to","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"}