-
Notifications
You must be signed in to change notification settings - Fork 0
VMProcessClassLoader
Classloader for VM processes that loads classes from the VM process's classpath, providing process isolation through a dedicated classloader hierarchy.
JNode's VMProcessClassLoader (org.jnode.vm.VmProcessClassLoader) is a specialized Java ClassLoader that provides class loading for VM processes created via VmProcess.createProcess(). Unlike JNode's primary VmClassLoader hierarchy (which integrates with the plugin system and handles class definition for the VM kernel), VMProcessClassLoader operates at the user-level process abstraction.
The key design rationale is process isolation: each VmProcess gets its own VmProcessClassLoader instance with a parent-first delegation that can selectively skip the parent for specific core classes. This ensures that system classes like java.lang.System and org.jnode.vm.VmProcess are loaded from the VM's core classes rather than from the process's classpath, preventing processes from accidentally overriding critical system classes.
VmProcessClassLoader extends the standard Java ClassLoader rather than JNode's VmClassLoader because it operates in a different layer — the user-process layer built on top of the VM, not the VM kernel itself.
| Class / File | Role |
|---|---|
core/src/core/org/jnode/vm/VmProcessClassLoader.java |
Main classloader implementation |
core/src/core/org/jnode/vm/VmProcess.java |
VM process creation, uses VmProcessClassLoader for process isolation |
When VmProcess.createProcess() is invoked, it:
- Creates a new
VmProcessClassLoaderinstance - Uses this classloader to load
VmProcessclass - Reflectively instantiates a new
VmProcessvia the constructor - The new process runs with its own classloader, isolated from the parent
// From VmProcess.java:121-142
public static Process createProcess(String mainClassName, String[] args, String[] envp)
throws Exception {
final ClassLoader cl = new VmProcessClassLoader();
final Class processClass = cl.loadClass(VmProcess.class.getName());
// ... reflective instantiation
}The VmProcessClassLoader maintains a HashSet<String> of class names that should not be delegated to the parent classloader:
// From VmProcessClassLoader.java:33-45
private final HashSet<String> skipClassNames;
public VmProcessClassLoader(ClassLoader parent) {
super(parent);
skipClassNames = new HashSet<String>();
skipClassNames.add("java.lang.System");
skipClassNames.add("org.jnode.vm.VmProcess");
}The skipParentLoader(String name) method checks if a class should bypass the parent:
// From VmProcessClassLoader.java:54-57
public boolean skipParentLoader(String name) {
name = name.replace('/', '.');
return skipClassNames.contains(name);
}This ensures that critical system classes are always loaded from the VM's core, not from any process-specific classpath.
BootstrapClassLoader (JVM built-in)
└── SystemClassLoader (ClassLoader.getSystemClassLoader())
└── VmProcessClassLoader (per-process instance)
└── [Process classes loaded from process classpath]
-
Standard ClassLoader, not VmClassLoader —
VmProcessClassLoaderextendsjava.lang.ClassLoaderdirectly, not JNode'sVmClassLoader. This is by design: it operates in the user-process layer, not the VM kernel layer. -
skipParentLoader is advisory — The
skipParentLoader()method exists but is not automatically invoked during normalloadClass()delegation. The caller (typicallyVmProcess) must check this explicitly before deciding whether to delegate to the parent. -
Process isolation is lightweight — Unlike
Isolatewhich provides strong isolation via separate statics tables,VmProcessisolation is primarily through the classloader. Both approaches exist in JNode for different use cases. -
Default parent is system classloader — The no-arg constructor uses
ClassLoader.getSystemClassLoader()as the parent, ensuring access to core Java classes.
- VmClassLoader — JNode's primary VM classloader hierarchy
- VM-Classloader — JVM classloader implementation with plugin delegation
- Isolate-Implementation — Alternative process isolation via isolates and dual-statics
- Class-Library-Integration — Class loading integration with GNU Classpath/OpenJDK