-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Remove some limitations of GraalVM Native Image #2762
Comments
Hello @christianwimmer, regarding this part:
I am not an expert in native-image semantics, but I was under the impression that within an application running as a native image, there is always just one single classloader at runtime. Is that not the case? |
No, that is not correct. Different However, right now each of these class loaders sees every class and every resource at run time, i.e., if you call |
@christianwimmer, thank you very much for explaining those details. |
This PR removes the |
Hello, please don't enable Also, regarding "since in practice every large project needs to specify this option" : that's not true. All Quarkus applications are built without this option, as we explicitly prohibit using it. |
@Sanne I'm glad to hear that Quarkus does not need From a "works out-of-the-box" point of view, it is bad though because many libraries have "dangling" dependencies that are just ignored on HotSpot but causes native image build errors. So the my current thinking is to make |
@christianwimmer that makes sense, thank you! If we can simply revert to the current semantics I see no problem; we already do the same for e.g. not discovering all Services by default (only the ones explicitly chosen) and defaulting to build-time-initialization for most classes (with explicit exceptions). We really like the better optimisations that GraalVM can do in such configuration. |
Citing @christianwimmer from #3491 (comment) :
Having a per lib/package control is a good thing, thanks a lot for it! I hope the implementation will bring library maintainers a way to define settings suitable for them while at the same they won't pollute all dependent projects who may prefer something different. However, making Apache Camel is an integration toolkit that contains 300+ connectors for exchanging data between various heterogeneous systems. Those connectors are typically based on third party libs and frameworks. Camel Quarkus aims at porting all those 300+ connectors to Quarkus, where, as @Sanne pointed out above, there is a strong preference for doing things at build time, because it makes the end user applications more robust and also faster at runtime. In Camel Quarkus will try our luck and enforce complete class for every single lib we depend on. It may work for some, while it will fail for others. Often the issues are easy to fix in third party libs and if we see a solution, we gladly report it and/or propose a fix. Now you may ask what is wrong with all that? Well, I think if the most of the ecosystem will test with If enforcing complete class path would stay the default, I think the load of finding and fixing issues would be spread more evenly across the ecosystem. Library maintainers would have higher chances to find issues early themselves when testing in native mode. Similarly for library consumers: if there is more of them testing with complete class path enforced, then there are higher chances that the issues will be found and fixed early. In situations, where the incomplete class path is really necessary, because the library maintainer wants it like that, or because there is no other way, the announced per lib/package switch is highly welcome. But still, with complete class path enforced by default, there would be less chances that it gets overused. |
PR with a proposed solution to replace |
#4753 Add support for including lambda classes to reflection configuration |
All items listed in this issue are finished by now. |
@christianwimmer did this partially solve #1108? It seems that the remaining concern there was about listing resources starting from the root. |
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
java
launcher, andOnly 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.
The text was updated successfully, but these errors were encountered: