< prev index next >

src/jdk.jcmd/share/classes/sun/tools/jmap/JMap.java

Print this page




 169                UnsupportedEncodingException {
 170         String liveopt = "-all";
 171         String filename = null;
 172         String parallel = null;
 173         String subopts[] = options.split(",");
 174         boolean set_all = false;
 175         boolean set_live = false;
 176 
 177         for (int i = 0; i < subopts.length; i++) {
 178             String subopt = subopts[i];
 179             if (subopt.equals("") || subopt.equals("all")) {
 180                 set_all = true;
 181                 liveopt = "-all";
 182             } else if (subopt.equals("live")) {
 183                 // Add '-' for compatibility.
 184                 set_live = true;
 185                 liveopt = "-live";
 186             } else if (subopt.startsWith("file=")) {
 187                 filename = parseFileName(subopt);
 188                 if (filename == null) {

 189                     usage(1); // invalid options or no filename
 190                 }
 191             } else if (subopt.startsWith("parallel=")) {
 192                parallel = subopt.substring("parallel=".length());
 193                if (parallel == null) {

 194                     usage(1);
 195                }
 196             } else {

 197                 usage(1);
 198             }
 199         }

 200         if (set_live && set_all) {
 201             usage(1);
 202         }
 203 
 204         System.out.flush();
 205         // inspectHeap is not the same as jcmd GC.class_histogram
 206         executeCommandForPid(pid, "inspectheap", liveopt, filename, parallel);
 207     }
 208 
 209     private static void dump(String pid, String options)
 210         throws AttachNotSupportedException, IOException,
 211                UnsupportedEncodingException {
 212 
 213         String subopts[] = options.split(",");
 214         String filename = null;
 215         String liveopt = "-all";
 216 
 217         for (int i = 0; i < subopts.length; i++) {
 218             String subopt = subopts[i];
 219             if (subopt.equals("live")) {
 220                 liveopt = "-live";
 221             } else if (subopt.startsWith("file=")) {
 222                 filename = parseFileName(subopt);
 223             }
 224         }
 225 
 226         if (filename == null) {

 227             usage(1);  // invalid options or no filename
 228         }
 229 
 230         // dumpHeap is not the same as jcmd GC.heap_dump
 231         executeCommandForPid(pid, "dumpheap", filename, liveopt);
 232     }
 233 
 234     private static void checkForUnsupportedOptions(String[] args) {
 235         // Check arguments for -F, -m, and non-numeric value
 236         // and warn the user that SA is not supported anymore
 237 
 238         int paramCount = 0;
 239 
 240         for (String s : args) {
 241             if (s.equals("-F")) {
 242                 SAOptionError("-F option used");
 243             }
 244 
 245             if (s.equals("-heap")) {
 246                 SAOptionError("-heap option used");




 169                UnsupportedEncodingException {
 170         String liveopt = "-all";
 171         String filename = null;
 172         String parallel = null;
 173         String subopts[] = options.split(",");
 174         boolean set_all = false;
 175         boolean set_live = false;
 176 
 177         for (int i = 0; i < subopts.length; i++) {
 178             String subopt = subopts[i];
 179             if (subopt.equals("") || subopt.equals("all")) {
 180                 set_all = true;
 181                 liveopt = "-all";
 182             } else if (subopt.equals("live")) {
 183                 // Add '-' for compatibility.
 184                 set_live = true;
 185                 liveopt = "-live";
 186             } else if (subopt.startsWith("file=")) {
 187                 filename = parseFileName(subopt);
 188                 if (filename == null) {
 189                     System.err.println("Fail at processing option '" + subopt +"'");
 190                     usage(1); // invalid options or no filename
 191                 }
 192             } else if (subopt.startsWith("parallel=")) {
 193                parallel = subopt.substring("parallel=".length());
 194                if (parallel == null) {
 195                     System.err.println("Fail at processing option '" + subopt + "'");
 196                     usage(1);
 197                }
 198             } else {
 199                 System.err.println("Fail at processing option '" + subopt + "'");
 200                 usage(1);
 201             }
 202         }
 203         // backward compitable: if both "live" and "all" set, use "live".
 204         if (set_live && set_all) {
 205            liveopt = "-live";
 206         }

 207         System.out.flush();
 208         // inspectHeap is not the same as jcmd GC.class_histogram
 209         executeCommandForPid(pid, "inspectheap", liveopt, filename, parallel);
 210     }
 211 
 212     private static void dump(String pid, String options)
 213         throws AttachNotSupportedException, IOException,
 214                UnsupportedEncodingException {
 215 
 216         String subopts[] = options.split(",");
 217         String filename = null;
 218         String liveopt = "-all";
 219 
 220         for (int i = 0; i < subopts.length; i++) {
 221             String subopt = subopts[i];
 222             if (subopt.equals("live")) {
 223                 liveopt = "-live";
 224             } else if (subopt.startsWith("file=")) {
 225                 filename = parseFileName(subopt);
 226             }
 227         }
 228 
 229         if (filename == null) {
 230             System.err.println("Fail at processing option 'file'");
 231             usage(1);  // invalid options or no filename
 232         }
 233 
 234         // dumpHeap is not the same as jcmd GC.heap_dump
 235         executeCommandForPid(pid, "dumpheap", filename, liveopt);
 236     }
 237 
 238     private static void checkForUnsupportedOptions(String[] args) {
 239         // Check arguments for -F, -m, and non-numeric value
 240         // and warn the user that SA is not supported anymore
 241 
 242         int paramCount = 0;
 243 
 244         for (String s : args) {
 245             if (s.equals("-F")) {
 246                 SAOptionError("-F option used");
 247             }
 248 
 249             if (s.equals("-heap")) {
 250                 SAOptionError("-heap option used");


< prev index next >