hotspot/test/runtime/SharedArchiveFile/LargeSharedSpace.java
changeset 42584 ab0188378b7c
parent 42565 b433edc423da
child 42614 e3a8e9ec17b2
--- a/hotspot/test/runtime/SharedArchiveFile/LargeSharedSpace.java	Mon Nov 21 17:38:13 2016 +0000
+++ b/hotspot/test/runtime/SharedArchiveFile/LargeSharedSpace.java	Mon Nov 21 21:07:45 2016 -0500
@@ -23,10 +23,10 @@
 
 /*
  * @test LargeSharedSpace
- * @bug 8168790
+ * @bug 8168790 8169870
  * @summary Test CDS dumping with specific space size.
- * The space size used in the test might not be suitable on windows and 32-bit platforms.
- * @requires (sun.arch.data.model != "32") & (os.family != "windows")
+ * The space size used in the test might not be suitable on windows.
+ * @requires (os.family != "windows")
  * @library /test/lib
  * @modules java.base/jdk.internal.misc
  *          java.management
@@ -38,11 +38,24 @@
 
 public class LargeSharedSpace {
     public static void main(String[] args) throws Exception {
-       ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
-            "-XX:SharedMiscCodeSize=1066924031", "-XX:+UnlockDiagnosticVMOptions",
-            "-XX:SharedArchiveFile=./LargeSharedSpace.jsa", "-Xshare:dump");
-       OutputAnalyzer output = new OutputAnalyzer(pb.start());
-       output.shouldContain("Loading classes to share");
-       output.shouldHaveExitValue(0);
+       String sizes[] = {"1066924031", "1600386047"};
+       String expectedOutputs[] =
+           {/* can dump using the given size */
+            "Loading classes to share",
+            /* the size is too large, exceeding the limit for compressed klass support */
+            "larger than compressed klass limit"};
+       for (int i = 0; i < sizes.length; i++) {
+           ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(
+                "-XX:SharedMiscCodeSize="+sizes[i], "-XX:+UnlockDiagnosticVMOptions",
+                "-XX:SharedArchiveFile=./LargeSharedSpace.jsa", "-Xshare:dump");
+           OutputAnalyzer output = new OutputAnalyzer(pb.start());
+           try {
+               output.shouldContain(expectedOutputs[i]);
+           } catch (RuntimeException e) {
+               /* failed to reserve the memory for the required size, might happen
+                  on 32-bit platforms */
+               output.shouldContain("Unable to allocate memory for shared space");
+           }
+       }
     }
 }