Skip to content

Conversation

Akirathan
Copy link
Contributor

In enso, we are building NI from a small JDK created by jlink. On latest GraalVM CE 25.0.0, it is no longer possible to build NI from small JDK without java.prefs module on MacOS.

Minimal reproducer

Makefile:

NI_BUILDER_MODULES = "org.graalvm.nativeimage.builder,org.graalvm.nativeimage.driver,org.graalvm.nativeimage.librarysupport,org.graalvm.nativeimage.objectfile,org.graalvm.nativeimage.pointsto"
NI_BASE_MODULES = "org.graalvm.nativeimage,org.graalvm.nativeimage.base,com.oracle.graal.graal_enterprise,com.oracle.svm.svm_enterprise"
JDK_MODULES = "java.naming,java.net.http,java.rmi,jdk.attach,jdk.charsets,jdk.crypto.ec,jdk.httpserver,jdk.localedata,jdk.jdwp.agent,jdk.security.auth"
ADD_MODULES = "$(NI_BUILDER_MODULES),$(NI_BASE_MODULES),$(JDK_MODULES)"

MODULE_JARS = "$$JAVA_HOME/lib/svm/bin/../../graalvm/svm-driver.jar:$$JAVA_HOME/lib/svm/bin/../builder/native-image-base.jar:$$JAVA_HOME/lib/svm/bin/../builder/espresso-svm.jar:$$JAVA_HOME/lib/svm/bin/../builder/objectfile.jar:$$JAVA_HOME/lib/svm/bin/../builder/pointsto.jar:$$JAVA_HOME/lib/svm/bin/../builder/svm-enterprise.jar:$$JAVA_HOME/lib/svm/bin/../builder/svm.jar:$$JAVA_HOME/lib/svm/bin/../builder/svm-configure.jar:$$JAVA_HOME/lib/svm/bin/../builder/svm-capnproto-runtime.jar:$$JAVA_HOME/lib/svm/bin/../builder/svm-foreign.jar:$$JAVA_HOME/lib/svm/bin/../library-support.jar"

NI_EXE = small_jdk/lib/svm/bin/native-image

all: clean native_image

small_jdk:
	jlink --output small_jdk --module-path "$(MODULE_JARS)" --add-modules "$(ADD_MODULES)"
	cp -r $$JAVA_HOME/lib/graalvm $$JAVA_HOME/lib/svm $$JAVA_HOME/lib/static $$JAVA_HOME/lib/truffle small_jdk/lib

Main.class: Main.java
	javac Main.java

native_image: Main.class small_jdk
	$(NI_EXE) Main -o main

clean:
	rm -rf small_jdk
	rm -f Main.class
	rm -f main

Main.java:

public class Main {
    public static void main(String[] args) {
        System.out.println("Hello from Main");
    }
}

Running make on GraalVM CE 25.0.0, the following error is reported:

========================================================================================================================
GraalVM Native Image: Generating 'main' (executable)...
========================================================================================================================
[1/8] Initializing...
                                                                                    (0.0s @ 0.08GB)
Error: Substitution target for com.oracle.svm.core.posix.darwin.Target_java_util_prefs_FileSystemPreferences is not loaded. Use field `onlyWith` in the `TargetClass` annotation to make substitution only active when needed.

Running make on GraalVM CE 24.0.1 is OK.

Note that @JaroslavTulach was not possible to reproduce this error on Linux AMD64. Seems to affect only Mac (I have aarch64, but it probably also affects x64).

Context

Copy link

Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
The following contributors of this PR have not signed the OCA:

To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application.

When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated.

If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. label Sep 26, 2025
@Akirathan
Copy link
Contributor Author

Akirathan commented Sep 26, 2025

Because of this issue, we had to add java.prefs module to small JDK used for NI builds as a workaround. See enso-org/enso#14019 (comment). I have confirmed that with this PR applied, java.prefs can be removed from the small JDK.

@JaroslavTulach
Copy link
Contributor

JaroslavTulach commented Sep 26, 2025

  • Pavel is making this contribution on behalf of Enso
  • the same company on behalf of I am making my contributions
  • looking at my mailbox I see Enso signed the company agreement in ~2022
  • such a company wide OCA agreement shall cover all Enso employees
  • as such this contribution by Pavel shall be OCA covered as well

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Required At least one contributor does not have an approved Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants