dynamic attach fails when using intellij dynamic classpath
Brian Harris
brianfromoregon at gmail.com
Thu May 14 19:00:40 UTC 2015
Hi,
jol's (cool!) dynamic agent attach feature seems to fail inside Intellij
when Intellij is told to launch jvm using classpath file. This is done by
setting dynamic.classpath property to true inside workspace.xml. More
detail including link to intellij's JdkUtil class that looks at this
setting:
http://stackoverflow.com/questions/4853540/what-does-the-dynamic-classpath-flag-do-intellij-project-settings
The failure looks like this:
D:\tools\jdk1.8.0_20\bin\java -ea -Didea.launcher.port=7536
"-Didea.launcher.bin.path=D:\tools\IntelliJ IDEA Community Edition
14.1.1\bin" -classpath "D:\tools\IntelliJ IDEA Community Edition
14.1.1\lib\idea_rt.jar;D:\tools\IntelliJ IDEA Community Edition
14.1.1\lib\util.jar" -Dfile.encoding=windows-1252
com.intellij.rt.execution.CommandLineWrapper
C:\Users\Harris\AppData\Local\Temp\classpath0.tmp
com.intellij.rt.execution.application.AppMain
com.intellij.rt.execution.junit.JUnitStarter -ideVersion5
com.brianfromoregon.MainTest,test
java.lang.ClassNotFoundException:
org.openjdk.jol.util.InstrumentationSupport$Installer
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at
sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:304)
at
sun.instrument.InstrumentationImpl.loadClassAndCallAgentmain(InstrumentationImpl.java:411)
Agent failed to start!
Exception in thread "Attach Listener"
Process finished with exit code 0
When I set dynamic.classpath to false, then the error goes away.
D:\tools\jdk1.8.0_20\bin\java -ea -Didea.launcher.port=7537
"-Didea.launcher.bin.path=D:\tools\IntelliJ IDEA Community Edition
14.1.1\bin" -Dfile.encoding=windows-1252 -classpath "D:\tools\IntelliJ IDEA
Community Edition 14.1.1\lib\idea_rt.jar;D:\tools\IntelliJ IDEA Community
Edition
14.1.1\plugins\junit\lib\junit-rt.jar;D:\tools\jdk1.8.0_20\jre\lib\charsets.jar;D:\tools\jdk1.8.0_20\jre\lib\deploy.jar;D:\tools\jdk1.8.0_20\jre\lib\javaws.jar;D:\tools\jdk1.8.0_20\jre\lib\jce.jar;D:\tools\jdk1.8.0_20\jre\lib\jfr.jar;D:\tools\jdk1.8.0_20\jre\lib\jfxswt.jar;D:\tools\jdk1.8.0_20\jre\lib\jsse.jar;D:\tools\jdk1.8.0_20\jre\lib\management-agent.jar;D:\tools\jdk1.8.0_20\jre\lib\plugin.jar;D:\tools\jdk1.8.0_20\jre\lib\resources.jar;D:\tools\jdk1.8.0_20\jre\lib\rt.jar;D:\tools\jdk1.8.0_20\jre\lib\ext\access-bridge-64.jar;D:\tools\jdk1.8.0_20\jre\lib\ext\cldrdata.jar;D:\tools\jdk1.8.0_20\jre\lib\ext\dnsns.jar;D:\tools\jdk1.8.0_20\jre\lib\ext\jaccess.jar;D:\tools\jdk1.8.0_20\jre\lib\ext\jfxrt.jar;D:\tools\jdk1.8.0_20\jre\lib\ext\localedata.jar;D:\tools\jdk1.8.0_20\jre\lib\ext\nashorn.jar;D:\tools\jdk1.8.0_20\jre\lib\ext\sunec.jar;D:\tools\jdk1.8.0_20\jre\lib\ext\sunjce_provider.jar;D:\tools\jdk1.8.0_20\jre\lib\ext\sunmscapi.jar;D:\tools\jdk1.8.0_20\jre\lib\ext\sunpkcs11.jar;D:\tools\jdk1.8.0_20\jre\lib\ext\zipfs.jar;C:\Users\Harris\code\jol-tests\target\test-classes;C:\Users\Harris\code\jol-tests\target\classes;D:\tools\IntelliJ
IDEA Community Edition 14.1.1\lib\junit-4.11.jar;D:\tools\IntelliJ IDEA
Community Edition 14.1.1\lib\hamcrest-core-1.3.jar;D:\tools\IntelliJ IDEA
Community Edition
14.1.1\lib\hamcrest-library-1.3.jar;F:\maven-repo\org\openjdk\jol\jol-core\0.3.1\jol-core-0.3.1.jar"
com.intellij.rt.execution.application.AppMain
com.intellij.rt.execution.junit.JUnitStarter -ideVersion5
com.brianfromoregon.MainTest,test
Process finished with exit code 0
I have tested with Intellij versions 12,13,14. Any ideas what the problem
is? Using debugger I can see that it blows up on this line
inside org.openjdk.jol.util.InstrumentationSupport#tryDynamicAttach
vmClass.getDeclaredMethod("loadAgent", String.class, String.class)
.invoke(vm, agentFile.getAbsolutePath(), "");
However, debugger shows seemingly equivalent values for vmClass and vm and
agentFile in both pass and fail scenarios, so I'm a bit stuck.
More information about the jol-dev
mailing list