< prev index next >

test/hotspot/jtreg/runtime/appcds/TestCommon.java

Print this page


 132             opts.archiveName = getCurrentArchiveName();
 133 
 134         cmd.add("-XX:SharedArchiveFile=" + opts.archiveName);
 135 
 136         if (opts.classList != null) {
 137             File classListFile = makeClassList(opts.classList);
 138             cmd.add("-XX:ExtraSharedClassListFile=" + classListFile.getPath());
 139         }
 140 
 141         for (String s : opts.suffix) cmd.add(s);
 142 
 143         String[] cmdLine = cmd.toArray(new String[cmd.size()]);
 144         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine);
 145         return executeAndLog(pb, "dump");
 146     }
 147 
 148 
 149     // Execute JVM using AppCDS archive with specified AppCDSOptions
 150     public static OutputAnalyzer runWithArchive(AppCDSOptions opts)
 151         throws Exception {






 152 
 153         ArrayList<String> cmd = new ArrayList<String>();
 154 
 155         for (String p : opts.prefix) cmd.add(p);
 156 
 157         cmd.add("-Xshare:" + opts.xShareMode);
 158         cmd.add("-showversion");
 159         cmd.add("-XX:SharedArchiveFile=" + getCurrentArchiveName());
 160         cmd.add("-Dtest.timeout.factor=" + timeoutFactor);
 161 
 162         if (opts.appJar != null) {
 163             cmd.add("-cp");
 164             cmd.add(opts.appJar);
 165         }
 166 
 167         for (String s : opts.suffix) cmd.add(s);
 168 
 169         String[] cmdLine = cmd.toArray(new String[cmd.size()]);
 170         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine);
 171         return executeAndLog(pb, "exec");
 172     }
 173 
 174 
 175     public static OutputAnalyzer execCommon(String... suffix) throws Exception {
 176         AppCDSOptions opts = (new AppCDSOptions());
 177         opts.addSuffix(suffix);
 178         return runWithArchive(opts);
 179     }
 180 
 181     // This is the new API for running a Java process with CDS enabled.
 182     // See comments in the CDSTestUtils.Result class for how to use this method.
 183     public static Result run(String... suffix) throws Exception {
 184         AppCDSOptions opts = (new AppCDSOptions());
 185         opts.addSuffix(suffix);
 186         return new Result(opts, runWithArchive(opts));
 187     }
 188 
 189     public static OutputAnalyzer exec(String appJar, String... suffix) throws Exception {
 190         AppCDSOptions opts = (new AppCDSOptions()).setAppJar(appJar);
 191         opts.addSuffix(suffix);
 192         return runWithArchive(opts);
 193     }
 194 
 195     public static Result runWithModules(String prefix[], String upgrademodulepath, String modulepath,
 196                                             String mid, String... testClassArgs) throws Exception {
 197         AppCDSOptions opts = makeModuleOptions(prefix, upgrademodulepath, modulepath,
 198                                                mid, testClassArgs);
 199         return new Result(opts, runWithArchive(opts));
 200     }
 201 
 202     public static OutputAnalyzer execAuto(String... suffix) throws Exception {
 203         AppCDSOptions opts = (new AppCDSOptions());
 204         opts.addSuffix(suffix).setXShareMode("auto");
 205         return runWithArchive(opts);






 206     }
 207 
 208     public static OutputAnalyzer execOff(String... suffix) throws Exception {
 209         AppCDSOptions opts = (new AppCDSOptions());
 210         opts.addSuffix(suffix).setXShareMode("off");
 211         return runWithArchive(opts);
 212     }
 213 
 214 
 215     private static AppCDSOptions makeModuleOptions(String prefix[], String upgrademodulepath, String modulepath,
 216                                             String mid, String testClassArgs[]) {
 217         AppCDSOptions opts = (new AppCDSOptions());
 218 
 219         opts.addPrefix(prefix);
 220         if (upgrademodulepath == null) {
 221             opts.addSuffix("-p", modulepath, "-m", mid);
 222         } else {
 223             opts.addSuffix("--upgrade-module-path", upgrademodulepath,
 224                            "-p", modulepath, "-m", mid);
 225         }




 132             opts.archiveName = getCurrentArchiveName();
 133 
 134         cmd.add("-XX:SharedArchiveFile=" + opts.archiveName);
 135 
 136         if (opts.classList != null) {
 137             File classListFile = makeClassList(opts.classList);
 138             cmd.add("-XX:ExtraSharedClassListFile=" + classListFile.getPath());
 139         }
 140 
 141         for (String s : opts.suffix) cmd.add(s);
 142 
 143         String[] cmdLine = cmd.toArray(new String[cmd.size()]);
 144         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine);
 145         return executeAndLog(pb, "dump");
 146     }
 147 
 148 
 149     // Execute JVM using AppCDS archive with specified AppCDSOptions
 150     public static OutputAnalyzer runWithArchive(AppCDSOptions opts)
 151         throws Exception {
 152       ProcessBuilder pb = createProcessBuilderWithArchive(opts);
 153       return executeAndLog(pb, "exec");
 154     }
 155 
 156     public static ProcessBuilder createProcessBuilderWithArchive(AppCDSOptions opts)
 157         throws Exception {
 158 
 159         ArrayList<String> cmd = new ArrayList<String>();
 160 
 161         for (String p : opts.prefix) cmd.add(p);
 162 
 163         cmd.add("-Xshare:" + opts.xShareMode);
 164         cmd.add("-showversion");
 165         cmd.add("-XX:SharedArchiveFile=" + getCurrentArchiveName());
 166         cmd.add("-Dtest.timeout.factor=" + timeoutFactor);
 167 
 168         if (opts.appJar != null) {
 169             cmd.add("-cp");
 170             cmd.add(opts.appJar);
 171         }
 172 
 173         for (String s : opts.suffix) cmd.add(s);
 174 
 175         String[] cmdLine = cmd.toArray(new String[cmd.size()]);
 176         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, cmdLine);
 177         return pb;
 178     }
 179 
 180 
 181     public static OutputAnalyzer execCommon(String... suffix) throws Exception {
 182         AppCDSOptions opts = (new AppCDSOptions());
 183         opts.addSuffix(suffix);
 184         return runWithArchive(opts);
 185     }
 186 
 187     // This is the new API for running a Java process with CDS enabled.
 188     // See comments in the CDSTestUtils.Result class for how to use this method.
 189     public static Result run(String... suffix) throws Exception {
 190         AppCDSOptions opts = (new AppCDSOptions());
 191         opts.addSuffix(suffix);
 192         return new Result(opts, runWithArchive(opts));
 193     }
 194 
 195     public static OutputAnalyzer exec(String appJar, String... suffix) throws Exception {
 196         AppCDSOptions opts = (new AppCDSOptions()).setAppJar(appJar);
 197         opts.addSuffix(suffix);
 198         return runWithArchive(opts);
 199     }
 200 
 201     public static Result runWithModules(String prefix[], String upgrademodulepath, String modulepath,
 202                                             String mid, String... testClassArgs) throws Exception {
 203         AppCDSOptions opts = makeModuleOptions(prefix, upgrademodulepath, modulepath,
 204                                                mid, testClassArgs);
 205         return new Result(opts, runWithArchive(opts));
 206     }
 207 
 208     public static OutputAnalyzer execAuto(String... suffix) throws Exception {
 209         AppCDSOptions opts = (new AppCDSOptions());
 210         opts.addSuffix(suffix).setXShareMode("auto");
 211         return runWithArchive(opts);
 212     }
 213 
 214     public static ProcessBuilder createProcessBuilderWithAutoArchive(String... suffix) throws Exception {
 215         AppCDSOptions opts = (new AppCDSOptions());
 216         opts.addSuffix(suffix).setXShareMode("auto");
 217         return createProcessBuilderWithArchive(opts);
 218     }
 219 
 220     public static OutputAnalyzer execOff(String... suffix) throws Exception {
 221         AppCDSOptions opts = (new AppCDSOptions());
 222         opts.addSuffix(suffix).setXShareMode("off");
 223         return runWithArchive(opts);
 224     }
 225 
 226 
 227     private static AppCDSOptions makeModuleOptions(String prefix[], String upgrademodulepath, String modulepath,
 228                                             String mid, String testClassArgs[]) {
 229         AppCDSOptions opts = (new AppCDSOptions());
 230 
 231         opts.addPrefix(prefix);
 232         if (upgrademodulepath == null) {
 233             opts.addSuffix("-p", modulepath, "-m", mid);
 234         } else {
 235             opts.addSuffix("--upgrade-module-path", upgrademodulepath,
 236                            "-p", modulepath, "-m", mid);
 237         }


< prev index next >