< prev index next >

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

Print this page




  92     }
  93 
  94 
  95     // Create AppCDS archive using most common args - convenience method
  96     // Legacy name preserved for compatibility
  97     public static OutputAnalyzer dump(String appJar, String appClasses[],
  98                                                String... suffix) throws Exception {
  99         return createArchive(appJar, appClasses, suffix);
 100     }
 101 
 102 
 103     // Create AppCDS archive using most common args - convenience method
 104     public static OutputAnalyzer createArchive(String appJar, String appClasses[],
 105                                                String... suffix) throws Exception {
 106         AppCDSOptions opts = (new AppCDSOptions()).setAppJar(appJar)
 107             .setAppClasses(appClasses);
 108         opts.addSuffix(suffix);
 109         return createArchive(opts);
 110     }
 111 
 112     // If you use -XX:+UseAppCDS or -XX:-UseAppCDS in your JVM command-line, call this method
 113     // to wrap the arguments.
 114     public static String[] makeCommandLineForAppCDS(String... args) throws Exception {
 115         return args;
 116     }
 117 
 118     // Create AppCDS archive using appcds options
 119     public static OutputAnalyzer createArchive(AppCDSOptions opts)
 120         throws Exception {
 121 
 122         ArrayList<String> cmd = new ArrayList<String>();
 123         File classList = makeClassList(opts.appClasses);
 124         startNewArchiveName();
 125 
 126         for (String p : opts.prefix) cmd.add(p);
 127 
 128         if (opts.appJar != null) {
 129             cmd.add("-cp");
 130             cmd.add(opts.appJar);
 131         } else {
 132             cmd.add("-cp");
 133             cmd.add("\"\"");
 134         }
 135 
 136         cmd.add("-Xshare:dump");
 137         cmd.add("-Xlog:cds,cds+hashtables");
 138         cmd.add("-XX:+UseAppCDS");
 139         cmd.add("-XX:ExtraSharedClassListFile=" + classList.getPath());
 140 
 141         if (opts.archiveName == null)
 142             opts.archiveName = getCurrentArchiveName();
 143 
 144         cmd.add("-XX:SharedArchiveFile=" + opts.archiveName);
 145 
 146         for (String s : opts.suffix) cmd.add(s);
 147 
 148         String[] cmdLine = cmd.toArray(new String[cmd.size()]);
 149         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, makeCommandLineForAppCDS(cmdLine));
 150         return executeAndLog(pb, "dump");
 151     }
 152 
 153 
 154     // Execute JVM using AppCDS archive with specified AppCDSOptions
 155     public static OutputAnalyzer runWithArchive(AppCDSOptions opts)
 156         throws Exception {
 157 
 158         ArrayList<String> cmd = new ArrayList<String>();
 159 
 160         for (String p : opts.prefix) cmd.add(p);
 161 
 162         cmd.add("-Xshare:" + opts.xShareMode);
 163         cmd.add("-XX:+UseAppCDS");
 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, makeCommandLineForAppCDS(cmdLine));
 177         return executeAndLog(pb, "exec");
 178     }
 179 
 180 
 181     public static OutputAnalyzer execCommon(String... suffix) throws Exception {
 182         AppCDSOptions opts = (new AppCDSOptions());
 183         opts.addSuffix(suffix);




  92     }
  93 
  94 
  95     // Create AppCDS archive using most common args - convenience method
  96     // Legacy name preserved for compatibility
  97     public static OutputAnalyzer dump(String appJar, String appClasses[],
  98                                                String... suffix) throws Exception {
  99         return createArchive(appJar, appClasses, suffix);
 100     }
 101 
 102 
 103     // Create AppCDS archive using most common args - convenience method
 104     public static OutputAnalyzer createArchive(String appJar, String appClasses[],
 105                                                String... suffix) throws Exception {
 106         AppCDSOptions opts = (new AppCDSOptions()).setAppJar(appJar)
 107             .setAppClasses(appClasses);
 108         opts.addSuffix(suffix);
 109         return createArchive(opts);
 110     }
 111 


 112     public static String[] makeCommandLineForAppCDS(String... args) throws Exception {
 113         return args;
 114     }
 115 
 116     // Create AppCDS archive using appcds options
 117     public static OutputAnalyzer createArchive(AppCDSOptions opts)
 118         throws Exception {
 119 
 120         ArrayList<String> cmd = new ArrayList<String>();
 121         File classList = makeClassList(opts.appClasses);
 122         startNewArchiveName();
 123 
 124         for (String p : opts.prefix) cmd.add(p);
 125 
 126         if (opts.appJar != null) {
 127             cmd.add("-cp");
 128             cmd.add(opts.appJar);
 129         } else {
 130             cmd.add("-cp");
 131             cmd.add("\"\"");
 132         }
 133 
 134         cmd.add("-Xshare:dump");
 135         cmd.add("-Xlog:cds,cds+hashtables");

 136         cmd.add("-XX:ExtraSharedClassListFile=" + classList.getPath());
 137 
 138         if (opts.archiveName == null)
 139             opts.archiveName = getCurrentArchiveName();
 140 
 141         cmd.add("-XX:SharedArchiveFile=" + opts.archiveName);
 142 
 143         for (String s : opts.suffix) cmd.add(s);
 144 
 145         String[] cmdLine = cmd.toArray(new String[cmd.size()]);
 146         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, makeCommandLineForAppCDS(cmdLine));
 147         return executeAndLog(pb, "dump");
 148     }
 149 
 150 
 151     // Execute JVM using AppCDS archive with specified AppCDSOptions
 152     public static OutputAnalyzer runWithArchive(AppCDSOptions opts)
 153         throws Exception {
 154 
 155         ArrayList<String> cmd = new ArrayList<String>();
 156 
 157         for (String p : opts.prefix) cmd.add(p);
 158 
 159         cmd.add("-Xshare:" + opts.xShareMode);

 160         cmd.add("-showversion");
 161         cmd.add("-XX:SharedArchiveFile=" + getCurrentArchiveName());
 162         cmd.add("-Dtest.timeout.factor=" + timeoutFactor);
 163 
 164         if (opts.appJar != null) {
 165             cmd.add("-cp");
 166             cmd.add(opts.appJar);
 167         }
 168 
 169         for (String s : opts.suffix) cmd.add(s);
 170 
 171         String[] cmdLine = cmd.toArray(new String[cmd.size()]);
 172         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(true, makeCommandLineForAppCDS(cmdLine));
 173         return executeAndLog(pb, "exec");
 174     }
 175 
 176 
 177     public static OutputAnalyzer execCommon(String... suffix) throws Exception {
 178         AppCDSOptions opts = (new AppCDSOptions());
 179         opts.addSuffix(suffix);


< prev index next >