56 57 ClassFileInstaller.writeClassToDisk("javax/naming/myspi/NamingManager", 58 InMemoryJavaCompiler.compile("javax.naming.myspi.NamingManager", source, "--patch-module=java.naming"), 59 System.getProperty("test.classes")); 60 61 // Build the jar file that will be used for the module "java.naming". 62 JarBuilder.build("javanaming", "javax/naming/myspi/NamingManager"); 63 moduleJar = TestCommon.getTestJar("javanaming.jar"); 64 65 System.out.println("Test dumping with --patch-module"); 66 OutputAnalyzer output = 67 TestCommon.dump(null, 68 TestCommon.list("javax/naming/myspi/NamingManager"), 69 "--patch-module=java.naming=" + moduleJar, 70 "-Xlog:class+load", 71 "-Xlog:class+path=info", 72 "PatchMain", "javax.naming.myspi.NamingManager"); 73 output.shouldHaveExitValue(1) 74 .shouldContain("Cannot use the following option when dumping the shared archive: --patch-module"); 75 76 output = TestCommon.execCommon( 77 "-XX:+UnlockDiagnosticVMOptions", 78 "--patch-module=java.naming=" + moduleJar, 79 "-Xlog:class+load", 80 "-Xlog:class+path=info", 81 "PatchMain", "javax.naming.myspi.NamingManager"); 82 output.shouldHaveExitValue(0) 83 .shouldContain("CDS is disabled") 84 .shouldContain("I pass!"); 85 } 86 } | 56 57 ClassFileInstaller.writeClassToDisk("javax/naming/myspi/NamingManager", 58 InMemoryJavaCompiler.compile("javax.naming.myspi.NamingManager", source, "--patch-module=java.naming"), 59 System.getProperty("test.classes")); 60 61 // Build the jar file that will be used for the module "java.naming". 62 JarBuilder.build("javanaming", "javax/naming/myspi/NamingManager"); 63 moduleJar = TestCommon.getTestJar("javanaming.jar"); 64 65 System.out.println("Test dumping with --patch-module"); 66 OutputAnalyzer output = 67 TestCommon.dump(null, 68 TestCommon.list("javax/naming/myspi/NamingManager"), 69 "--patch-module=java.naming=" + moduleJar, 70 "-Xlog:class+load", 71 "-Xlog:class+path=info", 72 "PatchMain", "javax.naming.myspi.NamingManager"); 73 output.shouldHaveExitValue(1) 74 .shouldContain("Cannot use the following option when dumping the shared archive: --patch-module"); 75 76 TestCommon.run( 77 "-XX:+UnlockDiagnosticVMOptions", 78 "--patch-module=java.naming=" + moduleJar, 79 "-Xlog:class+load", 80 "-Xlog:class+path=info", 81 "PatchMain", "javax.naming.myspi.NamingManager") 82 .assertSilentlyDisabledCDS(out -> { 83 out.shouldHaveExitValue(0) 84 .shouldContain("I pass!"); 85 }); 86 } 87 } |