37 * @run main ArchivedModuleComboTest 38 */ 39 40 import java.io.File; 41 import java.nio.file.Files; 42 import java.nio.file.Path; 43 import java.nio.file.Paths; 44 import jdk.test.lib.process.OutputAnalyzer; 45 import jdk.test.lib.process.ProcessTools; 46 import sun.hotspot.WhiteBox; 47 48 public class ArchivedModuleComboTest { 49 public static void main(String[] args) throws Exception { 50 String wbJar = ClassFileInstaller.getJarPath("WhiteBox.jar"); 51 String use_whitebox_jar = "-Xbootclasspath/a:" + wbJar; 52 String appJar = ClassFileInstaller.getJarPath("app.jar"); 53 54 Path userDir = Paths.get(System.getProperty("user.dir")); 55 Path moduleDir = Files.createTempDirectory(userDir, "mods"); 56 57 // Dump without --module-path 58 OutputAnalyzer output = TestCommon.dump(appJar, 59 TestCommon.list("CheckArchivedModuleApp"), 60 use_whitebox_jar); 61 TestCommon.checkDump(output); 62 63 // Test case 1) 64 // - Dump without --module-path 65 // - Run from -cp only, archived boot layer module ModuleDescriptors 66 // should be used. 67 System.out.println("----------------------- Test case 1 ----------------------"); 68 output = TestCommon.exec(appJar, use_whitebox_jar, 69 "-XX:+UnlockDiagnosticVMOptions", 70 "-XX:+WhiteBoxAPI", 71 "CheckArchivedModuleApp", 72 "yes"); 73 TestCommon.checkExec(output); 74 75 // Test case 2) 76 // - Dump without --module-path 77 // - Run from -cp only, archived boot layer module ModuleDescriptors 78 // should be used with --show-module-resolution (requires resolution). 79 System.out.println("----------------------- Test case 2 ----------------------"); 80 output = TestCommon.exec(appJar, use_whitebox_jar, 81 "--show-module-resolution", 82 "-XX:+UnlockDiagnosticVMOptions", 83 "-XX:+WhiteBoxAPI", 84 "CheckArchivedModuleApp", 85 "yes"); 86 TestCommon.checkExec(output); 87 88 // Test case 3) 89 // - Dump without --module-path 90 // - Run with --module-path, archived boot layer module ModuleDescriptors 91 // should be disabled. 92 System.out.println("----------------------- Test case 3 ----------------------"); 93 output = TestCommon.exec(appJar, use_whitebox_jar, 94 "--module-path", 95 moduleDir.toString(), 96 "-XX:+UnlockDiagnosticVMOptions", 97 "-XX:+WhiteBoxAPI", 98 "CheckArchivedModuleApp", 99 "no"); 100 TestCommon.checkExec(output); 101 102 // Dump with --module-path specified (test case 4, 5). Use an 103 // empty directory as it's simple and still triggers the case 104 // where system module objects are not archived. 105 output = TestCommon.dump(appJar, 106 TestCommon.list("CheckArchivedModuleApp"), 107 "--module-path", 108 moduleDir.toString(), 109 use_whitebox_jar); 110 TestCommon.checkDump(output); 111 112 // Test case 4) 113 // - Dump with --module-path 114 // - Run from -cp only, no archived boot layer module ModuleDescriptors 115 // should be found. 116 System.out.println("----------------------- Test case 4 ----------------------"); 117 output = TestCommon.exec(appJar, use_whitebox_jar, 118 "-XX:+UnlockDiagnosticVMOptions", 119 "-XX:+WhiteBoxAPI", 120 "CheckArchivedModuleApp", 121 "no"); 122 TestCommon.checkExec(output); 123 124 // Test case 5) 125 // - Dump with --module-path 126 // - Run with --module-path, no archived boot layer module ModuleDescriptors 127 // should be found. 128 System.out.println("----------------------- Test case 5 ----------------------"); 129 output = TestCommon.exec(appJar, use_whitebox_jar, 130 "--module-path", 131 moduleDir.toString(), 132 "-XX:+UnlockDiagnosticVMOptions", 133 "-XX:+WhiteBoxAPI", 134 "CheckArchivedModuleApp", 135 "no"); 136 TestCommon.checkExec(output); 137 } 138 } | 37 * @run main ArchivedModuleComboTest 38 */ 39 40 import java.io.File; 41 import java.nio.file.Files; 42 import java.nio.file.Path; 43 import java.nio.file.Paths; 44 import jdk.test.lib.process.OutputAnalyzer; 45 import jdk.test.lib.process.ProcessTools; 46 import sun.hotspot.WhiteBox; 47 48 public class ArchivedModuleComboTest { 49 public static void main(String[] args) throws Exception { 50 String wbJar = ClassFileInstaller.getJarPath("WhiteBox.jar"); 51 String use_whitebox_jar = "-Xbootclasspath/a:" + wbJar; 52 String appJar = ClassFileInstaller.getJarPath("app.jar"); 53 54 Path userDir = Paths.get(System.getProperty("user.dir")); 55 Path moduleDir = Files.createTempDirectory(userDir, "mods"); 56 57 // 58 // Dump without --module-path, without --show-module-resolution 59 // 60 OutputAnalyzer output = TestCommon.dump(appJar, 61 TestCommon.list("CheckArchivedModuleApp"), 62 use_whitebox_jar); 63 TestCommon.checkDump(output); 64 65 // Test case 1) 66 // - Dump without --module-path, without --show-module-resolution 67 // - Run from -cp only and without --show-module-resolution 68 // + archived boot layer module ModuleDescriptors should be used 69 // + archived boot layer configuration should be used 70 System.out.println("----------------------- Test case 1 ----------------------"); 71 output = TestCommon.exec(appJar, use_whitebox_jar, 72 "-XX:+UnlockDiagnosticVMOptions", 73 "-XX:+WhiteBoxAPI", 74 "CheckArchivedModuleApp", 75 "yes", 76 "yes"); 77 TestCommon.checkExec(output); 78 79 // Test case 2) 80 // - Dump without --module-path, without --show-module-resolution 81 // - Run from -cp only and with --show-module-resolution 82 // + archived boot layer module ModuleDescriptors should be used with 83 // --show-module-resolution (requires resolution) 84 // + archived boot layer Configuration should not be disabled 85 System.out.println("----------------------- Test case 2 ----------------------"); 86 output = TestCommon.exec(appJar, use_whitebox_jar, 87 "--show-module-resolution", 88 "-XX:+UnlockDiagnosticVMOptions", 89 "-XX:+WhiteBoxAPI", 90 "CheckArchivedModuleApp", 91 "yes", 92 "no"); 93 TestCommon.checkExec(output, "root java.base jrt:/java.base"); 94 95 // Test case 3) 96 // - Dump without --module-path, without --show-module-resolution 97 // - Run with --module-path 98 // + archived boot layer module ModuleDescriptors should be disabled 99 // + archived boot layer Configuration should be disabled 100 System.out.println("----------------------- Test case 3 ----------------------"); 101 output = TestCommon.exec(appJar, use_whitebox_jar, 102 "--module-path", 103 moduleDir.toString(), 104 "-XX:+UnlockDiagnosticVMOptions", 105 "-XX:+WhiteBoxAPI", 106 "CheckArchivedModuleApp", 107 "no", 108 "no"); 109 TestCommon.checkExec(output); 110 111 // 112 // Dump with --module-path specified (test case 4, 5). Use an 113 // empty directory as it's simple and still triggers the case 114 // where system module objects are not archived. 115 // 116 output = TestCommon.dump(appJar, 117 TestCommon.list("CheckArchivedModuleApp"), 118 "--module-path", 119 moduleDir.toString(), 120 use_whitebox_jar); 121 TestCommon.checkDump(output); 122 123 // Test case 4) 124 // - Dump with --module-path 125 // - Run from -cp only, no archived boot layer module ModuleDescriptors 126 // and Configuration should be found. 127 System.out.println("----------------------- Test case 4 ----------------------"); 128 output = TestCommon.exec(appJar, use_whitebox_jar, 129 "-XX:+UnlockDiagnosticVMOptions", 130 "-XX:+WhiteBoxAPI", 131 "CheckArchivedModuleApp", 132 "no", 133 "no"); 134 TestCommon.checkExec(output); 135 136 // Test case 5) 137 // - Dump with --module-path 138 // - Run with --module-path, no archived boot layer module ModuleDescriptors 139 // and Configuration should be found. 140 System.out.println("----------------------- Test case 5 ----------------------"); 141 output = TestCommon.exec(appJar, use_whitebox_jar, 142 "--module-path", 143 moduleDir.toString(), 144 "-XX:+UnlockDiagnosticVMOptions", 145 "-XX:+WhiteBoxAPI", 146 "CheckArchivedModuleApp", 147 "no", 148 "no"); 149 TestCommon.checkExec(output); 150 151 // 152 // Dump without --module-path, with --show-module-resolution 153 // 154 output = TestCommon.dump(appJar, 155 TestCommon.list("CheckArchivedModuleApp"), 156 "--show-module-resolution", 157 use_whitebox_jar); 158 TestCommon.checkDump(output, "root java.base jrt:/java.base"); 159 160 // Test case 6) 161 // - Dump without --module-path, with --show-module-resolution 162 // - Run from -cp only and without --show-module-resolution 163 // + archived boot layer module ModuleDescriptors should be used 164 // + archived boot layer Configuration should be used 165 System.out.println("----------------------- Test case 6 ----------------------"); 166 output = TestCommon.exec(appJar, use_whitebox_jar, 167 "-XX:+UnlockDiagnosticVMOptions", 168 "-XX:+WhiteBoxAPI", 169 "CheckArchivedModuleApp", 170 "yes", 171 "yes"); 172 TestCommon.checkExec(output); 173 174 // Test case 7) 175 // - Dump without --module-path, with --show-module-resolution 176 // - Run from -cp only and with --show-module-resolution 177 // + archived boot layer module ModuleDescriptors should be used with 178 // --show-module-resolution (requires resolution) 179 // + archived boot layer Configuration should be disabled 180 System.out.println("----------------------- Test case 7 ----------------------"); 181 output = TestCommon.exec(appJar, use_whitebox_jar, 182 "--show-module-resolution", 183 "-XX:+UnlockDiagnosticVMOptions", 184 "-XX:+WhiteBoxAPI", 185 "CheckArchivedModuleApp", 186 "yes", 187 "no"); 188 TestCommon.checkExec(output, "root java.base jrt:/java.base"); 189 } 190 } |