< prev index next >

src/jdk.hotspot.agent/share/classes/sun/jvm/hotspot/SALauncher.java

Print this page

        

*** 109,146 **** return commonHelp(); } return launcherHelp(); } ! private static void buildAttachArgs(ArrayList<String> newArgs, ! String pid, String exe, String core) { ! if ((pid == null) && (exe == null)) { ! throw new IllegalArgumentException( ! "You have to set --pid or --exe."); } if (pid != null) { // Attach to live process if (exe != null) { ! throw new IllegalArgumentException( ! "Unnecessary argument: --exe"); } else if (core != null) { ! throw new IllegalArgumentException( ! "Unnecessary argument: --core"); } else if (!pid.matches("^\\d+$")) { ! throw new IllegalArgumentException("Invalid pid: " + pid); } newArgs.add(pid); ! } else { if (exe.length() == 0) { ! throw new IllegalArgumentException("You have to set --exe."); } newArgs.add(exe); if ((core == null) || (core.length() == 0)) { ! throw new IllegalArgumentException("You have to set --core."); } newArgs.add(core); } } --- 109,143 ---- return commonHelp(); } return launcherHelp(); } ! private static void buildAttachArgs(ArrayList<String> newArgs, String pid, ! String exe, String core, boolean allowEmpty) { ! if (!allowEmpty && (pid == null) && (exe == null)) { ! throw new SAGetoptException("You have to set --pid or --exe."); } if (pid != null) { // Attach to live process if (exe != null) { ! throw new SAGetoptException("Unnecessary argument: --exe"); } else if (core != null) { ! throw new SAGetoptException("Unnecessary argument: --core"); } else if (!pid.matches("^\\d+$")) { ! throw new SAGetoptException("Invalid pid: " + pid); } newArgs.add(pid); ! } else if (exe != null) { if (exe.length() == 0) { ! throw new SAGetoptException("You have to set --exe."); } newArgs.add(exe); if ((core == null) || (core.length() == 0)) { ! throw new SAGetoptException("You have to set --core."); } newArgs.add(core); } }
*** 168,178 **** pid = sg.getOptarg(); continue; } } ! buildAttachArgs(newArgs, pid, exe, core); CLHSDB.main(newArgs.toArray(new String[newArgs.size()])); } private static void runHSDB(String[] oldArgs) { SAGetopt sg = new SAGetopt(oldArgs); --- 165,175 ---- pid = sg.getOptarg(); continue; } } ! buildAttachArgs(newArgs, pid, exe, core, true); CLHSDB.main(newArgs.toArray(new String[newArgs.size()])); } private static void runHSDB(String[] oldArgs) { SAGetopt sg = new SAGetopt(oldArgs);
*** 197,207 **** pid = sg.getOptarg(); continue; } } ! buildAttachArgs(newArgs, pid, exe, core); HSDB.main(newArgs.toArray(new String[newArgs.size()])); } private static void runJSTACK(String[] oldArgs) { SAGetopt sg = new SAGetopt(oldArgs); --- 194,204 ---- pid = sg.getOptarg(); continue; } } ! buildAttachArgs(newArgs, pid, exe, core, true); HSDB.main(newArgs.toArray(new String[newArgs.size()])); } private static void runJSTACK(String[] oldArgs) { SAGetopt sg = new SAGetopt(oldArgs);
*** 235,245 **** newArgs.add("-l"); continue; } } ! buildAttachArgs(newArgs, pid, exe, core); JStack.main(newArgs.toArray(new String[newArgs.size()])); } private static void runJMAP(String[] oldArgs) { SAGetopt sg = new SAGetopt(oldArgs); --- 232,242 ---- newArgs.add("-l"); continue; } } ! buildAttachArgs(newArgs, pid, exe, core, false); JStack.main(newArgs.toArray(new String[newArgs.size()])); } private static void runJMAP(String[] oldArgs) { SAGetopt sg = new SAGetopt(oldArgs);
*** 285,295 **** newArgs.add("-finalizerinfo"); continue; } } ! buildAttachArgs(newArgs, pid, exe, core); JMap.main(newArgs.toArray(new String[newArgs.size()])); } private static void runJINFO(String[] oldArgs) { SAGetopt sg = new SAGetopt(oldArgs); --- 282,292 ---- newArgs.add("-finalizerinfo"); continue; } } ! buildAttachArgs(newArgs, pid, exe, core, false); JMap.main(newArgs.toArray(new String[newArgs.size()])); } private static void runJINFO(String[] oldArgs) { SAGetopt sg = new SAGetopt(oldArgs);
*** 323,333 **** newArgs.add("-sysprops"); continue; } } ! buildAttachArgs(newArgs, pid, exe, core); JInfo.main(newArgs.toArray(new String[newArgs.size()])); } private static void runJSNAP(String[] oldArgs) { SAGetopt sg = new SAGetopt(oldArgs); --- 320,330 ---- newArgs.add("-sysprops"); continue; } } ! buildAttachArgs(newArgs, pid, exe, core, false); JInfo.main(newArgs.toArray(new String[newArgs.size()])); } private static void runJSNAP(String[] oldArgs) { SAGetopt sg = new SAGetopt(oldArgs);
*** 352,362 **** pid = sg.getOptarg(); continue; } } ! buildAttachArgs(newArgs, pid, exe, core); JSnap.main(newArgs.toArray(new String[newArgs.size()])); } public static void main(String[] args) { // Provide a help --- 349,359 ---- pid = sg.getOptarg(); continue; } } ! buildAttachArgs(newArgs, pid, exe, core, false); JSnap.main(newArgs.toArray(new String[newArgs.size()])); } public static void main(String[] args) { // Provide a help
*** 410,421 **** if (args[0].equals("jsnap")) { runJSNAP(oldArgs); return; } ! throw new IllegalArgumentException("Unknown tool: " + args[0]); ! } catch (Exception e) { System.err.println(e.getMessage()); toolHelp(args[0]); } } } --- 407,418 ---- if (args[0].equals("jsnap")) { runJSNAP(oldArgs); return; } ! throw new SAGetoptException("Unknown tool: " + args[0]); ! } catch (SAGetoptException e) { System.err.println(e.getMessage()); toolHelp(args[0]); } } }
< prev index next >