24 */
25
26 package sun.tools.jinfo;
27
28 import java.lang.reflect.Method;
29 import java.util.Arrays;
30 import java.io.IOException;
31 import java.io.InputStream;
32
33 import com.sun.tools.attach.VirtualMachine;
34
35 import sun.tools.attach.HotSpotVirtualMachine;
36
37 /*
38 * This class is the main class for the JInfo utility. It parses its arguments
39 * and decides if the command should be satisfied using the VM attach mechanism
40 * or an SA tool.
41 */
42 public class JInfo {
43
44 public static void main(String[] args) throws Exception {
45 if (args.length == 0) {
46 usage(1); // no arguments
47 }
48
49 // First determine if we should launch SA or not
50 boolean useSA = false;
51 if (args[0].equals("-F")) {
52 // delete the -F
53 args = Arrays.copyOfRange(args, 1, args.length);
54 useSA = true;
55 } else if (args[0].equals("-flags")
56 || args[0].equals("-sysprops"))
57 {
58 if (args.length == 2) {
59 if (!args[1].matches("[0-9]+")) {
60 // If args[1] doesn't parse to a number then
61 // it must be the SA debug server
62 // (otherwise it is the pid)
63 useSA = true;
101 pid = args[2];
102 flag(pid, option);
103 break;
104 case "-flags":
105 if (args.length != 2) {
106 usage(1);
107 }
108 pid = args[1];
109 flags(pid);
110 break;
111 case "-sysprops":
112 if (args.length != 2) {
113 usage(1);
114 }
115 pid = args[1];
116 sysprops(pid);
117 break;
118 case "-help":
119 case "-h":
120 usage(0);
121 default:
122 if (args.length == 1) {
123 // no flags specified, we do -sysprops and -flags
124 pid = args[0];
125 sysprops(pid);
126 System.out.println();
127 flags(pid);
128 } else {
129 usage(1);
130 }
131 }
132 }
133 }
134
135 // Invoke SA tool with the given arguments
136 private static void runTool(String args[]) throws Exception {
137 String tool = "sun.jvm.hotspot.tools.JInfo";
138 // Tool not available on this platform.
139 Class<?> c = loadClass(tool);
140 if (c == null) {
|
24 */
25
26 package sun.tools.jinfo;
27
28 import java.lang.reflect.Method;
29 import java.util.Arrays;
30 import java.io.IOException;
31 import java.io.InputStream;
32
33 import com.sun.tools.attach.VirtualMachine;
34
35 import sun.tools.attach.HotSpotVirtualMachine;
36
37 /*
38 * This class is the main class for the JInfo utility. It parses its arguments
39 * and decides if the command should be satisfied using the VM attach mechanism
40 * or an SA tool.
41 */
42 public class JInfo {
43
44 @SuppressWarnings("fallthrough")
45 public static void main(String[] args) throws Exception {
46 if (args.length == 0) {
47 usage(1); // no arguments
48 }
49
50 // First determine if we should launch SA or not
51 boolean useSA = false;
52 if (args[0].equals("-F")) {
53 // delete the -F
54 args = Arrays.copyOfRange(args, 1, args.length);
55 useSA = true;
56 } else if (args[0].equals("-flags")
57 || args[0].equals("-sysprops"))
58 {
59 if (args.length == 2) {
60 if (!args[1].matches("[0-9]+")) {
61 // If args[1] doesn't parse to a number then
62 // it must be the SA debug server
63 // (otherwise it is the pid)
64 useSA = true;
102 pid = args[2];
103 flag(pid, option);
104 break;
105 case "-flags":
106 if (args.length != 2) {
107 usage(1);
108 }
109 pid = args[1];
110 flags(pid);
111 break;
112 case "-sysprops":
113 if (args.length != 2) {
114 usage(1);
115 }
116 pid = args[1];
117 sysprops(pid);
118 break;
119 case "-help":
120 case "-h":
121 usage(0);
122 // Fall through
123 default:
124 if (args.length == 1) {
125 // no flags specified, we do -sysprops and -flags
126 pid = args[0];
127 sysprops(pid);
128 System.out.println();
129 flags(pid);
130 } else {
131 usage(1);
132 }
133 }
134 }
135 }
136
137 // Invoke SA tool with the given arguments
138 private static void runTool(String args[]) throws Exception {
139 String tool = "sun.jvm.hotspot.tools.JInfo";
140 // Tool not available on this platform.
141 Class<?> c = loadClass(tool);
142 if (c == null) {
|