[GR-44282] BeforeAnalysisAccess#registerMethodOverrideReachabilityHandler not getting invoked as expected in GraalVM 22.2 #5194
Description
Describe the issue
Upgrading from GraalVM 22.1 to GraalVM 22.2 is resulting in changed behavior in reachability handlers.
Steps to reproduce the issue
Reproducer: https://github.com/mpeddada1/graalvm22.2-reachability
As seen in the reproducer, the method, BeforeAnalysisAccess.registerMethodOverrideReachabilityHandler()
in a custom Feature
implementation , doesn't get invoked.when using graalvm 22.2. This leads to classes not being registered for reflection and results in runtime errors like this:
Failures (1):
JUnit Vintage:MySampleTest:testSample
MethodSource [className = 'com.example.MySampleTest', methodName = 'testSample', methodParameterTypes = '']
=> java.lang.RuntimeException: Generated message class "com.example.MySampleClass" missing method "getName".
com.anotherpackage.GeneratedMessage.retrieveMethod(GeneratedMessage.java:31)
com.anotherpackage.GeneratedMessage.access$000(GeneratedMessage.java:5)
com.anotherpackage.GeneratedMessage$MethodAccessor.<init>(GeneratedMessage.java:20)
com.anotherpackage.GeneratedMessage$A.initializeMethodAccessor(GeneratedMessage.java:11)
com.example.MySampleClass.invokeAccessor(MySampleClass.java:13)
[...]
Caused by: java.lang.NoSuchMethodException: com.example.MySampleClass.getName()
java.lang.Class.getMethod(DynamicHub.java:2108)
com.anotherpackage.GeneratedMessage.retrieveMethod(GeneratedMessage.java:28)
[...]
However, that same method is invoked when using graal-sdk 22.1.0 and runs successfully.
Describe GraalVM and your environment:
- GraalVM version (latest snapshot builds can be found here), or commit id if built from source: 22.2.0
- JDK major version: 11
- OS: Linux
More details
Concurrent reachability handlers were enabled by default starting with 22.2.0 so I wonder if we're hitting some sort of a race condition?
Workaround: Adding the -H:-RunReachabilityHandlersConcurrently
parameter results in a successful build.