Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM= false" is broken with JDK 21 #7712

Closed
geofjamg opened this issue Nov 1, 2023 · 10 comments
Closed
Assignees

Comments

@geofjamg
Copy link

geofjamg commented Nov 1, 2023

Hi all,

Even with a very simple project like this one: https://github.com/geofjamg/buggraalvm
When we compile to a shared library using Oracle GraalVM JDK 21 (graalvm-jdk-21.0.1+12.1)

export JAVA_HOME=<DIR>/graalvm-jdk-21.0.1+12.1/Contents/Home 
export USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM=false
<DIR>/graalvm-jdk-21.0.1+12.1/Contents/Home/bin/native-image --class-path target/buggraalvm-1.0-SNAPSHOT.jar --shared -o buggraalvm

We get the error:

Warning: The USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM environment variable is deprecated and might be removed in a future release. Please refer to the GraalVM release notes.
Exception in thread "main" com.oracle.svm.util.ModuleSupport$ModuleSupportError: open of packages from module org.graalvm.polyglot to ALL-UNNAMED failed. No module named org.graalvm.polyglot in boot layer.
	at com.oracle.svm.util.ModuleSupport.accessPackagesToClass(ModuleSupport.java:123)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.setModuleAccesses(NativeImageGeneratorRunner.java:741)
	at com.oracle.svm.hosted.NativeImageGeneratorRunner$JDK9Plus.main(NativeImageGeneratorRunner.java:733)

The same project compiles perfectly with Oracle GraalVM JDK 17.

@TheTaha-Alamine
Copy link
Contributor

Hi @geofjamg could you give us the OS specifications you're working with? Thank you.

@geofjamg
Copy link
Author

geofjamg commented Nov 1, 2023

uname -a
Darwin mbp-de-xxx.home 23.1.0 Darwin Kernel Version 23.1.0: Mon Oct  9 21:27:24 PDT 2023; root:xnu-10002.41.9~6/RELEASE_ARM64_T6000 arm64

@geofjamg
Copy link
Author

geofjamg commented Nov 1, 2023

But I don't think it is an issue specific to the OS. I have same exception on a Linux Ubuntu AMD64.

@selhagani selhagani self-assigned this Nov 1, 2023
@selhagani
Copy link
Member

Hi @geofjamg, there seems to be an issue with the link you provided for the project. It says page not found. Can you double check it please?

@geofjamg
Copy link
Author

geofjamg commented Nov 1, 2023

I switched the repo to public. Is it ok now?

@selhagani
Copy link
Member

@geofjamg Yes it's public now thank you. Our team is working on this.

@selhagani
Copy link
Member

@geofjamg

You no longer need to run this command "export USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM=false" when using graalvm-jdk-21.0.1+12.1. It is deprecated. This should solve the issue you're facing with graalvm-jdk-21.0.1+12.1.

@geofjamg
Copy link
Author

geofjamg commented Nov 2, 2023

Thank you, indeed it works. I only had to add "--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.c=ALL-UNNAMED" to the native image command in my real application (no idea why it is not needed in the simple test case). Otherwise I get the error:

    > java.lang.IllegalAccessError: class com.powsybl.python.commons.Directives (in unnamed module @0x730e5763) cannot access class com.oracle.svm.core.c.ProjectHeaderFile (in module org.graalvm.nativeimage.builder) because module org.graalvm.nativeimage.builder does not export com.oracle.svm.core.c to unnamed module @0x730e5763

This is related to this dependency that is needed to get access to com.oracle.svm.core.c.ProjectHeaderFile for configuring the CContext.Directives:

      <dependency>
          <groupId>org.graalvm.nativeimage</groupId>
          <artifactId>svm</artifactId>
          <version>${graalvm.version}</version>
          <scope>provided</scope>
      </dependency>

Is it something expected? It was not needed with JDK 17.

@geofjamg
Copy link
Author

geofjamg commented Nov 8, 2023

@selhagani if I can suggest some changes:

  • The USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM variable not needed anymore could be specified in release notes / migration guide https://www.graalvm.org/release-notes/JDK_21/ or maybe in the change log.
  • If USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM is not needed anymore, whatever its value or if it sets or not, we should have the same behavior of native image and no failure of the variable is set.

@selhagani
Copy link
Member

Hi @geofjamg thanks for the suggestions! I will share them with our dev team.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants