The RuntimeHintsAgent agent fails at instrumenting the following case:

@EnabledIfRuntimeHintsAgent
class RuntimeHintsAgentTests {

    @Test
    void invokePrivateMethod() {
        Method greet = ReflectionUtils.findMethod(PrivateClass.class, "greet");
        RuntimeHintsInvocations invocations = RuntimeHintsRecorder.record(() -> {
            greet.invoke(new PrivateClass());
        });
    }

    class MyClass {

        private String greet() {
            return "hello";
        }

    }
}

With this code snippet, the agent fails during the method invocation with an exception like:

java.lang.IllegalAccessException: class org.springframework.aot.agent.InstrumentedBridgeMethods cannot access a member of class org.springframework.sample.RuntimeHintsAgentTests$MyClass with modifiers "private"

Comment From: bclozel

Reopening for cases where methods are public but declaring class is not.