Mercurial > hg > release > heapstats-2.1
changeset 230:11f64776a0b6
Bug 3371: Recommend jcmd instead of Attach API
Reviewed-by: yasuenag
https://github.com/HeapStats/heapstats/pull/95
author | KUBOTA Yuji <kubota.yuji@lab.ntt.co.jp> |
---|---|
date | Mon, 08 May 2017 11:08:12 +0900 |
parents | ac5cfda97b59 |
children | 5e09d5bd2a17 |
files | ChangeLog agent/attacher/src/jp/co/ntt/oss/heapstats/attacher/AgentAttacher.java agent/src/heapstats-engines/jvmInfo.cpp |
diffstat | 3 files changed, 25 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Thu Apr 13 11:28:39 2017 +0900 +++ b/ChangeLog Mon May 08 11:08:12 2017 +0900 @@ -1,3 +1,7 @@ +2017-05-08 KUBOTA Yuji <kubota.yuji@lab.ntt.co.jp> + + * Bug 3371: Recommend jcmd instead of Attach API + 2017-04-13 KUBOTA Yuji <kubota.yuji@lab.ntt.co.jp> * Bug 3359: Ignore only auto generated Makefile
--- a/agent/attacher/src/jp/co/ntt/oss/heapstats/attacher/AgentAttacher.java Thu Apr 13 11:28:39 2017 +0900 +++ b/agent/attacher/src/jp/co/ntt/oss/heapstats/attacher/AgentAttacher.java Mon May 08 11:08:12 2017 +0900 @@ -44,11 +44,11 @@ System.out.printf("%d\t%s\n", idx++, vmd.displayName()); } } - + public static void attachProcess(VirtualMachineDescriptor vmd, String agentPath, String options) throws - IOException, AttachNotSupportedException, - AgentLoadException, AgentInitializationException { + IOException, AttachNotSupportedException, + AgentLoadException, AgentInitializationException { VirtualMachine vm = null; try { @@ -58,6 +58,23 @@ vmd.displayName()); } + /* Recommend jcmd instead of Attach API if jdk9 or later */ + /* See https://bugs.openjdk.java.net/browse/JDK-8177154 */ + String[] versions = vm.getSystemProperties().getProperty("java.version").split("\\.", 3); + /* Check early access. See https://bugs.openjdk.java.net/browse/JDK-8061493 */ + int earlyAccess = versions[0].indexOf('-'); + int major = 0; + if (earlyAccess > 0) { + major = Integer.parseInt(versions[0].substring(0,earlyAccess)); + } else { + major = Integer.parseInt(versions[0]); + } + if (major >= 9) { + System.err.println("For Java 9 or later, use jcmd with below command instead."); + System.err.println("jcmd " + vm.id() + " JVMTI.agent_load " + agentPath); + System.exit(-1); + } + /* load agent to JVM. */ if (options == null) { vm.loadAgentPath(agentPath);
--- a/agent/src/heapstats-engines/jvmInfo.cpp Thu Apr 13 11:28:39 2017 +0900 +++ b/agent/src/heapstats-engines/jvmInfo.cpp Mon May 08 11:08:12 2017 +0900 @@ -162,6 +162,7 @@ if (unlikely(result != 4)) { /* * Support JDK 9 EA + * See https://bugs.openjdk.java.net/browse/JDK-8061493 */ #if USE_PCRE TPCRERegex versionRegex("^(\\d+)-ea\\+(\\d+)$", 9);