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

Classpath-based filtering of the native configuration generation #28163

Closed
sdeleuze opened this issue Mar 11, 2022 · 3 comments
Closed

Classpath-based filtering of the native configuration generation #28163

sdeleuze opened this issue Mar 11, 2022 · 3 comments
Labels
status: declined A suggestion or change that we don't feel we should currently apply theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement

Comments

@sdeleuze
Copy link
Contributor

As a follow-up of #27991 and #28160, a filtering on the generated configuration should be done based on classpath checks using reachableType for all hints + reflection/proxy/serializable types. This will allow to reduce the amount of configuration generated.

@sdeleuze sdeleuze added type: enhancement A general enhancement theme: aot An issue related to Ahead-of-time processing labels Mar 11, 2022
@sdeleuze sdeleuze added this to the 6.0.0-M4 milestone Mar 11, 2022
@sdeleuze sdeleuze self-assigned this Mar 11, 2022
@bclozel bclozel modified the milestones: 6.0.0-M4, 6.0.0-M5 May 9, 2022
@bclozel
Copy link
Member

bclozel commented Jun 2, 2022

We've introduced the ConditionalHint contract in #28126 that we could leverage here.
I'm wondering how generally applicable it is. Isn't it possible to add a typeReachable condition that's based on a class that's not present in the runtime classpath at build time but might be present at runtime? I'm thinking about java classes generated during the AOT phase. Or should we document that limitation and avoid using AOT classes as conditions in hints?

@snicoll
Copy link
Member

snicoll commented Jun 2, 2022

I am not convinced of the impact of this to be honest. We're already invoking RuntimeHintsRegistrar conditionally and the rest of the API is based on browsing the BeanFactory and registered beans with a closed-world assumption. The above is a far more superior filtering strategy than looking at the reachable type.

However, hints that are registered statically (in aot.factories) could contribute things and provide a reachable type. If they do using a class, invoking them will fail in the type is not present. Remains the case where they're using a TypeReference. From that perspective, I don't think we should care too much about AOT generated classes in conditions as statically registered factories don't really have access to that.

@bclozel bclozel modified the milestones: 6.0.0-M5, 6.0.0-M6 Jun 7, 2022
@bclozel
Copy link
Member

bclozel commented Jul 27, 2022

Now that we've evolved the AOT processing phase, it seems that we're contributing RuntimeHints in a dynamic fashion that already takes the classpath into account.

The typeReachable information should instead be used by contributions to signal that while the required dependency is on the classpath, we don't know if the hint will be useful since it depends on some type being reachable during the GraalVM static analysis. This can be especially useful for hints linked to clients (HTTP, RSocket, etc) since we don't necessarily know if they'll be used at runtime without knowing the actual method bodies.

For now, we don't have a use case for filtering hints based on their typeReachable information during the AOT phase. I'm closing this issue for now, we can revisit this decision if such a use case is found.

@bclozel bclozel closed this as not planned Won't fix, can't repro, duplicate, stale Jul 27, 2022
@bclozel bclozel added the status: declined A suggestion or change that we don't feel we should currently apply label Jul 27, 2022
@bclozel bclozel removed this from the 6.0.0-M6 milestone Jul 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: declined A suggestion or change that we don't feel we should currently apply theme: aot An issue related to Ahead-of-time processing type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

3 participants