1 |
/* gnu.classpath.tools.JavapMain |
/* |
2 |
Copyright (C) 2001 Free Software Foundation, Inc. |
* gnu.classpath.tools.JavapMain Copyright (C) 2001 Free Software Foundation, |
3 |
|
* Inc. |
4 |
This file is part of GNU Classpath. |
* |
5 |
|
* This file is part of GNU Classpath. |
6 |
GNU Classpath is free software; you can redistribute it and/or modify |
* |
7 |
it under the terms of the GNU General Public License as published by |
* GNU Classpath is free software; you can redistribute it and/or modify it |
8 |
the Free Software Foundation; either version 2, or (at your option) |
* under the terms of the GNU General Public License as published by the Free |
9 |
any later version. |
* Software Foundation; either version 2, or (at your option) any later version. |
10 |
|
* |
11 |
GNU Classpath is distributed in the hope that it will be useful, but |
* GNU Classpath is distributed in the hope that it will be useful, but WITHOUT |
12 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more |
14 |
General Public License for more details. |
* details. |
15 |
|
* |
16 |
You should have received a copy of the GNU General Public License |
* You should have received a copy of the GNU General Public License along with |
17 |
along with GNU Classpath; see the file COPYING. If not, write to the |
* GNU Classpath; see the file COPYING. If not, write to the Free Software |
18 |
Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
19 |
02111-1307 USA. */ |
*/ |
|
|
|
20 |
package gnu.classpath.tools; |
package gnu.classpath.tools; |
21 |
|
|
22 |
public class JavapMain |
public class JavapMain |
29 |
} |
} |
30 |
|
|
31 |
/** |
/** |
32 |
* Parses the arguments to determine what this program |
* Parses the arguments to determine what this program should do. |
|
* should do. |
|
33 |
*/ |
*/ |
34 |
private static Javaph parseArguments(String s[]) |
private static Javaph parseArguments(String s[]) |
35 |
{ |
{ |
36 |
Javaph p = new Javaph(); |
Javaph p = new Javaph(); |
|
|
|
37 |
if (s.length == 0) |
if (s.length == 0) |
38 |
usage(); |
usage(); |
|
|
|
39 |
p.setJavap(true); |
p.setJavap(true); |
|
|
|
40 |
boolean processArguments = true; |
boolean processArguments = true; |
41 |
int i = 0; |
int i = 0; |
42 |
while (processArguments) |
while (processArguments) |
|
{ |
|
|
if (s[i].equals("-c")) |
|
|
p.setDisassemble(true); |
|
|
else if (s[i].equals("-classpath")) |
|
|
p.setClasspath(s[++i]); |
|
|
else if (s[i].equals("-help")) |
|
|
usage(); |
|
|
else if (s[i].equals("-l")) |
|
|
{ |
|
|
p.setPrintLineNumbers(true); |
|
|
p.setPrintLocalVariables(true); |
|
|
} |
|
|
else if (s[i].equals("-public")) |
|
|
p.setShowPublic(true); |
|
|
else if (s[i].equals("-protected")) |
|
|
p.setShowProtected(true); |
|
|
else if (s[i].equals("-private")) |
|
|
p.setShowPrivate(true); |
|
|
else if (s[i].equals("-s")) |
|
|
p.setPrintSignatures(true); |
|
|
else if (s[i].equals("-verbose")) |
|
|
{ |
|
|
p.setPrintStackSize(true); |
|
|
p.setPrintNumberLocals(true); |
|
|
p.setPrintMethodArguments(true); |
|
|
} |
|
|
else if (s[i].startsWith("-")) |
|
43 |
{ |
{ |
44 |
System.err.println("Invalid flag: " + s[i]); |
if (s[i].equals("-c")) |
45 |
usage(); |
p.setDisassemble(true); |
46 |
|
else if (s[i].equals("-classpath")) |
47 |
|
p.setClasspath(s[++i]); |
48 |
|
else if (s[i].equals("-help")) |
49 |
|
usage(); |
50 |
|
else if (s[i].equals("-l")) |
51 |
|
{ |
52 |
|
p.setPrintLineNumbers(true); |
53 |
|
p.setPrintLocalVariables(true); |
54 |
|
} |
55 |
|
else if (s[i].equals("-public")) |
56 |
|
p.setShowPublic(true); |
57 |
|
else if (s[i].equals("-protected")) |
58 |
|
p.setShowProtected(true); |
59 |
|
else if (s[i].equals("-private")) |
60 |
|
p.setShowPrivate(true); |
61 |
|
else if (s[i].equals("-s")) |
62 |
|
p.setPrintSignatures(true); |
63 |
|
else if (s[i].equals("-verbose")) |
64 |
|
{ |
65 |
|
p.setPrintStackSize(true); |
66 |
|
p.setPrintNumberLocals(true); |
67 |
|
p.setPrintMethodArguments(true); |
68 |
|
} |
69 |
|
else if (s[i].startsWith("-")) |
70 |
|
{ |
71 |
|
System.err.println("Invalid flag: " + s[i]); |
72 |
|
usage(); |
73 |
|
} |
74 |
|
else |
75 |
|
break; |
76 |
|
i++; |
77 |
} |
} |
|
else |
|
|
break; |
|
|
|
|
|
i++; |
|
|
} |
|
|
|
|
78 |
String[] c = new String[s.length - i]; |
String[] c = new String[s.length - i]; |
79 |
if (c.length == 0) |
if (c.length == 0) |
80 |
usage(); |
usage(); |
|
|
|
81 |
for (int j = i; j < s.length; j++) |
for (int j = i; j < s.length; j++) |
82 |
c[j - i] = s[j]; |
c[j - i] = s[j]; |
|
|
|
83 |
p.setClasses(c); |
p.setClasses(c); |
|
|
|
84 |
return p; |
return p; |
85 |
} |
} |
86 |
|
|
93 |
System.out.println("Provide information about the given classes."); |
System.out.println("Provide information about the given classes."); |
94 |
System.out.println(""); |
System.out.println(""); |
95 |
System.out.println(" -c Disassemble the code"); |
System.out.println(" -c Disassemble the code"); |
96 |
System.out.println(" -classpath PATH Specify where to find user class files"); |
System.out |
97 |
|
.println(" -classpath PATH Specify where to find user class files"); |
98 |
System.out.println(" -help Print this usage message"); |
System.out.println(" -help Print this usage message"); |
99 |
System.out.println(" -l Print line number and local variable tables"); |
System.out |
100 |
System.out.println(" -public Show only public classes and members"); |
.println(" -l Print line number and local variable tables"); |
101 |
System.out.println( |
System.out |
102 |
" -protected Show public and protected classes and members"); |
.println(" -public Show only public classes and members"); |
103 |
System.out.println(" -private Show all classes and members"); |
System.out |
104 |
System.out.println(" -s Print internal type signatures"); |
.println(" -protected Show public and protected classes and members"); |
105 |
System.out.println( |
System.out |
106 |
" -verbose Print stack size, number of locals and args for methods"); |
.println(" -private Show all classes and members"); |
107 |
|
System.out |
108 |
|
.println(" -s Print internal type signatures"); |
109 |
|
System.out |
110 |
|
.println(" -verbose Print stack size, number of locals and args for methods"); |
111 |
System.exit(0); |
System.exit(0); |
112 |
} |
} |
113 |
} |
} |