throw new IOException((new StringBuilder()).
append("This virtual machine \"").
append(lvm.getVmid()).append("\" does not support dynamic attach.").toString());
VirtualMachine virtualmachine = null;
String s = String.valueOf(lvm.getVmid());
try {
virtualmachine = VirtualMachine.attach(s);
}
catch (AttachNotSupportedException attachnotsupportedexception) {
IOException ioexception = new IOException(attachnotsupportedexception.getMessage());
ioexception.initCause(attachnotsupportedexception);
throw ioexception;
}
String s1 = virtualmachine.getSystemProperties().getProperty("java.home");
String s2 = (new StringBuilder()).append(s1).append(File.separator).append("jre").append(File.separator).append("lib").append(File.separator).append("management-agent.jar").toString();
File file = new File(s2);
if (!file.exists()) {
s2 = (new StringBuilder()).append(s1).append(File.separator).append("lib").append(File.separator).append("management-agent.jar").toString();
file = new File(s2);
if (!file.exists())
throw new IOException("Management agent not found");
}
s2 = file.getCanonicalPath();
try {
virtualmachine.loadAgent(s2, "com.sun.management.jmxremote");
}
catch (AgentLoadException agentloadexception) {
IOException ioexception1 = new IOException(agentloadexception.getMessage());
ioexception1.initCause(agentloadexception);
throw ioexception1;
}
catch (AgentInitializationException agentinitializationexception) {
IOException ioexception2 = new IOException(agentinitializationexception.getMessage());
ioexception2.initCause(agentinitializationexception);
throw ioexception2;
}
Properties properties = virtualmachine.getAgentProperties();
lvm.setConnectorAddress((String) properties.get("com.sun.management.jmxremote.localConnectorAddress"));
virtualmachine.detach();
}