-
Notifications
You must be signed in to change notification settings - Fork 38.3k
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
Refine runtime hint conditions #28126
Comments
After various discussion with GraalVM team and @bclozel, I think we need to make the
Since annotation are currently not supported yet as relevant trigger (see related GraalVM issue), we should implement a check to verify annotations are not used as |
You can't reliably do that I am afraid. |
That's not a hard requirement, we can at least document it and do the check when we have the class. We could also maybe perform this check via ASM-based utility methods (I think we already have that implemented) when generating the config files since this will happen AOT. |
@snicoll About your remark on What I would like to do in Framework 6 is removing this special processing for "Spring things" which is not clearly defined and can't be check in a reliable way, and always translate to regular Since that's sadly not properly documented yet on GraalVM side, see examples of such files from the
|
We might be able to use |
This commit introduces a mandatory RuntimeHintCondition in ReflectionHints in order to leverage GraalVM conditional configuration capabilities and keep track of the reason why a hint exists. See spring-projectsgh-28126
@snicoll Could you please have a look to this draft branch where:
If you test it with sample native application, notice GraalVM 22.1-dev is required since GraalVM 22.0 is broken for some kind of conditional configuration. |
I had a look to the two commits and added some comments. I don't think making the reachable type mandatory in the API is warranted when the commit does this at the same time. If we can't figure out a better reachable type in I also think that making it mandatory in the method that creates the builder makes the API more fat. I'd welcome a different arrangement. Perhaps a validation that a condition is set when building the object? Still, I think it makes the API harder to use than it should and I am wondering if this is warranted. |
If I understand correctly, the GraalVM agent will use as reachableType whatever type is right above in the call stack when performing a reflection/resource/etc call. That's a nice heuristic for many libraries, but I suspect that this approach won't be super efficient in Spring Framework. In many cases, the call stack with start with a
I agree with the comment above. On top of that, I believe some hints might not even have a valid reachableType. In the case of field injection, we would have to point to a class that's always reachable by the core context - or worse, point to an AOT-generated class. In both cases, this doesn't really help. To summarize, I'd like to add this option to the API but not make it mandatory. |
Ok thanks for your feedback, I think I will just make a new try with reachable types added to other hints than reflection one and let it optional. |
To summarize our findings so far:
With this change, we can consider #28163 with a more general approach. |
GraalVM conditional configuration is only documented for reflection but it also applies to serialization, proxy and resources configurations. Since this mechanism allows to leverage GraalVM static analysis to reduce the memory footprint and image size, and for consistency, it would make sense to not only expose this capability in
ReflectionHints
, but also inJavaSerializationHints
,ProxyHints
andResourceHints
.The text was updated successfully, but these errors were encountered: