changeset 281:1e8de29f38c4 default tip

Bug 3791: HeapStats agent should show warning if it run on JDK 8u262 or later Co-authored-by: KUBOTA Yuji <kubota.yuji@gmail.com> Reviewed-by: ykubota https://github.com/HeapStats/heapstats/pull/154
author Yasumasa Suenaga <yasuenag@gmail.com>
date Sun, 19 Jul 2020 12:52:57 +0900
parents d9111a1d15cf
children
files ChangeLog README agent/src/heapstats-engines/jvmInfo.cpp
diffstat 3 files changed, 21 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Nov 11 21:07:11 2019 +0900
+++ b/ChangeLog	Sun Jul 19 12:52:57 2020 +0900
@@ -1,3 +1,7 @@
+2020-07-19 Yasumasa Suenaga <yasuenag@gmail.com>
+
+	* Bug 3791: HeapStats agent should show warning if it run on JDK 8u262 or later
+
 2019-11-11 Yasumasa Suenaga <yasuenag@gmail.com>
 
 	* Bug 3764: Agent thread might not be stopped when it works
--- a/README	Mon Nov 11 21:07:11 2019 +0900
+++ b/README	Sun Jul 19 12:52:57 2020 +0900
@@ -36,6 +36,8 @@
 * Linux x64 / x86_64 / AArch32
 * Oracle JDK / OpenJDK 6u18 or later
 
+**NOTE: For JDK 8u262 or later, we recommend to use built-in agent, JDK Flight Recorder, instead of HeapStats**
+
 ## How to use ##
 
 You can attach HeapStats agent by any way of the following:
@@ -154,4 +156,3 @@
 # License #
 
 [GNU General Public License, version 2](COPYING)
-
--- a/agent/src/heapstats-engines/jvmInfo.cpp	Mon Nov 11 21:07:11 2019 +0900
+++ b/agent/src/heapstats-engines/jvmInfo.cpp	Sun Jul 19 12:52:57 2020 +0900
@@ -1,7 +1,7 @@
 /*!
  * \file jvmInfo.cpp
  * \brief This file is used to get JVM performance information.
- * Copyright (C) 2011-2016 Nippon Telegraph and Telephone Corporation
+ * Copyright (C) 2011-2020 Nippon Telegraph and Telephone Corporation
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -526,4 +526,18 @@
   if (!isAfterJDK9()) {
     loadDelayLogFlag &= (_endorsedPath != NULL) && (_bootClassPath != NULL);
   }
+
+  /* JFR-backported JDK 8 is not supported */
+#if USE_PCRE
+  TPCRERegex versionRegex("^\\d+\\.(\\d+)\\.\\d+_(\\d+)[^0-9]*$", 9);
+#else
+  TCPPRegex versionRegex("^\\d+\\.(\\d+)\\.\\d+_(\\d+)[^0-9]*$");
+#endif
+  if (versionRegex.find(this->_javaVersion)) {
+    int major = atoi(versionRegex.group(1));
+    int update = atoi(versionRegex.group(2));
+    if ((major == 8) && (update >= 262)) {
+      logger->printWarnMsg("JDK %s is not recommended due to JFR backport", this->_javaVersion);
+    }
+  }
 }