1JAVAP(1) JDK Commands JAVAP(1)
2
3
4
6 javap - disassemble one or more class files
7
9 javap [options] classes...
10
11 options
12 Specifies the command-line options. See Options for javap.
13
14 classes
15 Specifies one or more classes separated by spaces to be pro‐
16 cessed for annotations. You can specify a class that can be
17 found in the class path by its file name, URL, or by its fully
18 qualified class name.
19
20 Examples:
21
22 path/to/MyClass.class
23
24 jar:file:///path/to/MyJar.jar!/mypkg/MyClass.class
25
26 java.lang.Object
27
29 The javap command disassembles one or more class files. The output de‐
30 pends on the options used. When no options are used, the javap command
31 prints the protected and public fields, and methods of the classes
32 passed to it.
33
34 The javap command isn't multirelease JAR aware. Using the class path
35 form of the command results in viewing the base entry in all JAR files,
36 multirelease or not. Using the URL form, you can use the URL form of
37 an argument to specify a specific version of a class to be disassem‐
38 bled.
39
40 The javap command prints its output to stdout.
41
42 Note:
43
44 In tools that support -- style options, the GNU-style options can use
45 the equal sign (=) instead of a white space to separate the name of an
46 option from its value.
47
49 -help, --help , or -?
50 Prints a help message for the javap command.
51
52 -version
53 Prints release information.
54
55 -verbose or -v
56 Prints additional information about the selected class.
57
58 -l Prints line and local variable tables.
59
60 -public
61 Shows only public classes and members.
62
63 -protected
64 Shows only protected and public classes and members.
65
66 -package
67 Shows package/protected/public classes and members (default).
68
69 -private or -p
70 Shows all classes and members.
71
72 -c Prints disassembled code, for example, the instructions that
73 comprise the Java bytecodes, for each of the methods in the
74 class.
75
76 -s Prints internal type signatures.
77
78 -sysinfo
79 Shows system information (path, size, date, SHA-256 hash) of the
80 class being processed.
81
82 -constants
83 Shows static final constants.
84
85 --module module or -m module
86 Specifies the module containing classes to be disassembled.
87
88 --module-path path
89 Specifies where to find application modules.
90
91 --system jdk
92 Specifies where to find system modules.
93
94 --class-path path, -classpath path, or -cp path
95 Specifies the path that the javap command uses to find user
96 class files. It overrides the default or the CLASSPATH environ‐
97 ment variable when it's set.
98
99 -bootclasspath path
100 Overrides the location of bootstrap class files.
101
102 --multi-release version
103 Specifies the version to select in multi-release JAR files.
104
105 -Joption
106 Passes the specified option to the JVM. For example:
107
108 javap -J-version
109
110 javap -J-Djava.security.manager -J-Djava.security.policy=MyPolicy MyClassName
111
112 See Overview of Java Options in java.
113
115 Compile the following HelloWorldFrame class:
116
117 import java.awt.Graphics;
118
119 import javax.swing.JFrame;
120 import javax.swing.JPanel;
121
122 public class HelloWorldFrame extends JFrame {
123
124 String message = "Hello World!";
125
126 public HelloWorldFrame(){
127 setContentPane(new JPanel(){
128 @Override
129 protected void paintComponent(Graphics g) {
130 g.drawString(message, 15, 30);
131 }
132 });
133 setSize(100, 100);
134 }
135 public static void main(String[] args) {
136 HelloWorldFrame frame = new HelloWorldFrame();
137 frame.setVisible(true);
138
139 }
140
141 }
142
143 The output from the javap HelloWorldFrame.class command yields the fol‐
144 lowing:
145
146 Compiled from "HelloWorldFrame.java"
147 public class HelloWorldFrame extends javax.swing.JFrame {
148 java.lang.String message;
149 public HelloWorldFrame();
150 public static void main(java.lang.String[]);
151 }
152
153 The output from the javap -c HelloWorldFrame.class command yields the
154 following:
155
156 Compiled from "HelloWorldFrame.java"
157 public class HelloWorldFrame extends javax.swing.JFrame {
158 java.lang.String message;
159
160 public HelloWorldFrame();
161 Code:
162 0: aload_0
163 1: invokespecial #1 // Method javax/swing/JFrame."<init>":()V
164 4: aload_0
165 5: ldc #2 // String Hello World!
166 7: putfield #3 // Field message:Ljava/lang/String;
167 10: aload_0
168 11: new #4 // class HelloWorldFrame$1
169 14: dup
170 15: aload_0
171 16: invokespecial #5 // Method HelloWorldFrame$1."<init>":(LHelloWorldFrame;)V
172 19: invokevirtual #6 // Method setContentPane:(Ljava/awt/Container;)V
173 22: aload_0
174 23: bipush 100
175 25: bipush 100
176 27: invokevirtual #7 // Method setSize:(II)V
177 30: return
178
179 public static void main(java.lang.String[]);
180 Code:
181 0: new #8 // class HelloWorldFrame
182 3: dup
183 4: invokespecial #9 // Method "<init>":()V
184 7: astore_1
185 8: aload_1
186 9: iconst_1
187 10: invokevirtual #10 // Method setVisible:(Z)V
188 13: return
189 }
190
191
192
193JDK 13 2018 JAVAP(1)