< prev index next >

test/hotspot/jtreg/runtime/appcds/sharedStrings/IncompatibleOptions.java

Print this page




  22  *
  23  */
  24 
  25 /*
  26  * @test
  27  * @summary Test options that are incompatible with use of shared strings
  28  *          Also test mismatch in oops encoding between dump time and run time
  29  * @requires vm.cds.archived.java.heap
  30  * @requires (vm.gc=="null")
  31  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  32  * @modules java.base/jdk.internal.misc
  33  * @modules java.management
  34  *          jdk.jartool/sun.tools.jar
  35  * @build sun.hotspot.WhiteBox
  36  * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  37  * @build HelloString
  38  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. IncompatibleOptions
  39  */
  40 
  41 import jdk.test.lib.Asserts;

  42 import jdk.test.lib.process.OutputAnalyzer;
  43 
  44 import sun.hotspot.code.Compiler;
  45 
  46 public class IncompatibleOptions {
  47     static final String COOPS_DUMP_WARNING =
  48         "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off";
  49     static final String COOPS_EXEC_WARNING =
  50         "UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces";
  51     static final String GC_WARNING =
  52         "Archived java heap is not supported";
  53     static final String OBJ_ALIGNMENT_MISMATCH =
  54         "The shared archive file's ObjectAlignmentInBytes of .* does not equal the current ObjectAlignmentInBytes of";
  55     static final String COMPACT_STRING_MISMATCH =
  56         "The shared archive file's CompactStrings setting .* does not equal the current CompactStrings setting";
  57 
  58     static String appJar;
  59 
  60     public static void main(String[] args) throws Exception {
  61         appJar = JarBuilder.build("IncompatibleOptions", "HelloString");
  62 
  63         // Uncompressed OOPs
  64         testDump(1, "-XX:+UseG1GC", "-XX:-UseCompressedOops", COOPS_DUMP_WARNING, true);



  65 
  66         // incompatible GCs
  67         testDump(2, "-XX:+UseParallelGC", "", GC_WARNING, false);
  68         testDump(3, "-XX:+UseSerialGC", "", GC_WARNING, false);
  69         if (!Compiler.isGraalEnabled()) { // Graal does not support CMS
  70             testDump(4, "-XX:+UseConcMarkSweepGC", "", GC_WARNING, false);
  71         }
  72 
  73         // ======= archive with compressed oops, run w/o
  74         testDump(5, "-XX:+UseG1GC", "-XX:+UseCompressedOops", null, false);
  75         testExec(5, "-XX:+UseG1GC", "-XX:-UseCompressedOops",
  76                  COOPS_EXEC_WARNING, true);
  77 
  78         // NOTE: No warning is displayed, by design
  79         // Still run, to ensure no crash or exception
  80         testExec(6, "-XX:+UseParallelGC", "", "", false);
  81         testExec(7, "-XX:+UseSerialGC", "", "", false);
  82         if (!Compiler.isGraalEnabled()) { // Graal does not support CMS
  83             testExec(8, "-XX:+UseConcMarkSweepGC", "", "", false);
  84         }




  22  *
  23  */
  24 
  25 /*
  26  * @test
  27  * @summary Test options that are incompatible with use of shared strings
  28  *          Also test mismatch in oops encoding between dump time and run time
  29  * @requires vm.cds.archived.java.heap
  30  * @requires (vm.gc=="null")
  31  * @library /test/lib /test/hotspot/jtreg/runtime/appcds
  32  * @modules java.base/jdk.internal.misc
  33  * @modules java.management
  34  *          jdk.jartool/sun.tools.jar
  35  * @build sun.hotspot.WhiteBox
  36  * @run driver ClassFileInstaller sun.hotspot.WhiteBox sun.hotspot.WhiteBox$WhiteBoxPermission
  37  * @build HelloString
  38  * @run main/othervm -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbootclasspath/a:. IncompatibleOptions
  39  */
  40 
  41 import jdk.test.lib.Asserts;
  42 import jdk.test.lib.Platform;
  43 import jdk.test.lib.process.OutputAnalyzer;
  44 
  45 import sun.hotspot.code.Compiler;
  46 
  47 public class IncompatibleOptions {
  48     static final String COOPS_DUMP_WARNING =
  49         "Cannot dump shared archive when UseCompressedOops or UseCompressedClassPointers is off";
  50     static final String COOPS_EXEC_WARNING =
  51         "UseCompressedOops and UseCompressedClassPointers must be on for UseSharedSpaces";
  52     static final String GC_WARNING =
  53         "Archived java heap is not supported";
  54     static final String OBJ_ALIGNMENT_MISMATCH =
  55         "The shared archive file's ObjectAlignmentInBytes of .* does not equal the current ObjectAlignmentInBytes of";
  56     static final String COMPACT_STRING_MISMATCH =
  57         "The shared archive file's CompactStrings setting .* does not equal the current CompactStrings setting";
  58 
  59     static String appJar;
  60 
  61     public static void main(String[] args) throws Exception {
  62         appJar = JarBuilder.build("IncompatibleOptions", "HelloString");
  63 
  64         // Uncompressed OOPs
  65         testDump(1, "-XX:+UseG1GC", "-XX:-UseCompressedOops", COOPS_DUMP_WARNING, true);
  66         if (Platform.isLinux() && Platform.isX64()) {
  67             testDump(1, "-XX:+UnlockExperimentalVMOptions", "-XX:+UseZGC", COOPS_DUMP_WARNING, true);
  68         }
  69 
  70         // incompatible GCs
  71         testDump(2, "-XX:+UseParallelGC", "", GC_WARNING, false);
  72         testDump(3, "-XX:+UseSerialGC", "", GC_WARNING, false);
  73         if (!Compiler.isGraalEnabled()) { // Graal does not support CMS
  74             testDump(4, "-XX:+UseConcMarkSweepGC", "", GC_WARNING, false);
  75         }
  76 
  77         // ======= archive with compressed oops, run w/o
  78         testDump(5, "-XX:+UseG1GC", "-XX:+UseCompressedOops", null, false);
  79         testExec(5, "-XX:+UseG1GC", "-XX:-UseCompressedOops",
  80                  COOPS_EXEC_WARNING, true);
  81 
  82         // NOTE: No warning is displayed, by design
  83         // Still run, to ensure no crash or exception
  84         testExec(6, "-XX:+UseParallelGC", "", "", false);
  85         testExec(7, "-XX:+UseSerialGC", "", "", false);
  86         if (!Compiler.isGraalEnabled()) { // Graal does not support CMS
  87             testExec(8, "-XX:+UseConcMarkSweepGC", "", "", false);
  88         }


< prev index next >