--- old/test/hotspot/jtreg/runtime/appcds/jigsaw/PatchModule/MismatchedPatchModule.java 2018-04-02 14:11:55.125437487 -0700 +++ new/test/hotspot/jtreg/runtime/appcds/jigsaw/PatchModule/MismatchedPatchModule.java 2018-04-02 14:11:54.837410347 -0700 @@ -62,71 +62,33 @@ JarBuilder.build("javanaming", "javax/naming/spi/NamingManager"); moduleJar = TestCommon.getTestJar("javanaming.jar"); - // Case 1: --patch-module specified for dump time and run time + // Case 1: --patch-module specified for dump time System.out.println("Case 1: --patch-module specified for dump time and run time"); OutputAnalyzer output = TestCommon.dump(null, TestCommon.list("javax/naming/spi/NamingManager"), "--patch-module=java.naming=" + moduleJar, "PatchMain", "javax.naming.spi.NamingManager"); - TestCommon.checkDump(output, "Loading classes to share"); + output.shouldHaveExitValue(1) + .shouldContain("Cannot use the following option when dumping the shared archive: --patch-module"); - // javax.naming.spi.NamingManager is not patched at runtime - TestCommon.run( - "-XX:+UnlockDiagnosticVMOptions", - "--patch-module=java.naming2=" + moduleJar, - "-Xlog:class+path=info", - "PatchMain", "javax.naming.spi.NamingManager") - .assertNormalExit(o -> o.shouldNotContain("I pass!")); - - // Case 2: --patch-module specified for dump time but not for run time - System.out.println("Case 2: --patch-module specified for dump time but not for run time"); + // Case 2: --patch-module specified for run time but not for dump time + System.out.println("Case 2: --patch-module specified for run time but not for dump time"); output = TestCommon.dump(null, TestCommon.list("javax/naming/spi/NamingManager"), - "--patch-module=java.naming=" + moduleJar, - "PatchMain", "javax.naming.spi.NamingManager"); - TestCommon.checkDump(output, "Loading classes to share"); - - // javax.naming.spi.NamingManager is not patched at runtime - TestCommon.run( - "-XX:+UnlockDiagnosticVMOptions", - "-Xlog:class+path=info", - "PatchMain", "javax.naming.spi.NamingManager") - .assertNormalExit(o -> o.shouldNotContain("I pass!")); - - // Case 3: --patch-module specified for run time but not for dump time - System.out.println("Case 3: --patch-module specified for run time but not for dump time"); - output = - TestCommon.dump(null, - TestCommon.list("javax/naming/spi/NamingManager"), - "PatchMain", "javax.naming.spi.NamingManager"); - TestCommon.checkDump(output, "Loading classes to share"); - - // javax.naming.spi.NamingManager is patched at runtime - TestCommon.run( - "-XX:+UnlockDiagnosticVMOptions", - "--patch-module=java.naming=" + moduleJar, - "-Xlog:class+path=info", - "PatchMain", "javax.naming.spi.NamingManager") - .assertNormalExit("I pass!"); - - // Case 4: mismatched --patch-module entry counts between dump time and run time - System.out.println("Case 4: mismatched --patch-module entry counts between dump time and run time"); - output = - TestCommon.dump(null, - TestCommon.list("javax/naming/spi/NamingManager"), - "--patch-module=java.naming=" + moduleJar, "PatchMain", "javax.naming.spi.NamingManager"); TestCommon.checkDump(output, "Loading classes to share"); // javax.naming.spi.NamingManager is patched at runtime - TestCommon.run( + output = TestCommon.execCommon( "-XX:+UnlockDiagnosticVMOptions", "--patch-module=java.naming=" + moduleJar, "--patch-module=java.naming2=" + moduleJar, "-Xlog:class+path=info", - "PatchMain", "javax.naming.spi.NamingManager") - .assertNormalExit("I pass!"); + "PatchMain", "javax.naming.spi.NamingManager"); + output.shouldHaveExitValue(0) + .shouldContain("CDS is disabled") + .shouldContain("I pass!"); } }