--- old/test/tools/launcher/modules/dryrun/DryRunTest.java 2016-06-30 22:03:32.000000000 -0700 +++ new/test/tools/launcher/modules/dryrun/DryRunTest.java 2016-06-30 22:03:31.000000000 -0700 @@ -60,6 +60,7 @@ // the module main class private static final String MAIN_CLASS = "jdk.test.Main"; + private static final String MAIN_CLINIT_CLASS = "jdk.test.MainWithClinit"; @BeforeTest @@ -99,13 +100,27 @@ 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 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 {