2828 * @requires vm.cds.write.archived.java.heap
2929 * @requires vm.flagless
3030 * @library /test/lib /test/hotspot/jtreg/runtime/cds/appcds
31- * @run driver AddmodsOption
31+ * @build jdk.test.whitebox.WhiteBox
32+ * @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
33+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI AddmodsOption
3234 */
3335
3436import jdk .test .lib .process .OutputAnalyzer ;
37+ import jdk .test .whitebox .WhiteBox ;
3538
3639public class AddmodsOption {
40+
41+ private static final WhiteBox WB = WhiteBox .getWhiteBox ();
42+ private static final boolean isJVMCISupported = (WB .getBooleanVMFlag ("EnableJVMCI" ) != null );
43+
3744 public static void main (String [] args ) throws Exception {
3845 final String moduleOption = "jdk.httpserver/sun.net.httpserver.simpleserver.Main" ;
3946 final String incubatorModule = "jdk.incubator.vector" ;
@@ -42,7 +49,7 @@ public static void main(String[] args) throws Exception {
4249 final String allSystem = "ALL-SYSTEM" ;
4350 final String allModulePath = "ALL-MODULE-PATH" ;
4451 final String loggingOption = "-Xlog:cds=debug,cds+module=debug,cds+heap=info,module=trace" ;
45- final String versionPattern = "java.[0-9][0-9][-] .*" ;
52+ final String versionPattern = "java.[0-9][0-9].*" ;
4653 final String subgraphCannotBeUsed = "subgraph jdk.internal.module.ArchivedBootLayer cannot be used because full module graph is disabled" ;
4754 final String warningIncubator = "WARNING: Using incubator modules: jdk.incubator.vector" ;
4855 String archiveName = TestCommon .getNewArchiveName ("addmods-option" );
@@ -136,31 +143,33 @@ public static void main(String[] args) throws Exception {
136143 .shouldContain ("subgraph jdk.internal.module.ArchivedBootLayer is not recorde" )
137144 .shouldHaveExitValue (0 );
138145
139- // dump an archive with JVMCI option which indirectly adds the
140- // jdk.internal.vm.ci module using the --add-modules option
141- archiveName = TestCommon .getNewArchiveName ("jvmci-module" );
142- TestCommon .setCurrentArchiveName (archiveName );
143- oa = TestCommon .dumpBaseArchive (
144- archiveName ,
145- loggingOption ,
146- "-XX:+UnlockExperimentalVMOptions" ,
147- "-XX:+EagerJVMCI" , "-XX:+UseJVMCICompiler" ,
148- "-version" );
149- oa .shouldHaveExitValue (0 );
150-
151- // run with the JVMCI option
152- oa = TestCommon .execCommon (
153- loggingOption ,
154- "-XX:+UnlockExperimentalVMOptions" ,
155- "-XX:+EagerJVMCI" , "-XX:+UseJVMCICompiler" ,
156- "-version" );
157- try {
158- oa .shouldHaveExitValue (0 )
159- .shouldMatch ("cds,module.*Restored from archive: entry.0x.*name jdk.internal.vm.ci" );
160- } catch (RuntimeException re ) {
161- // JVMCI compile may not be available
162- oa .shouldHaveExitValue (1 )
163- .shouldContain ("Cannot use JVMCI compiler: No JVMCI compiler found" );
146+ if (isJVMCISupported ) {
147+ // dump an archive with JVMCI option which indirectly adds the
148+ // jdk.internal.vm.ci module using the --add-modules option
149+ archiveName = TestCommon .getNewArchiveName ("jvmci-module" );
150+ TestCommon .setCurrentArchiveName (archiveName );
151+ oa = TestCommon .dumpBaseArchive (
152+ archiveName ,
153+ loggingOption ,
154+ "-XX:+UnlockExperimentalVMOptions" ,
155+ "-XX:+EagerJVMCI" , "-XX:+UseJVMCICompiler" ,
156+ "-version" );
157+ oa .shouldHaveExitValue (0 );
158+
159+ // run with the JVMCI option
160+ oa = TestCommon .execCommon (
161+ loggingOption ,
162+ "-XX:+UnlockExperimentalVMOptions" ,
163+ "-XX:+EagerJVMCI" , "-XX:+UseJVMCICompiler" ,
164+ "-version" );
165+ try {
166+ oa .shouldHaveExitValue (0 )
167+ .shouldMatch ("cds,module.*Restored from archive: entry.0x.*name jdk.internal.vm.ci" );
168+ } catch (RuntimeException re ) {
169+ // JVMCI compile may not be available
170+ oa .shouldHaveExitValue (1 )
171+ .shouldContain ("Cannot use JVMCI compiler: No JVMCI compiler found" );
172+ }
164173 }
165174
166175 // dump an archive with multiple modules in -add-modules
0 commit comments