changeset 158:f5626d1b4522

Bug 2912: [JDK 9] Support JDK 9 version string
author Yasumasa Suenaga <yasuenag@gmail.com>
date Mon, 18 Apr 2016 21:28:23 +0900
parents f3e6f861c1b2
children 488fb0589030
files agent/src/heapstats-engines/jvmInfo.cpp
diffstat 1 files changed, 31 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/agent/src/heapstats-engines/jvmInfo.cpp	Mon Apr 18 21:28:04 2016 +0900
+++ b/agent/src/heapstats-engines/jvmInfo.cpp	Mon Apr 18 21:28:23 2016 +0900
@@ -36,6 +36,13 @@
 #include "util.hpp"
 #include "jvmInfo.hpp"
 
+#if USE_PCRE
+#include "pcreRegex.hpp"
+#else
+#include "cppRegex.hpp"
+#endif
+
+
 /*!
  * \brief TJvmInfo constructor.
  */
@@ -153,10 +160,30 @@
        * This versioning equals to JDK version.
        */
       if (unlikely(result != 4)) {
-        logger->printCritMsg("Unsupported JVM version: %s (%d)", versionStr,
-                             result);
-        jvmti->Deallocate((unsigned char *)versionStr);
-        return false;
+        /*
+         * Support JDK 9 EA
+         */
+#if USE_PCRE
+        TPCRERegex versionRegex("^(\\d+)-ea\\+(\\d+)$", 9);
+#else
+        TCPPRegex versionRegex("^(\\d+)-ea\\+(\\d+)$");
+#endif
+        if (versionRegex.find(versionStr)) {
+          char *minorStr = versionRegex.group(1);
+          char *buildStr = versionRegex.group(2);
+
+          major = 1;
+          minor = (unsigned char)atoi(minorStr);
+          micro = 0;
+          build = (unsigned char)atoi(buildStr);
+
+          free(minorStr);
+          free(buildStr);
+        } else {
+          logger->printCritMsg("Unsupported JVM version: %s", versionStr);
+          jvmti->Deallocate((unsigned char *)versionStr);
+          return false;
+        }
       }
 
       /*