Description
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"
asgetConstructors()
will return a subset ofgetDeclaredConstructors()
. 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"
asgetFields()
does not return a subset ofgetDeclaredFields()
, asgetFields()
includes inherited fields butgetDeclaredFields()
does not. - same applies to methods, "allDeclaredMethods" does not infer "allPublicMethods" as getMethods() does not return a subset of
getDeclaredMethods()
, asgetMethods()
includes inherited methods butgetDeclaredMethods()
does not.
Because of this behavior difference for inherited fields and methods, our reflection hints predicates must be aligned with the expected behavior.