test/gc/arguments/TestUseCompressedOopsErgoTools.java
Print this page
@@ -40,14 +40,14 @@
}
}
class TestUseCompressedOopsErgoTools {
- private static long getClassMetaspaceSize() {
+ private static long getMetaspaceSize() {
HotSpotDiagnosticMXBean diagnostic = ManagementFactoryHelper.getDiagnosticMXBean();
- VMOption option = diagnostic.getVMOption("ClassMetaspaceSize");
+ VMOption option = diagnostic.getVMOption("MetaspaceSize");
return Long.parseLong(option.getValue());
}
public static long getMaxHeapForCompressedOops(String[] vmargs) throws Exception {
@@ -130,17 +130,17 @@
checkUseCompressedOops(join(gcflags, "-XX:ObjectAlignmentInBytes=16"), maxHeapForCompressedOops, true);
checkUseCompressedOops(join(gcflags, "-XX:ObjectAlignmentInBytes=16"), maxHeapForCompressedOops - 1, true);
checkUseCompressedOops(join(gcflags, "-XX:ObjectAlignmentInBytes=16"), maxHeapForCompressedOops + 1, false);
- // use a different ClassMetaspaceSize
- String classMetaspaceSizeArg = "-XX:ClassMetaspaceSize=" + 2 * getClassMetaspaceSize();
- maxHeapForCompressedOops = getMaxHeapForCompressedOops(join(gcflags, classMetaspaceSizeArg));
-
- checkUseCompressedOops(join(gcflags, classMetaspaceSizeArg), maxHeapForCompressedOops, true);
- checkUseCompressedOops(join(gcflags, classMetaspaceSizeArg), maxHeapForCompressedOops - 1, true);
- checkUseCompressedOops(join(gcflags, classMetaspaceSizeArg), maxHeapForCompressedOops + 1, false);
+ // use a different MetaspaceSize
+ String metaspaceSizeArg = "-XX:MetaspaceSize=" + 2 * getMetaspaceSize();
+ maxHeapForCompressedOops = getMaxHeapForCompressedOops(join(gcflags, metaspaceSizeArg));
+
+ checkUseCompressedOops(join(gcflags, metaspaceSizeArg), maxHeapForCompressedOops, true);
+ checkUseCompressedOops(join(gcflags, metaspaceSizeArg), maxHeapForCompressedOops - 1, true);
+ checkUseCompressedOops(join(gcflags, metaspaceSizeArg), maxHeapForCompressedOops + 1, false);
}
private static void checkUseCompressedOops(String[] args, long heapsize, boolean expectUseCompressedOops) throws Exception {
ArrayList<String> finalargs = new ArrayList<String>();
finalargs.addAll(Arrays.asList(args));
@@ -150,21 +150,19 @@
String output = expectValid(finalargs.toArray(new String[0]));
boolean actualUseCompressedOops = getFlagBoolValue(" UseCompressedOops", output);
- if (expectUseCompressedOops != actualUseCompressedOops) {
- throw new RuntimeException("Expected use of compressed oops: " + expectUseCompressedOops + " but was: " + actualUseCompressedOops);
- }
+ Asserts.assertEQ(expectUseCompressedOops, actualUseCompressedOops);
}
private static boolean getFlagBoolValue(String flag, String where) {
Matcher m = Pattern.compile(flag + "\\s+:?= (true|false)").matcher(where);
if (!m.find()) {
throw new RuntimeException("Could not find value for flag " + flag + " in output string");
}
- String match = m.group(1).equals("true");
+ return m.group(1).equals("true");
}
private static String expect(String[] flags, boolean hasWarning, boolean hasError, int errorcode) throws Exception {
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(flags);
OutputAnalyzer output = new OutputAnalyzer(pb.start());