-
Hello, At the moment, Having to register all the potential resources seems too tedious. I wonder if an option to exclude specific code-paths, classes, or packages from the cc @vjovanov |
Beta Was this translation helpful? Give feedback.
Replies: 7 comments 13 replies
-
I'm a bit unclear what the request is. From a technical standpoint, native-image must know about a resource at buildtime to be able to package it into the binary for runtime. Otherwise, it's up to the program to read the data from an external source (e.g. file, database). In previous versions of native-image, it was possible to manually specify sets of resources using a regex. I think that went away with the https://www.graalvm.org/latest/reference-manual/native-image/metadata/ also mentions |
Beta Was this translation helpful? Give feedback.
-
@zakkak I am also considering to relax the current setting. I feel we have two major culprits here:
I am not in favor of adding a special flag to make things work (for debugging it is OK), as this moves Native Image away from the Java semantics. My plan is to experiment with these three approaches in the next 2 months and then we can decide what is easiest to support and use. @zakkak what are your thoughts? |
Beta Was this translation helpful? Give feedback.
-
Regarding bloat, I find that the biggest problem here are not the application classes, but the JDK classes. In a simple
Yes it would include all of these types to be available for
We do, exactly, just the default exception for
When you boil it down, this is a workaround for a lack of Maybe we could throw This way libraries would be able to handle this and we don't need extra JSON. In the future if a
|
Beta Was this translation helpful? Give feedback.
-
We could make a flag for this, but I would leave it as experimental for the time the third-party libraries don't adopt the new semantics. |
Beta Was this translation helpful? Give feedback.
-
Have you considered branching the logic of the original code on the We created an enum around the possible values for convenience. |
Beta Was this translation helpful? Give feedback.
-
In general, to make an informed decision it would be good to give examples of how many entries relative to all metadata entries need to be added for the project to work. If the number of entries is relatively small compared to the size of the project (e.g. <1-2% of all entries), I feel the benefits of strict semantics outweigh the cost of maintaining the extra entries (especially because the missing entries are pretty easy to find). |
Beta Was this translation helpful? Give feedback.
-
After a few iterations we have concluded the following:
In the example you provided with resources, if there is a test that passes a system property that leads to reading the resource in many different places, I feel it is OK that this test also provides the metadata for those places. The end users will eventually not need to do it, but the frameworks will have to go this extra step. If really cumbersome, one can always use wildcards in |
Beta Was this translation helpful? Give feedback.
After a few iterations we have concluded the following:
--exact-reachability-metadata
will remain very strict in order to guarantee that all entries are covered by the metadata. This includes resource lookups andClass.forName
on non-existing classes. This flag should be used by the frameworks and libraries to make sure that they have covered all possible entries in the code and that their users don't have to do it.Most of the functionality
--exact-reachability-metadata
currently covers will be promoted to the default behavior (e.g., throwing aMissingReflectionRegistrationError
when callingClass.getDeclaredMethods()
on an unregistered class). With this, the end user will not care a…