Skip to content

IllegalAccessException while instrumenting invocation of non-public method with RuntimeHintsAgent #29046

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

Closed
bclozel opened this issue Aug 31, 2022 · 1 comment
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 Aug 31, 2022

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"
@bclozel bclozel added type: bug A general bug theme: aot An issue related to Ahead-of-time processing labels Aug 31, 2022
@bclozel bclozel added this to the 6.0.0-M6 milestone Aug 31, 2022
@bclozel bclozel self-assigned this Aug 31, 2022
@bclozel
Copy link
Member Author

bclozel commented Sep 1, 2022

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

@bclozel bclozel reopened this Sep 1, 2022
@bclozel bclozel closed this as completed in 289d378 Sep 1, 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