Skip to content

Class Library

Levente Santha edited this page May 9, 2026 · 1 revision

Class Library

JNode implements the standard Java class library by integrating and patching GNU Classpath and OpenJDK.

Overview

Because JNode is an operating system that runs directly on hardware (without a host OS like Linux or Windows), standard Java library calls that typically rely on OS-level native methods (like Thread.start(), System.out.println(), or file I/O) cannot work out of the box.

To provide a fully compliant Java environment, JNode downloads standard class library jars during the build process and layers its own custom VM-specific implementations on top of them.

Key Components

Class / File Role
core/src/classpath/vm/ JNode's custom implementations of GNU Classpath VM classes.
core/src/openjdk/vm/ JNode's custom implementations of OpenJDK VM classes.
all/lib/classlib.jar The downloaded base class library (managed by the build system).

How It Works

  1. Base Libraries: During sh build.sh, the build system downloads the required base standard libraries (e.g., a pre-compiled GNU Classpath or OpenJDK jar) to all/lib/classlib.jar if they are not already present.
  2. VM Overrides: Classes inside core/src/classpath/vm/ and core/src/openjdk/vm/ replace or supplement the standard implementations. For instance, JNode provides its own java.lang.VMThread and java.lang.VMSystem which interface directly with the JNode kernel and scheduler rather than making native OS calls.
  3. Boot Image Generation: The BootImageBuilder weaves these standard classes and JNode's VM-specific overrides together into the final boot image, replacing native method bindings with JNode's own magic or Java-based native implementations.

Gotchas & Non-Obvious Behavior

  • No Native OS Methods: You cannot use JNI to call C/C++ libraries. Any "native" method in standard Java classes must have a JNode-specific implementation, typically handled via @MagicPermission or written purely in Java using VmMagic.
  • Finding the Source of Truth: If you are debugging a standard Java class (like java.io.File), check core/src/classpath/ or core/src/openjdk/ first to see if JNode overrides its behavior. If it doesn't, the issue might be in the underlying downloaded classlib.jar or in how JNode's JIT compiler processes it.

Related Pages

Clone this wiki locally