test/runtime/CompressedOops/ObjectAlignment.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File 8059557_open Sdiff test/runtime/CompressedOops

test/runtime/CompressedOops/ObjectAlignment.java

Print this page




  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8022865
  27  * @summary Tests for the -XX:ObjectAlignmentInBytes command line option
  28  * @library /testlibrary
  29  * @modules java.base/sun.misc
  30  *          java.management
  31  * @run main ObjectAlignment
  32  */
  33 import jdk.test.lib.*;
  34 
  35 public class ObjectAlignment {
  36 
  37     public static void main(String[] args) throws Exception {
  38 
  39         if (Platform.is64bit()) {
  40             // Minimum alignment should be 8
  41             testObjectAlignment(4)
  42                 .shouldContain("error: ObjectAlignmentInBytes=4 must be greater or equal 8")
  43                 .shouldHaveExitValue(1);
  44 
  45             // Alignment has to be a power of 2
  46             testObjectAlignment(9)
  47                 .shouldContain("error: ObjectAlignmentInBytes=9 must be power of 2")
  48                 .shouldHaveExitValue(1);
  49 
  50             testObjectAlignment(-1)
  51                 .shouldContain("error: ObjectAlignmentInBytes=-1 must be power of 2")

  52                 .shouldHaveExitValue(1);
  53 
  54             // Maximum alignment allowed is 256
  55             testObjectAlignment(512)
  56                 .shouldContain("error: ObjectAlignmentInBytes=512 must not be greater than 256")
  57                 .shouldHaveExitValue(1);
  58 
  59             // Valid alignments should work
  60             testObjectAlignment(8).shouldHaveExitValue(0);
  61             testObjectAlignment(16).shouldHaveExitValue(0);
  62             testObjectAlignment(256).shouldHaveExitValue(0);
  63 
  64         } else {
  65             // For a 32bit JVM the option isn't there, make sure it's not silently ignored
  66             testObjectAlignment(8)
  67                 .shouldContain("Unrecognized VM option 'ObjectAlignmentInBytes=8'")
  68                 .shouldHaveExitValue(1);
  69         }
  70     }
  71 
  72     private static OutputAnalyzer testObjectAlignment(int alignment) throws Exception {
  73         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:ObjectAlignmentInBytes=" + alignment,
  74                                                                   "-version");
  75         return new OutputAnalyzer(pb.start());
  76     }


  22  */
  23 
  24 /*
  25  * @test
  26  * @bug 8022865
  27  * @summary Tests for the -XX:ObjectAlignmentInBytes command line option
  28  * @library /testlibrary
  29  * @modules java.base/sun.misc
  30  *          java.management
  31  * @run main ObjectAlignment
  32  */
  33 import jdk.test.lib.*;
  34 
  35 public class ObjectAlignment {
  36 
  37     public static void main(String[] args) throws Exception {
  38 
  39         if (Platform.is64bit()) {
  40             // Minimum alignment should be 8
  41             testObjectAlignment(4)
  42                 .shouldContain("outside the allowed range")
  43                 .shouldHaveExitValue(1);
  44 
  45             // Alignment has to be a power of 2
  46             testObjectAlignment(9)
  47                 .shouldContain("must be power of 2")
  48                 .shouldHaveExitValue(1);
  49 
  50             testObjectAlignment(-1)
  51                 .shouldContain("must be power of 2")
  52                 .shouldContain("outside the allowed range")
  53                 .shouldHaveExitValue(1);
  54 
  55             // Maximum alignment allowed is 256
  56             testObjectAlignment(512)
  57                 .shouldContain("outside the allowed range")
  58                 .shouldHaveExitValue(1);
  59 
  60             // Valid alignments should work
  61             testObjectAlignment(8).shouldHaveExitValue(0);
  62             testObjectAlignment(16).shouldHaveExitValue(0);
  63             testObjectAlignment(256).shouldHaveExitValue(0);
  64 
  65         } else {
  66             // For a 32bit JVM the option isn't there, make sure it's not silently ignored
  67             testObjectAlignment(8)
  68                 .shouldContain("Unrecognized VM option 'ObjectAlignmentInBytes=8'")
  69                 .shouldHaveExitValue(1);
  70         }
  71     }
  72 
  73     private static OutputAnalyzer testObjectAlignment(int alignment) throws Exception {
  74         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:ObjectAlignmentInBytes=" + alignment,
  75                                                                   "-version");
  76         return new OutputAnalyzer(pb.start());
  77     }
test/runtime/CompressedOops/ObjectAlignment.java
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File