< prev index next >

test/hotspot/jtreg/runtime/cds/appcds/jigsaw/module/ModuleOption.java

Print this page

 25  * @test
 26  * @bug 8316969
 27  * @summary Test handling of module option (-m).
 28  * @requires vm.cds.write.archived.java.heap
 29  * @requires vm.flagless
 30  * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
 31  * @run driver ModuleOption
 32  */
 33 
 34 import jdk.test.lib.process.OutputAnalyzer;
 35 
 36 public class ModuleOption {
 37     public static void main(String[] args) throws Exception {
 38         final String moduleOption = "jdk.httpserver/sun.net.httpserver.simpleserver.Main";
 39         final String incubatorModule = "jdk.incubator.vector";
 40         final String loggingOption = "-Xlog:aot=debug,aot+module=debug,aot+heap=info,cds=debug,module=trace";
 41         // Pattern of a module version string.
 42         // e.g. JDK 22:     "java 22"
 43         //      JDK 22.0.1: "java 22.0.1"
 44         final String versionPattern = "java.[0-9][0-9].*";

 45         String archiveName = TestCommon.getNewArchiveName("module-option");
 46         TestCommon.setCurrentArchiveName(archiveName);
 47 
 48         // dump a base archive with -m jdk.httpserver
 49         OutputAnalyzer oa = TestCommon.dumpBaseArchive(
 50             archiveName,
 51             loggingOption,
 52             "-m", moduleOption,
 53             "-version");
 54         oa.shouldHaveExitValue(0);
 55 
 56         // same module specified during runtime
 57         oa = TestCommon.execCommon(
 58             loggingOption,
 59             "-m", moduleOption,
 60             "-version");
 61         oa.shouldHaveExitValue(0)
 62           // version of the jdk.httpserver module, e.g. java 22-ea
 63           .shouldMatch(versionPattern)
 64           .shouldMatch("aot,module.*Restored from archive: entry.0x.*name jdk.httpserver");


 65 
 66         // different module specified during runtime
 67         oa = TestCommon.execCommon(
 68             loggingOption,
 69             "-m", "jdk.compiler/com.sun.tools.javac.Main",
 70             "-version");
 71         oa.shouldHaveExitValue(0)
 72           .shouldContain("Mismatched values for property jdk.module.main: runtime jdk.compiler dump time jdk.httpserver");
 73 
 74         // no module specified during runtime
 75         oa = TestCommon.execCommon(
 76             loggingOption,
 77             "-version");
 78         oa.shouldHaveExitValue(0)
 79           .shouldContain("Mismatched values for property jdk.module.main: jdk.httpserver specified during dump time but not during runtime");
 80 
 81         // dump an archive without the module option
 82         archiveName = TestCommon.getNewArchiveName("no-module-option");
 83         TestCommon.setCurrentArchiveName(archiveName);
 84         oa = TestCommon.dumpBaseArchive(

 25  * @test
 26  * @bug 8316969
 27  * @summary Test handling of module option (-m).
 28  * @requires vm.cds.write.archived.java.heap
 29  * @requires vm.flagless
 30  * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
 31  * @run driver ModuleOption
 32  */
 33 
 34 import jdk.test.lib.process.OutputAnalyzer;
 35 
 36 public class ModuleOption {
 37     public static void main(String[] args) throws Exception {
 38         final String moduleOption = "jdk.httpserver/sun.net.httpserver.simpleserver.Main";
 39         final String incubatorModule = "jdk.incubator.vector";
 40         final String loggingOption = "-Xlog:aot=debug,aot+module=debug,aot+heap=info,cds=debug,module=trace";
 41         // Pattern of a module version string.
 42         // e.g. JDK 22:     "java 22"
 43         //      JDK 22.0.1: "java 22.0.1"
 44         final String versionPattern = "java.[0-9][0-9].*";
 45         final String noOptimizedModuleHandling = "optimized module handling: disabled because archive was created without optimized module handling";
 46         String archiveName = TestCommon.getNewArchiveName("module-option");
 47         TestCommon.setCurrentArchiveName(archiveName);
 48 
 49         // dump a base archive with -m jdk.httpserver
 50         OutputAnalyzer oa = TestCommon.dumpBaseArchive(
 51             archiveName,
 52             loggingOption,
 53             "-m", moduleOption,
 54             "-version");
 55         oa.shouldHaveExitValue(0);
 56 
 57         // same module specified during runtime
 58         oa = TestCommon.execCommon(
 59             loggingOption,
 60             "-m", moduleOption,
 61             "-version");
 62         oa.shouldHaveExitValue(0)
 63           // version of the jdk.httpserver module, e.g. java 22-ea
 64           .shouldMatch(versionPattern);
 65         if (!oa.contains(noOptimizedModuleHandling)) {
 66             oa.shouldMatch("aot,module.*Restored from archive: entry.0x.*name jdk.httpserver");
 67         }
 68 
 69         // different module specified during runtime
 70         oa = TestCommon.execCommon(
 71             loggingOption,
 72             "-m", "jdk.compiler/com.sun.tools.javac.Main",
 73             "-version");
 74         oa.shouldHaveExitValue(0)
 75           .shouldContain("Mismatched values for property jdk.module.main: runtime jdk.compiler dump time jdk.httpserver");
 76 
 77         // no module specified during runtime
 78         oa = TestCommon.execCommon(
 79             loggingOption,
 80             "-version");
 81         oa.shouldHaveExitValue(0)
 82           .shouldContain("Mismatched values for property jdk.module.main: jdk.httpserver specified during dump time but not during runtime");
 83 
 84         // dump an archive without the module option
 85         archiveName = TestCommon.getNewArchiveName("no-module-option");
 86         TestCommon.setCurrentArchiveName(archiveName);
 87         oa = TestCommon.dumpBaseArchive(
< prev index next >