{"record":{"id":"c93a336d09fa70cf","repo":"oracle/graal","slug":"expected-an-espressoexternalresolvedjavamodule-go","errorCode":null,"errorMessage":"Expected an EspressoExternalResolvedJavaModule, got {}","messagePattern":"Expected an EspressoExternalResolvedJavaModule, 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/EspressoExternalResolvedJavaModule.java","lineNumber":73,"sourceCode":"    }\n\n    @Override\n    public String getName() {\n        return name;\n    }\n\n    @Override\n    public boolean isOpen(String packageName) {\n        Objects.requireNonNull(packageName);\n        Value packageNameValue = access.invokeJVMCIHelper(\"toGuestString\", packageName);\n        return access.java_lang_Module_isOpen_String.getMirror().execute(moduleValue, packageNameValue).asBoolean();\n    }\n\n    @Override\n    public boolean isOpen(String packageName, ResolvedJavaModule accessingModule) {\n        Objects.requireNonNull(packageName);\n        if (!(accessingModule instanceof EspressoExternalResolvedJavaModule espressoModule)) {\n            throw new IllegalArgumentException(\"Expected an EspressoExternalResolvedJavaModule, got \" + safeGetClass(accessingModule));\n        }\n        Value packageNameValue = access.invokeJVMCIHelper(\"toGuestString\", packageName);\n        return access.java_lang_Module_isOpen_String_Module.getMirror().execute(moduleValue, packageNameValue, espressoModule.moduleValue).asBoolean();\n    }\n\n    @Override\n    public boolean isExported(String packageName) {\n        Objects.requireNonNull(packageName);\n        Value packageNameValue = access.invokeJVMCIHelper(\"toGuestString\", packageName);\n        return access.java_lang_Module_isExported_String.getMirror().execute(moduleValue, packageNameValue).asBoolean();\n    }\n\n    @Override\n    public boolean isExported(String packageName, ResolvedJavaModule accessingModule) {\n        Objects.requireNonNull(packageName);\n        if (!(accessingModule instanceof EspressoExternalResolvedJavaModule espressoModule)) {\n            throw new IllegalArgumentException(\"Expected an EspressoExternalResolvedJavaModule, got \" + safeGetClass(accessingModule));\n        }","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/espresso-compiler-stub/src/com.oracle.truffle.espresso.vmaccess/src/com/oracle/truffle/espresso/vmaccess/EspressoExternalResolvedJavaModule.java#L55-L91","documentation":"Thrown by EspressoExternalResolvedJavaModule.isOpen(String, ResolvedJavaModule) when the accessingModule argument is not an EspressoExternalResolvedJavaModule. The two-argument isOpen forwards the accessing module's guest module Value into the guest j.l.Module.isOpen(String, Module) call, so only module wrappers created by the same Espresso vmaccess layer (which carry that Value) are usable; modules resolved by another JVMCI backend (e.g. the host compiler's own module meta objects) are rejected. safeGetClass reports the actual class, or 'null' when safe.","triggerScenarios":"Calling isOpen(packageName, accessingModule) where accessingModule came from the host JVMCI (HostResolvedJavaModule from libgraal/HotSpot backend) or is null; mixing module objects across a pipeline that talks to both a host and the Espresso guest VM.","commonSituations":"Compiler configurations that consult both the host module graph and the guest module graph for readability checks; porting code from an in-process JVMCI (where any ResolvedJavaModule worked) to the external espresso-compiler-stub adapter.","solutions":["Resolve the accessing module through the same EspressoExternalVMAccess so it is an EspressoExternalResolvedJavaModule","Use the single-argument isOpen(packageName) when you only need unconditional openness and cannot obtain the guest wrapper for the accessor","Null-check accessingModule before the call (safeGetClass will show null)"],"exampleFix":"// before\nboolean open = espressoModule.isOpen(pkg, hostBackendModule);\n\n// after\nResolvedJavaModule guestAccessor = access.findModule(accessorClass);\nboolean open = espressoModule.isOpen(pkg, guestAccessor);","handlingStrategy":"type-guard","validationCode":"if (accessingModule == null || !(accessingModule instanceof EspressoExternalResolvedJavaModule)) {\n    // fall back to unconditional form or fail with a clear diagnostic\n    boolean open = module.isOpen(packageName);\n    ...\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Resolve accessing modules through the same EspressoExternalVMAccess as the target module","Prefer the single-argument isOpen(packageName) when the guest accessor wrapper is unavailable","Never pass host-backend ResolvedJavaModule implementations into guest module queries"],"tags":["espresso","jvmci","module","type-mismatch","opens"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}