--- old/test/hotspot/jtreg/gc/arguments/GCTypes.java 2018-10-19 10:54:11.000000000 -0400 +++ new/test/hotspot/jtreg/gc/arguments/GCTypes.java 2018-10-19 10:54:11.000000000 -0400 @@ -1,5 +1,5 @@ /* - * 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 @@ -26,6 +26,9 @@ 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. */ @@ -57,12 +60,24 @@ .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(); } @@ -70,7 +85,7 @@ DefNew("Copy"), ParNew("ParNew"), PSNew("PS Scavenge"), - G1("G1 Young Generation"); + G1("G1"); @Override public String getGCName() { @@ -79,6 +94,9 @@ private final String gcTypeName; private YoungGCType(String name) { + if (name.contains("G1")) { + name = LegacyMonitoring.use() ? "G1 Young Generation" : "G1 Young"; + } gcTypeName = name; } @@ -95,11 +113,14 @@ 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; }