GraalVM CE built from source produces broken native-image binaries when using future defaults
Describe the issue
A GraalVM CE built from source by following vm/README.md produces native-image
binaries that fail at startup with java.lang.UnsatisfiedLinkError when built with
--future-defaults=class-for-name-respects-class-loader.
The native-image shipped in the official binary release works fine.
This was encountered when using Homebrew's graalvm package to try to build a
Java program into a native image. I decided to try --future-defaults=all since it's recommended and
it broke.
Steps to reproduce the issue
Build LabsJDK jvmci-25.4-b23 as in the building README:
bash configurethenmake graal-builder-image.cd graal/vm && mx --env ce --java-home=<graal-builder-jdk> build, thenGRAALVM_HOME=$(mx --env ce graalvm-home).Build and run a program that uses java.net:
void main() throws Exception { IO.println(java.net.InetAddress.getByName("localhost")); }$GRAALVM_HOME/bin/javac NetTest.java $GRAALVM_HOME/bin/native-image NetTest && ./NetTest # localhost/127.0.0.1$GRAALVM_HOME/bin/native-image --future-defaults=class-for-name-respects-class-loader NetTest && ./NetTest # System.loadLibrary failed, java.lang.UnsatisfiedLinkError: no net in system library path: ... # Fatal error: Failed to create the main Isolate. (code 13)
Instead of building your own GraalVM you can also reproduce using Homebrew's
graalvm by doing brew install graalvm instead of steps 1 and 2.
Describe GraalVM and your environment:
- GraalVM version: Homebrew built from source at tag
graal-25.4.4.1.1(commit95ce1499c8c), base JDK LabsJDK jvmci-25.4-b23 (labsjdk-ce-25.0.4.1.1+1),mx7.86.0. Compared against the official CE build of the same version. - JDK major version: 25
- OS: macOS 26.6.2, Apple clang 21.0.0
- Architecture: AArch64
More details
These details are from an agentic root-cause finding loop. Basically, the agent
thinks it's due to the layout of $GRAALVM_HOME/lib being different for
from-source builds vs the official builds.
The difference is the layout of the static JDK libraries in the base JDK:
vm/README.md("Creating a JVMCI-Enabled JDK", step 4) says to runmake graal-builder-image. In labs-openjdk,make/GraalBuilderImage.gmkcopies the static libraries flat intograal-builder-jdk/lib/lib*.a(DEST := $(GRAAL_BUILDER_IMAGE_DIR)/lib).- The released LabsJDK tarballs (for example
labsjdk-ce-25.0.4.1.1+1-jvmci-25.4-b23-darwin-aarch64.tar.gz) instead ship them underlib/static/darwin-aarch64/lib*.a(andlib/static/linux-<arch>/<libc>/on Linux).substratevm/mx.substratevm/mx_substratevm.pyhandles both. Inmx_register_dynamic_suite_constituents(line 3550 atgraal-25.4.4.1.1), theSVM_STATIC_LIBRARIES_SUPPORTlayout includesdependency:svm-static-library-symbols/*only when<base_jdk>/lib/staticexists; for a flatlib/it copies the bare.afiles. The fallback at line 3199 is commented# Allow older labsjdk versions to work.- So the from-source GraalVM has
lib/static/darwin-aarch64/lib*.abut nolib*.a.symbolsmanifests, while the official build has 42 of each on darwin-aarch64.With
ClassForNameRespectsClassLoader,JNILibraryLoadFeaturebuilds the image's table of builtin native libraries from those manifests (collectBuiltinSymbolsForRuntimeLookup->NativeLibraries.getStaticLibrarySymbols, which returns an empty list when the.symbolsfile is missing). With no manifests the table has noJNI_OnLoad_netentry, so at run timeSystem.loadLibrary("net")does not recogniselibnetas linked into the image and tries todlopenit.libnet.aitself is linked in either way.Of the individual future defaults, only
class-for-name-respects-class-loadertriggers the failure; the other six pass.Faster check of the
mxhalf, no JDK build needed: pointmxat a LabsJDK release tarball and runmx build --only svm-static-library-symbols,SVM_STATIC_LIBRARIES_SUPPORTinsubstratevm. The resultingsvm-static-libraries-support.tarcontains 42.aand 42.a.symbols. Movelib/static/darwin-aarch64/*.atolib/in a copy of that JDK and rerun: 42.a, no.symbols.Confirmed fix on the packaging side: placing the same
.afiles underlib/static/darwin-aarch64/(with.symbolsgenerated asmxdoes) makes theclass-for-name-respects-class-loaderimage run.Two ways to close the gap:
labs-openjdk: makegraal-builder-image(orstatic-libs-graal-image) emitlib/static/<os>-<arch>[/<libc>]/like the release tarballs, instead of flatlib/. Then every base JDK has one layout, and the flat-lib/fallback inmx_substratevm.pycan eventually go.mx_substratevm.py: generate the.symbolsmanifests for the flat-lib/layout as well, rather than only forlib/static.
Source: oracle/graal