test/runtime/SharedArchiveFile/LargeSharedSpace.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.

@@ -31,11 +31,11 @@
  * @modules java.base/jdk.internal.misc
  *          java.management
  * @run main LargeSharedSpace
  */
 
-import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.cds.CDSTestUtils;
 import jdk.test.lib.process.OutputAnalyzer;
 import jdk.test.lib.Platform;
 
 public class LargeSharedSpace {
     public static void main(String[] args) throws Exception {

@@ -44,14 +44,12 @@
 
        // Test case 1: -XX:SharedMiscCodeSize=1066924031
        //
        // The archive should be dumped successfully. It might fail to reserve memory
        // for shared space under low memory condition. The dumping process should not crash.
-       pb = ProcessTools.createJavaProcessBuilder(
-                "-XX:SharedMiscCodeSize=1066924031", "-XX:+UnlockDiagnosticVMOptions",
-                "-XX:SharedArchiveFile=./LargeSharedSpace.jsa", "-Xshare:dump");
-       output = new OutputAnalyzer(pb.start());
+       output = CDSTestUtils.createArchive("-XX:SharedMiscCodeSize=1066924031",
+                                           "-XX:+UnlockDiagnosticVMOptions");
        try {
            output.shouldContain("Loading classes to share");
        } catch (RuntimeException e1) {
            output.shouldContain("Unable to allocate memory for shared space");
        }

@@ -62,29 +60,24 @@
        // shared space size and the compressed space size is larger than the 4G
        // compressed klass limit (0x100000000), error is reported.
        //
        // The dumping process should not crash.
        if (Platform.is64bit()) {
-           pb = ProcessTools.createJavaProcessBuilder(
+           CDSTestUtils.createArchive(
                     "-XX:+UseCompressedClassPointers", "-XX:CompressedClassSpaceSize=3G",
-                    "-XX:SharedMiscCodeSize=1600386047", "-XX:+UnlockDiagnosticVMOptions",
-                    "-XX:SharedArchiveFile=./LargeSharedSpace.jsa", "-Xshare:dump");
-           output = new OutputAnalyzer(pb.start());
-           output.shouldContain("larger than compressed klass limit");
+               "-XX:SharedMiscCodeSize=1600386047")
+               .shouldContain("larger than compressed klass limit");
         }
 
         // Test case 3: -XX:SharedMiscCodeSize=1600386047
         //
         // On 32-bit platform, compressed class pointer is not used. It may fail
         // to reserve memory under low memory condition.
         //
         // The dumping process should not crash.
         if (Platform.is32bit()) {
-           pb = ProcessTools.createJavaProcessBuilder(
-                    "-XX:SharedMiscCodeSize=1600386047", "-XX:+UnlockDiagnosticVMOptions",
-                    "-XX:SharedArchiveFile=./LargeSharedSpace.jsa", "-Xshare:dump");
-           output = new OutputAnalyzer(pb.start());
+            output = CDSTestUtils.createArchive("-XX:SharedMiscCodeSize=1600386047");
            try {
                output.shouldContain("Loading classes to share");
            } catch (RuntimeException e3) {
                output.shouldContain("Unable to allocate memory for shared space");
            }