-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
GraalVM Native Image has a few limitations that are preventing users from building native images from their code bases. This issue describe the areas where improvements are planned over the next releases. Actual work is done under separate issues, linked from this issue so that everyone who wants to work on it gets an overview of who is working on what.
Support for the module system
The native image generator does not support a module path argument yet on JDK 11. The plan is to
- support all module path arguments in the same way as the the
java
launcher, and - allow introspection of module information at run time using the respective JDK reflection APIs.
Only information about modules where at least one class is reachable will be available at run time.
Work to support the module path arguments is currently in progress: #1962
Support for method handles and the invokedynamic bytecode
Currently only method handles that are a compile time constant are supported. This is an important subset because it allows, for example, all Java lambdas and the invokedynamic-based string concatenation. Still, we want to support method handles also when they are not a compile time constant, i.e., when method handle chains are constructed and changed at run time.
The approach will be similar to reflection: methods that are available via a method handle must be registered in a configuration file at image build time.
Note that the performance of such method handles will be slower compared to the Java HotSpot VM because no dynamic compilation of method handle chains is possible.
Work is currently in progress: #2761
(Done) Support for Java serialization
Java serialization is a special form or reflection: during deserialization, classes are instantiated and fields are set in a reflective way without explicit bytecode. So the implementation approach will be similar to reflection: classes that are available for serialization must be registered in a configuration file at image build time.
(Update: support for serialization is finished and available starting with GraalVM 21.0)
Improve support for resource bundles and locales
Currently, the locale is fixed at image build time, i.e., registered resource bundles are only included for a single locale. This single locale is of course also the default locale at runtime. This will be made more flexible, so that arbitrary locales can be included and the default locale is set correctly at run time.
Work is currently in progress: #2982
Improve support for resource registration
All resources that should be available at run time need to be listed at image build time. Currently, all listed resources are included in a non-structured form, i.e., it is not possible to navigate resources like a file system. Also resources are not separated by class loader, i.e., every class loader sees all resources.
The image heap must include a virtual file system for the included resources that allows navigation.
Allow incomplete class path and all security services by default
Currently, support for an incomplete class path must be enabled by manually via --allow-incomplete-classpath
. This ensures that no linking errors are thrown at run time. But since in practice every large project needs to specify this option, we will flip the default and enable the support by default.
Similarly, support for all security services must be enabled manually via --enable-all-security-services
. We will flip the default and enable support by default. (Update: this part is finished, the option --enable-all-security-services
is deprecated and a no-op starting with GraalVM 21.1)
Allow multiple classes with the same name
Different class loaders can load multiple classes with the same name. This is currently not supported on native image. However, this is only a historic restriction that can be changed.