< prev index next >

test/hotspot/jtreg/gc/arguments/GCTypes.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.

@@ -24,10 +24,13 @@
 import java.lang.management.GarbageCollectorMXBean;
 import java.lang.management.ManagementFactory;
 import java.util.Arrays;
 import java.util.Objects;
 
+import com.sun.management.HotSpotDiagnosticMXBean;
+import com.sun.management.VMOption;
+
 /**
  * Helper class with enum representation of GC types.
  */
 public final class GCTypes {
 

@@ -55,32 +58,47 @@
                 )
                 .findFirst()
                 .orElse(null);
     }
 
+    public static class LegacyMonitoring {
+        private static final boolean useLegacyMonitoring = getUseLegacyMonitoring();
+
+        private static boolean getUseLegacyMonitoring() {
+            HotSpotDiagnosticMXBean diagnostic
+                = ManagementFactory.getPlatformMXBean(HotSpotDiagnosticMXBean.class);
+            VMOption option = diagnostic.getVMOption("G1UseLegacyMonitoring");
+            return option.getValue().equals("true");
+        }
+
+        public static boolean use() { return useLegacyMonitoring; }
+    }
+
     /**
      * Helper interface used by GCTypes static methods
      * to get gcTypeName field of *GCType classes.
      */
     private interface GCType {
-
         String getGCName();
     }
 
     public static enum YoungGCType implements GCType {
         DefNew("Copy"),
         ParNew("ParNew"),
         PSNew("PS Scavenge"),
-        G1("G1 Young Generation");
+        G1("G1");
 
         @Override
         public String getGCName() {
             return gcTypeName;
         }
         private final String gcTypeName;
 
         private YoungGCType(String name) {
+            if (name.contains("G1")) {
+                name = LegacyMonitoring.use() ? "G1 Young Generation" : "G1 Young";
+            }
             gcTypeName = name;
         }
 
         public static YoungGCType getYoungGCType() {
             return GCTypes.getCurrentGCType(YoungGCType.class);

@@ -93,15 +111,18 @@
 
     public static enum OldGCType implements GCType {
         Serial("MarkSweepCompact"),
         CMS("ConcurrentMarkSweep"),
         PSOld("PS MarkSweep"),
-        G1("G1 Old Generation");
+        G1("G1");
 
         private final String gcTypeName;
 
         private OldGCType(String name) {
+            if (name.contains("G1")) {
+                name = LegacyMonitoring.use() ? "G1 Old Generation" : "G1 Full";
+            }
             gcTypeName = name;
         }
 
         public static OldGCType getOldGCType() {
             return GCTypes.getCurrentGCType(OldGCType.class);
< prev index next >