-
Notifications
You must be signed in to change notification settings - Fork 0
OpenJDK Patches
VM-specific implementations of OpenJDK classes for JNode compatibility.
OpenJDK Patches are JNode's approach to modifying the standard Java class library for its custom JVM. Instead of using traditional patch files applied to source code, JNode provides complete VM-specific implementations of OpenJDK classes that replace the standard implementations at build time.
This approach allows JNode to:
- Connect standard Java classes to JNode's native subsystems (file I/O, network, graphics)
- Maintain API compatibility with standard Java while using JNode-specific internals
- Avoid JNI by implementing native methods directly using VM Magic annotations
| Class / File | Role |
|---|---|
core/src/openjdk/vm/java/lang/*.java |
Java language runtime patches (String, Process, Throwable, etc.) |
core/src/openjdk/vm/java/io/*.java |
I/O system patches (File, Console, Object streams) |
core/src/openjdk/vm/java/net/*.java |
Network API patches (Socket, Datagram, InetAddress) |
core/src/openjdk/vm/java/awt/*.java |
AWT native peer implementations |
core/src/openjdk/vm/sun/misc/*.java |
Sun internal classes (Unsafe, Signal, VM support) |
core/src/openjdk/vm/sun/management/*.java |
Management and diagnostic interfaces |
core/src/openjdk/vm/sun/font/*.java |
Font rendering native implementations |
-
Build-Time Resolution: During boot image creation, classes in
core/src/openjdk/vm/take precedence over the same classes fromclasslib.jar. -
Native Method Binding: Each patch class implements
nativemethods that connect to JNode's VM using@MagicPermissionandVmMagicintrinsics. -
Package Preservation: Patches maintain their original package names (
java.*,sun.*,com.sun.*) to ensure compatibility with code expecting those namespaces.
The NativeFileSystem.java patch replaces java.io.FileSystem to provide:
- JNode-specific path resolution
- Integration with JNode's VFS layer
- Permission and attribute handling via JNode's security model
The NativeUnsafe.java patch provides:
- Direct memory access without JNI
- Object field offset calculations
- Thread park/unpark using JNode's scheduler
- No JNI: All native methods use VM Magic instead of JNI, requiring special compiler support.
- Package Identity: Patches must match the exact package of the class they replace.
- Version Sensitivity: Patches must track the version of OpenJDK used in classlib.jar.
- Incomplete Coverage: Not all OpenJDK classes are patched—some use GNU Classpath equivalents.
- Class-Library-Integration - Full integration architecture
- Class-Library - Basic class library documentation
- VM-Magic - Magic annotations for VM integration
- OpenJDK - OpenJDK project context
- Java-API - Java API coverage in JNode