test/runtime/SharedArchiveFile/SharedStringsDedup.java
Print this page
@@ -1,7 +1,7 @@
/*
- * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2017, 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.
@@ -32,42 +32,22 @@
* @modules java.base/jdk.internal.misc
* java.management
* @run main SharedStringsDedup
*/
-import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.cds.CDSTestUtils;
import jdk.test.lib.process.OutputAnalyzer;
import java.io.File;
// The main purpose is to test the interaction between shared strings
// and -XX:+UseStringDeduplication. We run in -Xshare:auto mode so
// we don't need to worry about CDS archive mapping failure (which
// doesn't happen often so it won't impact coverage).
public class SharedStringsDedup {
public static void main(String[] args) throws Exception {
- // Dump
- ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
- "-XX:+UnlockDiagnosticVMOptions",
- "-XX:SharedArchiveFile=./SharedStringsDedup.jsa",
- "-XX:+UseCompressedOops", "-XX:+UseG1GC",
- "-XX:+PrintSharedSpaces",
- "-Xshare:dump");
-
- new OutputAnalyzer(pb.start())
- .shouldContain("Loading classes to share")
- .shouldContain("Shared string table stats")
- .shouldHaveExitValue(0);
-
- // Run with -Xshare:auto
- pb = ProcessTools.createJavaProcessBuilder(
- "-XX:+UnlockDiagnosticVMOptions",
- "-XX:SharedArchiveFile=./SharedStringsDedup.jsa",
- "-XX:+UseCompressedOops", "-XX:+UseG1GC",
- "-XX:+UseStringDeduplication",
- "-Xshare:auto",
- "-version");
-
- new OutputAnalyzer(pb.start())
- .shouldMatch("(java|openjdk) version")
- .shouldHaveExitValue(0);
+ OutputAnalyzer out =
+ CDSTestUtils.createArchive("-XX:+UseCompressedOops", "-XX:+UseG1GC");
+ CDSTestUtils.checkDump(out, "Shared string table stats");
+ CDSTestUtils.runWithArchiveAndCheck("-XX:+UseCompressedOops", "-XX:+UseG1GC",
+ "-XX:+UseStringDeduplication");
}
}