oracle/graal · error · RuntimeException
No original class for type {}
Error message
No original class for type {} What it means
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.
Source
Thrown at compiler/src/jdk.graal.compiler.hostvmaccess/src/jdk/graal/compiler/hostvmaccess/HostVMAccess.java:442
@Override
public ResolvedJavaModule getModule(ResolvedJavaType type) {
return new HostVMResolvedJavaModuleImpl(getOriginalClass(type).getModule());
}
@Override
public ResolvedJavaPackage getPackage(ResolvedJavaType type) {
Package pkg = getOriginalClass(type).getPackage();
if (pkg == null) {
return null;
}
return new HostVMResolvedJavaPackageImpl(providers.getMetaAccess(), pkg);
}
private Class<?> getOriginalClass(ResolvedJavaType type) {
Class<?> originalClass = providers.getSnippetReflection().originalClass(type);
if (originalClass == null) {
throw new RuntimeException("No original class for type " + type);
}
return originalClass;
}
@Override
public ResolvedJavaModuleLayer bootModuleLayer() {
return new HostVMResolvedJavaModuleLayerImpl(ModuleLayer.boot());
}
@Override
public URL getCodeSourceLocation(ResolvedJavaType type) {
Class<?> originalClass = providers.getSnippetReflection().originalClass(type);
ProtectionDomain pd = originalClass.getProtectionDomain();
CodeSource cs = pd.getCodeSource();
if (cs == null) {
return null;
}
return cs.getLocation();View on GitHub (pinned to a66e9ccd1d)
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
Example fix
// before
ResolvedJavaPackage pkg = vmAccess.getPackage(foreignType);
// after
if (providers.getSnippetReflection().originalClass(foreignType) == null) {
// type unknown on this host - resolve it through this runtime first
foreignType = providers.getMetaAccess().lookupJavaType(hostClass);
}
ResolvedJavaPackage pkg = vmAccess.getPackage(foreignType); Defensive patterns
Strategy: validation
Validate before calling
Class<?> hostClass = providers.getSnippetReflection().originalClass(type);
if (hostClass == null) {
// type unknown to this host - re-resolve via this runtime or skip
} Try / catch
catch (RuntimeException e) { if (e.getMessage().startsWith("No original class")) { fall back to type.getSourceName()/toJavaName based handling; } else throw e; } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Could not unwrap array: {}
- Could not unwrap an array constant: {}
- Element {} should be a {}, got {}
- Element {} should be an object, got {}
- Expected an array constant, got {}
AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14).
Data as JSON: /api/errors/449f8f1e02c70651.
Report an issue: GitHub.