Support using the Java tracer with both -javaagent and -jar at the same time #4924
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What Does This Do
Cleans up how we load classes via the CLI to avoid checking the code source location unless we really need it.
For example, if the agent classloader is already installed then we don't need the tracer's code source location.
Motivation
This avoids a potential exception when
dd-java-agent
is used with both-javaagent
and-jar
at the same time.(The original exception occurred because the code source location of
AgentJar
becamenull
after we addeddd-java-agent
to the boot-class-path - determining that we're runningdd-java-agent
with-jar
frompremain
turns out to be non-trivial, it was easier to adjust the code sodd-java-agent
can work in both places.)