#14527·graal

GraalVM CE built from source produces broken native-image binaries when using future defaults

Author: avermsCreated Sep 25, 2026Updated Oct 1, 2026
Labelsbugnative-image

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

  1. Build LabsJDK jvmci-25.4-b23 as in the building README: bash configure then make graal-builder-image.

  2. cd graal/vm && mx --env ce --java-home=<graal-builder-jdk> build, then GRAALVM_HOME=$(mx --env ce graalvm-home).

  3. Build and run a program that uses java.net:

    java
    void main() throws Exception {
        IO.println(java.net.InetAddress.getByName("localhost"));
    }
    bash
    $GRAALVM_HOME/bin/javac NetTest.java
    $GRAALVM_HOME/bin/native-image NetTest && ./NetTest
    # localhost/127.0.0.1
    bash
    $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 (commit 95ce1499c8c), base JDK LabsJDK jvmci-25.4-b23 (labsjdk-ce-25.0.4.1.1+1), mx 7.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 run make graal-builder-image. In labs-openjdk, make/GraalBuilderImage.gmk copies the static libraries flat into graal-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 under lib/static/darwin-aarch64/lib*.a (and lib/static/linux-<arch>/<libc>/ on Linux).
  • substratevm/mx.substratevm/mx_substratevm.py handles both. In mx_register_dynamic_suite_constituents (line 3550 at graal-25.4.4.1.1), the SVM_STATIC_LIBRARIES_SUPPORT layout includes dependency:svm-static-library-symbols/* only when <base_jdk>/lib/static exists; for a flat lib/ it copies the bare .a files. The fallback at line 3199 is commented # Allow older labsjdk versions to work.
  • So the from-source GraalVM has lib/static/darwin-aarch64/lib*.a but no lib*.a.symbols manifests, while the official build has 42 of each on darwin-aarch64.

With ClassForNameRespectsClassLoader, JNILibraryLoadFeature builds the image's table of builtin native libraries from those manifests (collectBuiltinSymbolsForRuntimeLookup -> NativeLibraries.getStaticLibrarySymbols, which returns an empty list when the .symbols file is missing). With no manifests the table has no JNI_OnLoad_net entry, so at run time System.loadLibrary("net") does not recognise libnet as linked into the image and tries to dlopen it. libnet.a itself is linked in either way.

Of the individual future defaults, only class-for-name-respects-class-loader triggers the failure; the other six pass.

Faster check of the mx half, no JDK build needed: point mx at a LabsJDK release tarball and run mx build --only svm-static-library-symbols,SVM_STATIC_LIBRARIES_SUPPORT in substratevm. The resulting svm-static-libraries-support.tar contains 42 .a and 42 .a.symbols. Move lib/static/darwin-aarch64/*.a to lib/ in a copy of that JDK and rerun: 42 .a, no .symbols.

Confirmed fix on the packaging side: placing the same .a files under lib/static/darwin-aarch64/ (with .symbols generated as mx does) makes the class-for-name-respects-class-loader image run.

Two ways to close the gap:

  1. labs-openjdk: make graal-builder-image (or static-libs-graal-image) emit lib/static/<os>-<arch>[/<libc>]/ like the release tarballs, instead of flat lib/. Then every base JDK has one layout, and the flat-lib/ fallback in mx_substratevm.py can eventually go.
  2. mx_substratevm.py: generate the .symbols manifests for the flat-lib/ layout as well, rather than only for lib/static.