{"record":{"id":"449f8f1e02c70651","repo":"oracle/graal","slug":"no-original-class-for-type","errorCode":null,"errorMessage":"No original class for type {}","messagePattern":"No original class for type (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"compiler/src/jdk.graal.compiler.hostvmaccess/src/jdk/graal/compiler/hostvmaccess/HostVMAccess.java","lineNumber":442,"sourceCode":"\n    @Override\n    public ResolvedJavaModule getModule(ResolvedJavaType type) {\n        return new HostVMResolvedJavaModuleImpl(getOriginalClass(type).getModule());\n    }\n\n    @Override\n    public ResolvedJavaPackage getPackage(ResolvedJavaType type) {\n        Package pkg = getOriginalClass(type).getPackage();\n        if (pkg == null) {\n            return null;\n        }\n        return new HostVMResolvedJavaPackageImpl(providers.getMetaAccess(), pkg);\n    }\n\n    private Class<?> getOriginalClass(ResolvedJavaType type) {\n        Class<?> originalClass = providers.getSnippetReflection().originalClass(type);\n        if (originalClass == null) {\n            throw new RuntimeException(\"No original class for type \" + type);\n        }\n        return originalClass;\n    }\n\n    @Override\n    public ResolvedJavaModuleLayer bootModuleLayer() {\n        return new HostVMResolvedJavaModuleLayerImpl(ModuleLayer.boot());\n    }\n\n    @Override\n    public URL getCodeSourceLocation(ResolvedJavaType type) {\n        Class<?> originalClass = providers.getSnippetReflection().originalClass(type);\n        ProtectionDomain pd = originalClass.getProtectionDomain();\n        CodeSource cs = pd.getCodeSource();\n        if (cs == null) {\n            return null;\n        }\n        return cs.getLocation();","sourceCodeStart":424,"sourceCodeEnd":460,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/jdk.graal.compiler.hostvmaccess/src/jdk/graal/compiler/hostvmaccess/HostVMAccess.java#L424-L460","documentation":"HostVMAccess.getOriginalClass asks snippetReflection.originalClass(type) to map a ResolvedJavaType back to a host Class<?>; if the mapping is unknown it returns null and this RuntimeException is thrown (used by getPackage and other type->Class operations). It means the ResolvedJavaType was not created by / is not known to this host JVM's JVMCI backend, so no original class exists to reflect on.","triggerScenarios":"Calling VMAccess.getPackage(type) (or any API routing through getOriginalClass) with a ResolvedJavaType resolved by a different JVMCI runtime, a guest-VM meta access, an unresolved or synthetic type, or a type whose class was never loaded reflectably on the host.","commonSituations":"Sharing ResolvedJavaType instances across two VMAccess implementations (host vs isolated); unit tests constructing mock/foreign ResolvedJavaType objects; types created from a class file stream without a corresponding host Class.","solutions":["Only pass types resolved by the same providers/MetaAccessProvider that backs this HostVMAccess","Use providers.getSnippetReflection().originalClass(type) yourself first and skip/branch when it returns null instead of letting the RuntimeException escape","Load the class on the host (e.g. via lookupAppClassLoaderType/Class.forName) and re-resolve the type so originalClass can map it"],"exampleFix":"// before\nResolvedJavaPackage pkg = vmAccess.getPackage(foreignType);\n\n// after\nif (providers.getSnippetReflection().originalClass(foreignType) == null) {\n    // type unknown on this host - resolve it through this runtime first\n    foreignType = providers.getMetaAccess().lookupJavaType(hostClass);\n}\nResolvedJavaPackage pkg = vmAccess.getPackage(foreignType);","handlingStrategy":"validation","validationCode":"Class<?> hostClass = providers.getSnippetReflection().originalClass(type);\nif (hostClass == null) {\n    // type unknown to this host - re-resolve via this runtime or skip\n}","typeGuard":null,"tryCatchPattern":"catch (RuntimeException e) { if (e.getMessage().startsWith(\"No original class\")) { fall back to type.getSourceName()/toJavaName based handling; } else throw e; }","preventionTips":["Only feed ResolvedJavaType instances produced by the same MetaAccessProvider","Track the origin of types in cross-VM pipelines and re-resolve at boundaries","Unit-test with real resolved types, not mocks, when host reflection is involved"],"tags":["graalvm","vmaccess","snippet-reflection","resolvedjavatype"],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}