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

RuntimeHintsAgent should not require full reflection on types #29091

Closed
bclozel opened this issue Sep 6, 2022 · 0 comments
Closed

RuntimeHintsAgent should not require full reflection on types #29091

bclozel opened this issue Sep 6, 2022 · 0 comments
Assignees
Labels
theme: aot An issue related to Ahead-of-time processing type: bug A general bug
Milestone

Comments

@bclozel
Copy link
Member

bclozel commented Sep 6, 2022

Currently, the RuntimeHintsAgent is too strict and does not fully replicate the behavior of a GraalVM native application when it comes to reflection.

Assuming the following registered reflection hint:

{
  "name" : "scratch.QueriedClass",
  "methods" : [
    { "name" : "firstMethod" },
  ]
}

for the following class

package scratch:

class QueriedClass {

  void firstMethod() { }

  void secondMethod() { }
}

A GraalVM native application will behave like this:

Method firstMethod = QueriedClass.class.getMethod("firstMethod");

// this will throw a NoSuchMethodException since no metadata was registered
Method secondMethod = QueriedClass.class.getMethod("secondMethod");

// this will return an array with a single method, "firstMethod"
Method[] methods = QueriedClass.class.getMethods();

Currently the Java agent and its testing infrastructure will require full method introspection on the type when Class.getMethods() is called. We should instead do the following:

  • do not require full method reflection on the type when this is called
  • align other parts of the instrumentation with this principle (fields...)
  • ensure that key methods on those elements acquired through reflection are instrumented to ensure that they're not used without reflection later in the process. This means that Method.invoke() and other key methods should be instrumented.
@bclozel bclozel added type: bug A general bug theme: aot An issue related to Ahead-of-time processing labels Sep 6, 2022
@bclozel bclozel added this to the 6.0.0-M6 milestone Sep 6, 2022
@bclozel bclozel self-assigned this Sep 6, 2022
@bclozel bclozel closed this as completed in 323d190 Sep 6, 2022
snicoll added a commit that referenced this issue Sep 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme: aot An issue related to Ahead-of-time processing type: bug A general bug
Projects
None yet
Development

No branches or pull requests

1 participant