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

Module support for native-image building #1962

Closed
olpaw opened this issue Dec 10, 2019 · 7 comments
Closed

Module support for native-image building #1962

olpaw opened this issue Dec 10, 2019 · 7 comments

Comments

@olpaw
Copy link
Member

olpaw commented Dec 10, 2019

The native-image source base needs to be modularized similar to what already happened for other parts of our GraalVM stack. This will help to get rid of all the --add-exports that we currently need when we run the image builder on Java 11+.

Additionally we need support for specifying the application that we want to build an image from on the module path. I.e. we need to support native-image --module-path. Specifically we need

  • -p <module path>
  • --module-path <module path>...
  • -m or --module <module>
  • --add-opens & --add-exports

Adding support for 'native-image ' would also be nice to have.

@olpaw
Copy link
Member Author

olpaw commented Dec 11, 2019

Being able to build Java 11 javac to a native-image is a good test-case for this issue.

@olpaw
Copy link
Member Author

olpaw commented Apr 21, 2020

#2372 addresses the modularization of the image builder itself.

@joerg-wille
Copy link

In version 19.3 of GraalVM Native Image Java 11 support was added but without support for the Java Platform Module System (JPMS) and also no module introspection at image run time.

  • Is this issue the correct one to track native-image JPMS support and especially module introspection at run time?
  • Has anything changed on this topic in later releases of native-image?
  • Is there work in progress on this topic or any estimation for full module introspection in native-image?

Thanks

@olpaw
Copy link
Member Author

olpaw commented Jun 15, 2021

Hello @joerg-wille

adding module support to native-image is actively being worked on. This will allow to build images on the module path (e.g. native-image --module-path=module-foo.jar:module-bar.jar -m mymods.foo/qualified.name.MainClassInFoo and use --add-exports and --add-opens. Additionally we are working on making sure the moduleinfo seen at image runtime makes sense. E.g. if someone calls MainClassInFoo.class.getModule().getName(), "mymods.foo" would be returned as expected.

Currently the changes that enable this are only available when building GraalVM with a special environment variable USE_NATIVE_IMAGE_JAVA_PLATFORM_MODULE_SYSTEM=true. We also have some testing that gives an idea what already works (can be run with mx hellomodule from graal/substratevm).

While this will not be part of 21.2 we are working on getting this released as soon as possible.

@alina-yur
Copy link
Member

@olpaw I guess we have an update here, right?:)

@olpaw
Copy link
Member Author

olpaw commented Oct 21, 2021

@olpaw I guess we have an update here, right?:)

Correct.

While the feature is still experimental, as of GraalVM 21.3, images can be built from Java modules. I.e. now native-image also understands --module-path (-p), --module (-m), --add-exports and --add-opens.
We added a simple example for users to try out:
https://github.com/graalvm/graalvm-demos/tree/master/native-hello-module

As said, this is still experimental and we a look forward for feedback from early adopters.
Our main-branch is already a few steps further:

@olpaw
Copy link
Member Author

olpaw commented Oct 21, 2021

The follow up PR for future improvements is #3935

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