Skip to content

Commit acbc5ae

Browse files
Add some notes on EXTRA_ESPRESSO_JAVA_HOMES in hacking.md
1 parent 0edee9f commit acbc5ae

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

espresso/docs/hacking.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,34 @@ $ mx --dy /espresso,/sulong maven-deploy --tags=public --all-suites --all-distri
8484

8585
You can now depend on the jars using a version like `24.2.1-SNAPSHOT`.
8686

87+
For embedding, there is a jar containing all the necessary JDK resources (classes, libraries, config files, etc.).
88+
This jar is made available to espresso through the truffle [resource API](https://www.graalvm.org/truffle/javadoc/com/oracle/truffle/api/TruffleLanguage.Env.html#getInternalResource(java.lang.String)).
89+
It is the mx distribution called `ESPRESSO_RUNTIME_RESOURCES` and is published on maven as `org.graalvm.espresso:espresso-runtime-resources-$RuntimeResourceId` where `$RuntimeResourceId` identifies the type and version of the included JDK.
90+
For example `org.graalvm.espresso:espresso-runtime-resources-jdk21` contain Oracle JDK 21.
91+
`ESPRESSO_RUNTIME_RESOURCES` contains the JDK specified through `ESPRESSO_JAVA_HOME` as well as the optional llvm bits specified in `ESPRESSO_LLVM_JAVA_HOME`.
92+
93+
Since we might want to distribute these resources for multiple JDK version, it is possible to produce additional runtime resource jars.
94+
This is done by setting `EXTRA_ESPRESSO_JAVA_HOMES` and optionally `EXTRA_ESPRESSO_LLVM_JAVA_HOMES`.
95+
Those are lists of java homes separated by a path separator.
96+
If `EXTRA_ESPRESSO_LLVM_JAVA_HOMES` is specified it should contain the same number of entries and in the same order as `EXTRA_ESPRESSO_JAVA_HOMES`.
97+
The JDKs set in `ESPRESSO_JAVA_HOME` and `EXTRA_ESPRESSO_JAVA_HOMES` should all have different versions.
98+
99+
For example to produce jdk21 and jk25 resource in addition to the version of `ESPRESSO_JAVA_HOME`:
100+
```bash
101+
$ export ESPRESSO_JAVA_HOME=/path/to/jdk26
102+
$ export ESPRESSO_LLVM_JAVA_HOME=/path/to/jdk26-llvm
103+
$ export EXTRA_ESPRESSO_JAVA_HOMES=/path/to/jdk21:/path/to/jdk25
104+
$ export EXTRA_ESPRESSO_LLVM_JAVA_HOMES=/path/to/jdk21-llvm:/path/to/jdk25-llvm
105+
# subsequent build and maven-deploy operation will now publish
106+
# * org.graalvm.espresso:espresso-runtime-resources-jdk21
107+
# * org.graalvm.espresso:espresso-runtime-resources-jdk25
108+
# * org.graalvm.espresso:espresso-runtime-resources-jdk26
109+
```
110+
111+
The `org.graalvm.espresso:java` maven dependency automatically depends on the "main" runtime resource (the one from `ESPRESSO_JAVA_HOME`).
112+
In order to use a different version in an embedding, an explicit dependency to `org.graalvm.espresso:espresso-runtime-resources-$RuntimeResourceId` should be added.
113+
The context should also be created with `java.RuntimeResourceId` set to the desired version (e.g., `"jdk21"`).
114+
87115
## `mx espresso-embedded ...`
88116

89117
To run Espresso on a vanilla JDK and/or not within a standalone use `mx espresso-embedded ...`, it mimics the `java` command. The launcher adds all jars and properties required to run Espresso on any vanilla JDK.

0 commit comments

Comments
 (0)