< prev index next >
test/tools/launcher/modules/dryrun/DryRunTest.java
Print this page
@@ -58,10 +58,11 @@
private static final String TEST_MODULE = "test";
private static final String M_MODULE = "m";
// the module main class
private static final String MAIN_CLASS = "jdk.test.Main";
+ private static final String MAIN_CLINIT_CLASS = "jdk.test.MainWithClinit";
@BeforeTest
public void compileTestModule() throws Exception {
@@ -97,17 +98,31 @@
*/
public void testModule() throws Exception {
String dir = MODS_DIR.toString();
String mid = TEST_MODULE + "/" + MAIN_CLASS;
- // java -modulepath mods -module $TESTMODULE/$MAINCLASS
// no resolution failure
int exitValue = exec("--dry-run", "-modulepath", dir, "-m", mid);
assertTrue(exitValue == 0);
}
/**
+ * Test dryrun that does not invoke <clinit> of the main class
+ */
+ public void testMainClinit() throws Exception {
+ String dir = MODS_DIR.toString();
+ String mid = TEST_MODULE + "/" + MAIN_CLINIT_CLASS;
+
+ int exitValue = exec("--dry-run", "-modulepath", dir, "-m", mid);
+ assertTrue(exitValue == 0);
+
+ // expect the test to fail if main class is initialized
+ exitValue = exec("-modulepath", dir, "-m", mid);
+ assertTrue(exitValue != 0);
+ }
+
+ /**
* Test non-existence module in -addmods
*/
public void testNonExistAddModules() throws Exception {
String dir = MODS_DIR.toString();
String mid = TEST_MODULE + "/" + MAIN_CLASS;
< prev index next >