docs/reference-manual/java-on-truffle/ImplementationDetails.md
Espresso operates, like other languages implemented with Truffle, both as a native executable or on HotSpot (currently possible on Linux only).
In the first case, when the Espresso runtime is compiled to a native executable, it does not require HotSpot to run Java.
However, it requires a standard core Java library (the rt.jar library for Java 8 or the lib/modules file for Java 11+, as well as the associated native libraries: libjava, libnio, and so on).
Espresso is a minified Java VM that implements all core components of a VM including:
Espresso reuses all JAR files and native libraries from GraalVM.
All native libraries and methods are loaded/accessed/called via Truffle Native Function Interface (JNI).
JNI handles are implemented in Espresso, for example, all Truffle NFI methods only receive and return primitives.
Some methods are substituted for performance, for example, Math.sqrt, System.arraycopy, avoiding the expensive transition to native.
Some native libraries might contain static data that would conflict if were used from multiple Espresso contexts or even from both Espresso and Java running on HotSpot.
On Linux, Espresso uses the capability of Truffle NFI to try to load libraries in isolated namespaces (dlmopen). This is only available on Linux with glibc and has many limitations.
This mode is not used when running in a native executable since there will be no conflict with HotSpot.
-agentlib, or -agentpath VM options.java.lang.instrument interface. As a result it does not support the -javaagent VM option.Context native access. Because of the way these libraries are loaded (via Truffle NFI), running on HotSpot only works on Linux (with glibc). Running as part of a native executable works on Linux, Windows, and macOS but it currently limited to one context.java.MultiThreaded option is set to "false", reference processing will not happen. Depending on the application, this could create resource leaks. Note that this option is set to "false" automatically if Espresso runs in a context where a single-threaded language is enabled (for example, JavaScript).polyglot.jar. For more information, see Interoperability with Truffle Languages.