Skip to content
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

Java agents aren't (really) supported #528

Open
pron opened this issue Oct 23, 2014 · 2 comments
Open

Java agents aren't (really) supported #528

pron opened this issue Oct 23, 2014 · 2 comments

Comments

@pron
Copy link

pron commented Oct 23, 2014

The -javaagent flag is passed to the JVM in java.cc, but the classpath is handled by RunJava. This is not how Java agents work!

The spec says this:

The agent class will be loaded by the system class loader (see ClassLoader.getSystemClassLoader).

I.e., the Java agent must see the classpath! It actually means more than that. The agent and the application share a class loader so they have access to the same static fields etc.

This results in a failure whenever a Java agent tries to access a class that is contained on the classpath, but not in the agent JAR.

A related problem is that the spec says:

The agent JAR is appended to the system class path.

But this isn't implemented.

@pron
Copy link
Author

pron commented Oct 23, 2014

Actually, what happens is that the master context is used by the agent, and not the application's context, which is created by RunJava, which is launched after the agent.

This points the way to a possible fix: set up the isolated context in a java agent that is always passed first to the JVM.

@circlespainter
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants