Cannot attach to VM via VirtualMachine.attach() API

Hi,

 

In my plugin, I have written a custom ProgramRunner and the user can create a run configuration and start my custom program as a separate JVM. I know the process ID of this newly created JVM and hence I use below code to obtain the connector address of the JVM, so I could connect to it via JMX

private static final String LOCAL_CONNECTOR_ADDRESS = "com.sun.management.jmxremote.localConnectorAddress";

vm = VirtualMachine.attach(String.valueOf(jvmId));

connectorAddress = vm.getAgentProperties().getProperty(LOCAL_CONNECTOR_ADDRESS);
if (connectorAddress == null) {
String agent = vm.getSystemProperties().getProperty("java.home") +
File.separator + "lib" + File.separator + "management-agent.jar";
vm.loadAgent(agent);
connectorAddress = vm.getAgentProperties().getProperty(LOCAL_CONNECTOR_ADDRESS);
}
vm.detach();

But this code does not work in IU-2016.1.2. Basically, the code after

VirtualMachine.attach()

method does not get executed and there is no exceptions either. But it works on IU-15.0. I'm wondering whether this breaks due to the security fix done as mentioned in below blog post.

http://blog.jetbrains.com/blog/2016/05/11/security-update-for-intellij-based-ides-v2016-1-and-older-versions/

Anyone knows what to do about this?

Please sign in to leave a comment.