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:cds=debug,cds+module=debug,cds+heap=info,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 subgraphCannotBeUsed = "subgraph jdk.internal.module.ArchivedBootLayer cannot be used because full module graph is disabled";
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 .shouldMatch("cds,module.*Restored from archive: entry.0x.*name jdk.httpserver");
66
67 // different module specified during runtime
68 oa = TestCommon.execCommon(
69 loggingOption,
70 "-m", "jdk.compiler/com.sun.tools.javac.Main",
71 "-version");
72 oa.shouldHaveExitValue(0)
73 .shouldContain("Mismatched modules: runtime jdk.compiler dump time jdk.httpserver")
74 .shouldContain(subgraphCannotBeUsed);
75
76 // no module specified during runtime
77 oa = TestCommon.execCommon(
78 loggingOption,
79 "-version");
80 oa.shouldHaveExitValue(0)
81 .shouldContain("Module jdk.httpserver specified during dump time but not during runtime")
82 .shouldContain(subgraphCannotBeUsed);
83
84 // dump an archive without the module option
85 archiveName = TestCommon.getNewArchiveName("no-module-option");
86 TestCommon.setCurrentArchiveName(archiveName);
87 oa = TestCommon.dumpBaseArchive(
88 archiveName,
89 loggingOption,
90 "-version");
91 oa.shouldHaveExitValue(0);
92
93 // run with module option
94 oa = TestCommon.execCommon(
95 loggingOption,
96 "-m", moduleOption,
97 "-version");
98 oa.shouldHaveExitValue(0)
99 .shouldContain("Module jdk.httpserver specified during runtime but not during dump time")
100 // version of the jdk.httpserver module, e.g. java 22-ea
101 .shouldMatch(versionPattern)
102 .shouldContain(subgraphCannotBeUsed);
103
104 // dump an archive with an incubator module, -m jdk.incubator.vector
105 archiveName = TestCommon.getNewArchiveName("incubator-module");
106 TestCommon.setCurrentArchiveName(archiveName);
107 oa = TestCommon.dumpBaseArchive(
108 archiveName,
109 loggingOption,
110 "-m", incubatorModule,
111 "-version");
112 oa.shouldHaveExitValue(0)
113 // module graph won't be archived with an incubator module
114 .shouldContain("archivedBootLayer not available, disabling full module graph");
115
116 // run with the same incubator module
117 oa = TestCommon.execCommon(
118 loggingOption,
119 "-m", incubatorModule,
120 "-version");
121 oa.shouldContain("full module graph: disabled")
122 // module is not restored from archive
|
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:cds=debug,cds+module=debug,cds+heap=info,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 subgraphCannotBeUsed = "subgraph jdk.internal.module.ArchivedBootLayer cannot be used because full module graph is disabled";
46 final String noOptimizedModuleHandling = "optimized module handling: disabled because archive was created without optimized module handling";
47 String archiveName = TestCommon.getNewArchiveName("module-option");
48 TestCommon.setCurrentArchiveName(archiveName);
49
50 // dump a base archive with -m jdk.httpserver
51 OutputAnalyzer oa = TestCommon.dumpBaseArchive(
52 archiveName,
53 loggingOption,
54 "-m", moduleOption,
55 "-version");
56 oa.shouldHaveExitValue(0);
57
58 // same module specified during runtime
59 oa = TestCommon.execCommon(
60 loggingOption,
61 "-m", moduleOption,
62 "-version");
63 oa.shouldHaveExitValue(0)
64 // version of the jdk.httpserver module, e.g. java 22-ea
65 .shouldMatch(versionPattern);
66 if (!oa.contains(noOptimizedModuleHandling)) {
67 oa.shouldMatch("cds,module.*Restored from archive: entry.0x.*name jdk.httpserver");
68 }
69
70 // different module specified during runtime
71 oa = TestCommon.execCommon(
72 loggingOption,
73 "-m", "jdk.compiler/com.sun.tools.javac.Main",
74 "-version");
75 oa.shouldHaveExitValue(0)
76 .shouldContain("Mismatched modules: runtime jdk.compiler dump time jdk.httpserver");
77 if (!oa.contains(noOptimizedModuleHandling)) {
78 oa.shouldContain(subgraphCannotBeUsed);
79 }
80
81 // no module specified during runtime
82 oa = TestCommon.execCommon(
83 loggingOption,
84 "-version");
85 oa.shouldHaveExitValue(0)
86 .shouldContain("Module jdk.httpserver specified during dump time but not during runtime");
87 if (!oa.contains(noOptimizedModuleHandling)) {
88 oa.shouldContain(subgraphCannotBeUsed);
89 }
90
91 // dump an archive without the module option
92 archiveName = TestCommon.getNewArchiveName("no-module-option");
93 TestCommon.setCurrentArchiveName(archiveName);
94 oa = TestCommon.dumpBaseArchive(
95 archiveName,
96 loggingOption,
97 "-version");
98 oa.shouldHaveExitValue(0);
99
100 // run with module option
101 oa = TestCommon.execCommon(
102 loggingOption,
103 "-m", moduleOption,
104 "-version");
105 oa.shouldHaveExitValue(0)
106 .shouldContain("Module jdk.httpserver specified during runtime but not during dump time")
107 // version of the jdk.httpserver module, e.g. java 22-ea
108 .shouldMatch(versionPattern);
109 if (!oa.contains(noOptimizedModuleHandling)) {
110 oa.shouldContain(subgraphCannotBeUsed);
111 }
112
113 // dump an archive with an incubator module, -m jdk.incubator.vector
114 archiveName = TestCommon.getNewArchiveName("incubator-module");
115 TestCommon.setCurrentArchiveName(archiveName);
116 oa = TestCommon.dumpBaseArchive(
117 archiveName,
118 loggingOption,
119 "-m", incubatorModule,
120 "-version");
121 oa.shouldHaveExitValue(0)
122 // module graph won't be archived with an incubator module
123 .shouldContain("archivedBootLayer not available, disabling full module graph");
124
125 // run with the same incubator module
126 oa = TestCommon.execCommon(
127 loggingOption,
128 "-m", incubatorModule,
129 "-version");
130 oa.shouldContain("full module graph: disabled")
131 // module is not restored from archive
|