-
Notifications
You must be signed in to change notification settings - Fork 325
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
Override IndyBootstrapDispatcher class module #1468
Override IndyBootstrapDispatcher class module #1468
Conversation
apm-agent-core/src/main/java/co/elastic/apm/agent/bci/IndyBootstrap.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, only a few minor comments/questions.
apm-agent-core/src/test/java/co/elastic/apm/agent/bci/IndyBootstrapTest.java
Outdated
Show resolved
Hide resolved
byte[] bootstrapClass = IOUtils.readToBytes(classFileAsStream); | ||
ClassInjector.UsingUnsafe.ofBootLoader().injectRaw(Collections.singletonMap(IndyBootstrapDispatcherModuleSetter.class.getName(), bootstrapClass)); | ||
|
||
IndyBootstrap.setJavaBaseModule(IndyBootstrapTest.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[question] Would it be possible to have an exception thrown with an explicit message when this method is called and IndyBootstrapDispatcherModuleSetter
hasn't been loaded from the right classloader ? If yes, that might help to diagnose any unexpected state in the field.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can't happen - the setJavaBaseModule
method tries to load it from the bootstrap CL explicitly, so failing to inject it there will result with ClassNotFoundException
(which I think is explanatory enough).
As you can see here, I do load it with the test's class loader, but its single method is never invoked on any class that is not loaded correctly.
What does this PR do?
Closes #1415
Supersedes #1465
Checklist
I have added tests that would fail without this fix- we currently only have integration tests for J9 with Java 8adoptopenjdk/openjdk11-openj9:jdk-11.0.1.13-alpine-slim
docker image with Spring PetClinicadoptopenjdk/openjdk9-openj9:jdk-9.0.4.12_openj9-0.9.0-alpine
docker image with Spring PetClinic