Skip to content

Fix RuntimeHintsPredicates matching rules for public/declared elements #31224

Closed
@bclozel

Description

@bclozel

While reviewing missing reachability hints for #31213, I have discussed the reflect-config.json schema and the meaning of its attributes with the GraalVM team. For this issue, we must ensure that our testing infrastructure (hints predicates and the java agent) truly align with the runtime behavior of GraalVM and how is it going to be enforced in the near future.

It turns out that a couple of our assumptions were wrong.

In general, we assume that registering an invocation hint for a field, method or constructor covers also the introspection case. This means that registering "allDeclaredMethods" (invoking all declared methods) infers "queryAllDeclaredMethods" (introspecting all declared methods) and there is no need to register the latter. This part is well aligned with the runtime reflection behavior.

On the other hand, so far we assumed that registering a "declared" hint also covered the "public" variant: for example, our current implementation assumes that registering "allDeclaredMethods" infers "allPublicMethods". This behavior is not consistent for fields, methods and constructors:

  • for constructors "allDeclaredConstructors" infers "allPublicConstructors" as getConstructors() will return a subset of getDeclaredConstructors(). This behavior is not yet fully reflected in the current GraalVM dev build (wrt logged warnings) but should be soon
  • for fields "allDeclaredFields" does not infer "allPublicFields" as getFields() does not return a subset of getDeclaredFields(), as getFields() includes inherited fields but getDeclaredFields() does not.
  • same applies to methods, "allDeclaredMethods" does not infer "allPublicMethods" as getMethods() does not return a subset of getDeclaredMethods(), as getMethods() includes inherited methods but getDeclaredMethods() does not.

Because of this behavior difference for inherited fields and methods, our reflection hints predicates must be aligned with the expected behavior.

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)theme: aotAn issue related to Ahead-of-time processingtype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions