You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Java on Truffle is an implementation of the Java Virtual Machine Specification, which offers some interesting capabilities in addition to being able to run applications in Java or other JVM languages.
11
+
Espresso is an implementation of the Java Virtual Machine Specification, which offers some interesting capabilities in addition to being able to run applications in Java or other JVM languages.
11
12
For example, the enhanced [HotSwap capabilities](HotSwap.md) boosts developer productivity by enabling unlimited hot code reloading.
12
-
Moreover, to illustrate what Java on Truffle can do, consider the following short examples.
13
+
Moreover, to illustrate what Espresso can do, consider the following short examples.
The main trade off for using Native Image is that the analysis and compilation of your program happens under the closed world assumption, meaning the static analysis needs to process all bytecode which will ever be executed in the application.
22
23
This makes using some language features such as dynamic class loading or reflection tricky.
23
24
24
-
Java on Truffle is a JVM implementation of a JVM bytecode interpreter, built on the [Truffle framework](../../../truffle/docs/README.md).
25
+
Espresso is a JVM implementation of a JVM bytecode interpreter, built on the [Truffle framework](../../../truffle/docs/README.md).
25
26
It is essentially a Java application, as are the Truffle framework itself and the GraalVM JIT compiler.
26
27
All three of them can be compiled ahead-of-time with `native-image`.
27
-
Using Java on Truffle for some parts of your application makes it possible to isolate the required dynamic behavior and still use the native executable on the rest of your code.
28
+
Using Espresso for some parts of your application makes it possible to isolate the required dynamic behavior and still use the native executable on the rest of your code.
28
29
29
30
Consider a canonical Java Shell tool (JShell) as an example command line application.
30
31
It is a REPL capable of evaluating Java code and consists of two parts:
31
32
* the UI - CLI app handling input-output
32
33
* the backend processor for running code you enter into Shell.
33
34
34
-
This design naturally fits the point we are trying to illustrate. We can build a native executable of the JShell's UI part, and make it include Java on Truffle to run the code dynamically specified at run time.
35
+
This design naturally fits the point we are trying to illustrate. We can build a native executable of the JShell's UI part, and make it include Espresso to run the code dynamically specified at run time.
The JShell implementation is actually the normal JShell launcher code, which only accepts Java on Truffle implementation (the project code-name is "Espresso") of the execution engine.
47
+
The JShell implementation is actually the normal JShell launcher code, which only accepts Espresso implementation of the execution engine.
48
48
49
49
The "glue" code that binds the part which is AOT compiled with the component that dynamically evaluates the code is located in the `EspressoExecutionControl` class.
50
-
It loads the JShell classes within the Java on Truffle context and delegate the input to them:
50
+
It loads the JShell classes within the Espresso context and delegate the input to them:
51
51
52
-
```
53
-
protected final Lazy<Value> ClassBytecodes = Lazy.of(() -> loadClass("jdk.jshell.spi.ExecutionControl$ClassBytecodes"));
54
-
protected final Lazy<Value> byte_array = Lazy.of(() -> loadClass("[B"));
55
-
protected final Lazy<Value> ExecutionControlException = Lazy.of(() -> loadClass("jdk.jshell.spi.ExecutionControl$ExecutionControlException"));
56
-
protected final Lazy<Value> RunException = Lazy.of(() -> loadClass("jdk.jshell.spi.ExecutionControl$RunException"));
57
-
protected final Lazy<Value> ClassInstallException = Lazy.of(() -> loadClass("jdk.jshell.spi.ExecutionControl$ClassInstallException"));
58
-
protected final Lazy<Value> NotImplementedException = Lazy.of(() -> loadClass("jdk.jshell.spi.ExecutionControl$NotImplementedException"));
59
-
protected final Lazy<Value> EngineTerminationException = Lazy.of(() -> loadClass("jdk.jshell.spi.ExecutionControl$EngineTerminationException"));
60
-
protected final Lazy<Value> InternalException = Lazy.of(() -> loadClass("jdk.jshell.spi.ExecutionControl$InternalException"));
61
-
protected final Lazy<Value> ResolutionException = Lazy.of(() -> loadClass("jdk.jshell.spi.ExecutionControl$ResolutionException"));
62
-
protected final Lazy<Value> StoppedException = Lazy.of(() -> loadClass("jdk.jshell.spi.ExecutionControl$StoppedException"));
63
-
protected final Lazy<Value> UserException = Lazy.of(() -> loadClass("jdk.jshell.spi.ExecutionControl$UserException"));
52
+
```shell
53
+
protected final Lazy<Value> ClassBytecodes = Lazy.of(() -> loadClass("jdk.jshell.spi.ExecutionControl$ClassBytecodes"));
54
+
protected final Lazy<Value> byte_array = Lazy.of(() -> loadClass("[B"));
55
+
protected final Lazy<Value> ExecutionControlException = Lazy.of(() -> loadClass("jdk.jshell.spi.ExecutionControl$ExecutionControlException"));
56
+
protected final Lazy<Value> RunException = Lazy.of(() -> loadClass("jdk.jshell.spi.ExecutionControl$RunException"));
57
+
protected final Lazy<Value> ClassInstallException = Lazy.of(() -> loadClass("jdk.jshell.spi.ExecutionControl$ClassInstallException"));
58
+
protected final Lazy<Value> NotImplementedException = Lazy.of(() -> loadClass("jdk.jshell.spi.ExecutionControl$NotImplementedException"));
59
+
protected final Lazy<Value> EngineTerminationException = Lazy.of(() -> loadClass("jdk.jshell.spi.ExecutionControl$EngineTerminationException"));
60
+
protected final Lazy<Value> InternalException = Lazy.of(() -> loadClass("jdk.jshell.spi.ExecutionControl$InternalException"));
61
+
protected final Lazy<Value> ResolutionException = Lazy.of(() -> loadClass("jdk.jshell.spi.ExecutionControl$ResolutionException"));
62
+
protected final Lazy<Value> StoppedException = Lazy.of(() -> loadClass("jdk.jshell.spi.ExecutionControl$StoppedException"));
63
+
protected final Lazy<Value> UserException = Lazy.of(() -> loadClass("jdk.jshell.spi.ExecutionControl$UserException"));
64
64
```
65
65
66
66
There is more code to pass the values correctly and transform the exceptions.
@@ -69,7 +69,7 @@ To try it out, build the `espresso-jshell` binary using the provided script, whi
69
69
2. Build the JAR file
70
70
3. Build a native executable
71
71
72
-
After the build you can observe the resulting binary file (`file` and `ldd` are Linux commands)
72
+
After the build you can observe the resulting binary file (`file` and `ldd` are Linux commands):
73
73
```shell
74
74
file ./espresso-jshell
75
75
ldd ./espresso-jshell
@@ -85,9 +85,9 @@ jshell> 1 + 1
85
85
1 ==> 2
86
86
```
87
87
88
-
Experiment with loading new code into JShell and see how Java on Truffle executes it.
88
+
Experiment with loading new code into JShell and see how Espresso executes it.
89
89
90
-
Watch a video version of the mixing AOT and JIT compiled code with Java on Truffle demo.
90
+
Watch a video version of the mixing AOT and JIT compiled code with the Espresso demo.
91
91
92
92
<divclass="row">
93
93
<divclass="col-sm-12">
@@ -109,14 +109,14 @@ Watch a video version of the mixing AOT and JIT compiled code with Java on Truff
109
109
<br>
110
110
111
111
112
-
## GraalVM Tools with Java on Truffle
112
+
## GraalVM Tools with Espresso
113
113
114
-
Java on Truffle is a proper part of the GraalVM ecosystem, and like other GraalVM-supported languages gets the support of developer tooling by default. The [Truffle framework](/graalvm-as-a-platform/language-implementation-framework/) integrates with the tools such as the debugger, profiler, memory analyzer, the [Instrumentation API](https://www.graalvm.org/truffle/javadoc/com/oracle/truffle/api/instrumentation/TruffleInstrument.html).
114
+
Espresso is a proper part of the GraalVM ecosystem, and like other GraalVM-supported languages gets the support of developer tooling by default. The [Truffle framework](/graalvm-as-a-platform/language-implementation-framework/) integrates with the tools such as the debugger, profiler, memory analyzer, the [Instrumentation API](https://www.graalvm.org/truffle/javadoc/com/oracle/truffle/api/instrumentation/TruffleInstrument.html).
115
115
The interpreter for a language needs to mark the AST nodes with some annotations to support those tools.
116
116
117
117
For example, to be able to use a profiler, a language interpreter needs to mark the root nodes.
118
118
For the debugger purposes, the language expressions should be marked as instrumental, the scopes for the variables specified, and so on. The language interpreter does not need to integrate with the tools itself.
119
-
As a result, you can profile a Java on Truffle program out of the box using either the CPU Sampler or Memory Tracer tools.
119
+
As a result, you can profile a Java application on Espresso out of the box using either the CPU Sampler or Memory Tracer tools.
120
120
121
121
For example, if we have a class like the following one computing the prime numbers:
Other tools that GraalVM offers are [Chrome Debugger](../../tools/chrome-debugger.md), [Code Coverage](../../tools/code-coverage.md), and [GraalVM Insight](../../tools/insight/README.md).
170
170
171
-
Having the "out-of-the-box" support for the developer tooling makes Java on Truffle an interesting choice of the JVM.
171
+
Having the "out-of-the-box" support for the developer tooling makes Espresso an interesting choice of the JVM.
172
172
173
-
Watch a short demonstration of GraalVM built-in tools for Java on Truffle.
173
+
Watch a short demonstration of GraalVM built-in tools for Espresso.
### Does Java running on Truffle implement the Java language running as a Truffle interpreter?
11
12
12
13
Not quite: it implements the Java Virtual Machine running as a Truffle interpreter.
13
-
That means it can only run a Java program once it has been compiled to Java bytecode (classes, JAR files, etc.) with your favorite Java compiler (for example, `javac`) or a build tool (Maven, Gradle, etc.).
14
+
That means it can only run a Java program once it has been compiled to Java bytecode (classes, JAR files, and so on) with your favorite Java compiler (for example, `javac`) or a build tool (Maven, Gradle, and so on).
14
15
In the GraalVM family, this is similar to WebAssembly or the LLVM interpreter: while both can run C programs, they have to be compiled by a C compiler first.
15
16
16
17
### Does Java running on Truffle run on the HotSpot JVM too?
17
-
Like other languages implemented with the [Truffle framework](../../../truffle/docs/README.md), it can run both as a native executable or on top of the HotSpot JVM.
18
-
Running on top of the HotSpot JVM is currently only possible on Linux x64 and macOS x64.
18
+
19
+
Like other languages implemented with the [Truffle framework](../../../truffle/docs/README.md), it can run both as a native executable or on the HotSpot JVM.
20
+
Running on the HotSpot JVM is currently only possible on Linux x64 and macOS x64.
19
21
We plan to extend this capability to other platforms.
20
22
21
-
### Does running Java on Truffle require the HotSpot JVM?
23
+
### Does running Espresso require the HotSpot JVM?
22
24
23
25
No, it doesn't, it works fine as a native executable.
24
-
Java on Truffle does require 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`, etc.).
26
+
Espresso does require 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).
27
+
28
+
### Running Java on GraalVM already brings the highest level of optimization, what benefits will Espresso give me?
25
29
26
-
### Running Java on GraalVM already brings the highest level of optimization, what benefits will Java on Truffle give me?
27
-
- Java on Truffle will inherit the extensive tooling provided by the Truffle framework. This means that for the things like code coverage and profiling you would no longer need to rely on external tools.
28
-
- Another important aspect is that Java on Truffle comes with improved isolation of the host Java VM and the Java program running on Truffle.
29
-
- Moreover, Java on Truffle can run in the context of a native executable while still allowing dynamically-loaded bytecode!
30
+
- Espresso inherits the extensive tooling provided by the Truffle framework. This means that for code coverage and profiling you would no longer need to rely on external tools.
31
+
- Another important aspect is that Espresso comes with improved isolation of the host Java VM and the Java program running on Truffle.
32
+
- Moreover, Espresso can run in the context of a native executable while still allowing dynamically-loaded bytecode!
30
33
- Finally, you can enjoy the benefits of enhanced HotSwap capabilities which will help boost your productivity.
31
34
32
-
### What is the license for Java on Truffle?
33
-
Java on Truffle is an implementation of the Java Virtual Machine. It is open source and is offered as free software under the [GNU General Public License version two (GPLv2)](https://github.com/oracle/graal/blob/master/tools/LICENSE).
35
+
### What is the license for Espresso?
36
+
37
+
Espresso is an implementation of the Java Virtual Machine. It is open source and is offered as free software under the [GNU General Public License version two (GPLv2)](https://github.com/oracle/graal/blob/master/tools/LICENSE).
38
+
39
+
### Can I run Espresso in production?
34
40
35
-
### Can I run Java on Truffle in production?
36
41
Yes, you can on Linux x64. Support for other platforms is still experimental.
37
42
38
-
### What performance can I expect from executing Java on Truffle?
43
+
### What performance can I expect from executing Espresso?
44
+
39
45
Performance is currently 2-3x slower than the HotSpot JVM.
40
-
It does not match the speed offered by GraalVM yet for sure, but having created a fully-working Java on Truffle runtime, the development team is now focusing on making it as performant as the GraalVM JIT.
46
+
It does not match the speed offered by GraalVM yet for sure, but having created a fully-working Espresso runtime, the development team is now focusing on making it as performant as the GraalVM JIT.
41
47
42
48
### Can I embed Java running on Truffle in my application?
49
+
43
50
Yes, you can use [GraalVM's Polyglot API](https://www.graalvm.org/sdk/javadoc/org/graalvm/polyglot/package-summary.html) to run Java bytecode in a separate context from the host Java VM.
44
-
You can even embed a Java 8 context in a Java 11, 17 or 21 application (using the option `--java.JavaHome=/path/to/jdk8`).
51
+
You can even embed a Java 8 context in a Java 11, 17, or 21 application (using the option `--java.JavaHome=/path/to/jdk8`).
45
52
46
53
### Why do I see "Unrecognized option: -javaagent:.../idea_rt.jar..." when I try to run my app from the IDE?
47
-
It is not possible to attach an agent to Java on Truffle. For the time being, add: `-XX:+IgnoreUnrecognizedVMOptions` to the VM options too.
54
+
55
+
It is not possible to attach an agent to Espresso. For the time being, add `-XX:+IgnoreUnrecognizedVMOptions` to the VM options.
0 commit comments