1javap(1) General Commands Manual javap(1)
2
3
4
6 javap - The Java Class File Disassembler
7
8 Disassembles class files.
9
11 javap [ options ] classes
12
13
15 The javap command disassembles one or more class files. Its output
16 depends on the options used. If no options are used, javap prints out
17 the package, protected, and public fields and methods of the classes
18 passed to it. javap prints its output to stdout.
19
20 options
21 Command-line options.
22
23 classes
24 List of one or more classes (separated by spaces) to be processed
25 for annotations (such as DocFooter.class). You may specify a
26 class that can be found in the class path, by its file name (for
27 example, /home/user/myproject/src/DocFooter.class), or with a URL
28 (for example, file:///home/user/myproject/src/DocFooter.class).
29
30
31 For example, compile the following class declaration:
32
33 import java.awt.*;
34 import java.applet.*;
35
36 public class DocFooter extends Applet {
37 String date;
38 String email;
39
40 public void init() {
41 resize(500,100);
42 date = getParameter("LAST_UPDATED");
43 email = getParameter("EMAIL");
44 }
45
46 public void paint(Graphics g) {
47 g.drawString(date + " by ",100, 15);
48 g.drawString(email,290,15);
49 }
50 }
51
52
53 The output from javap DocFooter.class yields:
54
55 Compiled from "DocFooter.java"
56 public class DocFooter extends java.applet.Applet {
57 java.lang.String date;
58 java.lang.String email;
59 public DocFooter();
60 public void init();
61 public void paint(java.awt.Graphics);
62 }
63
64
65 The output from javap -c DocFooter.class yields:
66
67 Compiled from "DocFooter.java"
68 public class DocFooter extends java.applet.Applet {
69 java.lang.String date;
70
71 java.lang.String email;
72
73 public DocFooter();
74 Code:
75 0: aload_0
76 1: invokespecial #1 // Method java/applet/Applet."<init>":()V
77 4: return
78
79 public void init();
80 Code:
81 0: aload_0
82 1: sipush 500
83 4: bipush 100
84 6: invokevirtual #2 // Method resize:(II)V
85 9: aload_0
86 10: aload_0
87 11: ldc #3 // String LAST_UPDATED
88 13: invokevirtual #4 // Method getParameter:(Ljava/lang/String;)Ljava/lang/String;
89 16: putfield #5 // Field date:Ljava/lang/String;
90 19: aload_0
91 20: aload_0
92 21: ldc #6 // String EMAIL
93 23: invokevirtual #4 // Method getParameter:(Ljava/lang/String;)Ljava/lang/String;
94 26: putfield #7 // Field email:Ljava/lang/String;
95 29: return
96
97 public void paint(java.awt.Graphics);
98 Code:
99 0: aload_1
100 1: new #8 // class java/lang/StringBuilder
101 4: dup
102 5: invokespecial #9 // Method java/lang/StringBuilder."<init>":()V
103 8: aload_0
104 9: getfield #5 // Field date:Ljava/lang/String;
105 12: invokevirtual #10 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
106 15: ldc #11 // String by
107 17: invokevirtual #10 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
108 20: invokevirtual #12 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
109 23: bipush 100
110 25: bipush 15
111 27: invokevirtual #13 // Method java/awt/Graphics.drawString:(Ljava/lang/String;II)V
112 30: aload_1
113 31: aload_0
114 32: getfield #7 // Field email:Ljava/lang/String;
115 35: sipush 290
116 38: bipush 15
117 40: invokevirtual #13 // Method java/awt/Graphics.drawString:(Ljava/lang/String;II)V
118 43: return
119 }
120
121
123 -help --help -?
124 Prints out help message for javap.
125
126 -version
127 Prints out version information.
128
129 -l Prints out line and local variable tables.
130
131 -public
132 Shows only public classes and members.
133
134 -protected
135 Shows only protected and public classes and members.
136
137 -package
138 Shows only package, protected, and public classes and members.
139 This is the default.
140
141 -private -p
142 Shows all classes and members.
143
144 -Jflag
145 Pass flag directly to the runtime system. Some examples:
146 javap -J-version
147 javap -J-Djava.security.manager -J-Djava.security.policy=MyPolicy MyClassName
148
149 -s Prints internal type signatures.
150
151 -sysinfo
152 Shows system information (path, size, date, MD5 hash) of the
153 class being processed.
154
155 -constants
156 Shows static final constants.
157
158 -c Prints out disassembled code, i.e., the instructions that com‐
159 prise the Java bytecodes, for each of the methods in the class.
160 These are documented in the Java Virtual Machine Specification @
161 http://java.sun.com/docs/books/vmspec/.
162
163 -verbose
164 Prints stack size, number of locals and args for methods.
165
166 -classpath path
167 Specifies the path javap uses to look up classes. Overrides the
168 default or the CLASSPATH environment variable if it is set.
169
170 -bootclasspath path
171 Specifies path from which to load bootstrap classes. By default,
172 the bootstrap classes are the classes implementing the core Java
173 platform located in jre/lib/rt.jar and several other jar files.
174
175 -extdirs dirs
176 Overrides location at which installed extensions are searched
177 for. The default location for extensions is the value of
178 java.ext.dirs.
179
180
182 javac(1), java(1), jdb(1), javah(1), javadoc(1)
183
184 16 Mar 2012 javap(1)