What does "p" in "javap" stand for?
What does "p" in "javap" stand for? (The "c" in "javac" stands for compiler)
By default, javap
prints declarations of the non-private members of each of the classes specified on the command line
Reference : http://docstore.mik.ua/orelly/java/javanut/ch16_08.htm
p
= print
javap
is part of the official Java tools and allows to disassemble one or more class files.
The "p" in this case stands for print, as in the official documentation is reported that:
... the
javap
command prints the package, protected and public fields, and methods of the classes passed to it. Thejavap
command prints its output to stdout.
it stands for java printer....
Official Documentation(Java 13).
Most probably p means print
As you can see, from the options description, p in javap
most probably stands for print(as the description consists MOSTLY of print this, print that, show this, show that...).
javap -help
Usage: javap <options> <classes>
where possible options include:
-help --help -? Print this usage message
-version Version information
-v -verbose Print additional information
-l Print line number and local variable tables
-public Show only public classes and members
-protected Show protected/public classes and members
-package Show package/protected/public classes
and members (default)
-p -private Show all classes and members
-c Disassemble the code
-s Print internal type signatures
-sysinfo Show system info (path, size, date, MD5 hash)
of class being processed
-constants Show final constants
-classpath <path> Specify where to find user class files
-cp <path> Specify where to find user class files
-bootclasspath <path> Override location of bootstrap class files
Usage
public class CheckoutJavaP{
private static int i = 1;
protected static String s = "string";
public static void main(String[] args){
InnerClass iC = new InnerClass();
iC.show();
System.out.println(s + i);
}
}
class InnerClass{
protected int count;
public InnerClass(){ System.out.println("In InnerClass Constructor");}
public void show(){ System.out.println("In InnerClass.show()");}
public int getCount(){ return this.count;}
}
(Note: As per its definition, the output below has no mention of InnerClass, only the class it is introspecting and no mention of the private
property):
The javap command disassembles one or more class files. The output depends on the options used. When no options are used, then the javap command prints the package, protected and public fields, and methods of the classes passed to it. The javap command prints its output to stdout.
javap CheckoutJavaP.class
Compiled from "CheckoutJavaP.java"
public class CheckoutJavaP {
protected static java.lang.String s;
public CheckoutJavaP();
public static void main(java.lang.String[]);
static {};
}
Usage - verbose
javap -v CheckoutJavaP.class
Classfile /C:/Users/jumping_monkey/CheckoutJavaP.class
Last modified 9 Feb, 2020; size 822 bytes
MD5 checksum fb7f219851715ef4489ebf7a47800d47
Compiled from "CheckoutJavaP.java"
public class CheckoutJavaP
minor version: 0
major version: 52
flags: ACC_PUBLIC, ACC_SUPER
Constant pool:
#1 = Methodref #16.#30 // java/lang/Object."<init>":()V
#2 = Class #31 // InnerClass
#3 = Methodref #2.#30 // InnerClass."<init>":()V
#4 = Methodref #2.#32 // InnerClass.show:()V
#5 = Fieldref #33.#34 // java/lang/System.out:Ljava/io/PrintStream;
#6 = Class #35 // java/lang/StringBuilder
#7 = Methodref #6.#30 // java/lang/StringBuilder."<init>":()V
#8 = Fieldref #15.#36 // CheckoutJavaP.s:Ljava/lang/String;
#9 = Methodref #6.#37 // java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
#10 = Fieldref #15.#38 // CheckoutJavaP.i:I
#11 = Methodref #6.#39 // java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
#12 = Methodref #6.#40 // java/lang/StringBuilder.toString:()Ljava/lang/String;
#13 = Methodref #41.#42 // java/io/PrintStream.println:(Ljava/lang/String;)V
#14 = String #43 // string
#15 = Class #44 // CheckoutJavaP
#16 = Class #45 // java/lang/Object
#17 = Utf8 i
#18 = Utf8 I
#19 = Utf8 s
#20 = Utf8 Ljava/lang/String;
#21 = Utf8 <init>
#22 = Utf8 ()V
#23 = Utf8 Code
#24 = Utf8 LineNumberTable
#25 = Utf8 main
#26 = Utf8 ([Ljava/lang/String;)V
#27 = Utf8 <clinit>
#28 = Utf8 SourceFile
#29 = Utf8 CheckoutJavaP.java
#30 = NameAndType #21:#22 // "<init>":()V
#31 = Utf8 InnerClass
#32 = NameAndType #46:#22 // show:()V
#33 = Class #47 // java/lang/System
#34 = NameAndType #48:#49 // out:Ljava/io/PrintStream;
#35 = Utf8 java/lang/StringBuilder
#36 = NameAndType #19:#20 // s:Ljava/lang/String;
#37 = NameAndType #50:#51 // append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
#38 = NameAndType #17:#18 // i:I
#39 = NameAndType #50:#52 // append:(I)Ljava/lang/StringBuilder;
#40 = NameAndType #53:#54 // toString:()Ljava/lang/String;
#41 = Class #55 // java/io/PrintStream
#42 = NameAndType #56:#57 // println:(Ljava/lang/String;)V
#43 = Utf8 string
#44 = Utf8 CheckoutJavaP
#45 = Utf8 java/lang/Object
#46 = Utf8 show
#47 = Utf8 java/lang/System
#48 = Utf8 out
#49 = Utf8 Ljava/io/PrintStream;
#50 = Utf8 append
#51 = Utf8 (Ljava/lang/String;)Ljava/lang/StringBuilder;
#52 = Utf8 (I)Ljava/lang/StringBuilder;
#53 = Utf8 toString
#54 = Utf8 ()Ljava/lang/String;
#55 = Utf8 java/io/PrintStream
#56 = Utf8 println
#57 = Utf8 (Ljava/lang/String;)V
{
protected static java.lang.String s;
descriptor: Ljava/lang/String;
flags: ACC_PROTECTED, ACC_STATIC
public CheckoutJavaP();
descriptor: ()V
flags: ACC_PUBLIC
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokespecial #1 // Method java/lang/Object."<init>":()V
4: return
LineNumberTable:
line 1: 0
public static void main(java.lang.String[]);
descriptor: ([Ljava/lang/String;)V
flags: ACC_PUBLIC, ACC_STATIC
Code:
stack=3, locals=2, args_size=1
0: new #2 // class InnerClass
3: dup
4: invokespecial #3 // Method InnerClass."<init>":()V
7: astore_1
8: aload_1
9: invokevirtual #4 // Method InnerClass.show:()V
12: getstatic #5 // Field java/lang/System.out:Ljava/io/PrintStream;
15: new #6 // class java/lang/StringBuilder
18: dup
19: invokespecial #7 // Method java/lang/StringBuilder."<init>":()V
22: getstatic #8 // Field s:Ljava/lang/String;
25: invokevirtual #9 // Method java/lang/StringBuilder.append:(Ljava/lang/String;)Ljava/lang/StringBuilder;
28: getstatic #10 // Field i:I
31: invokevirtual #11 // Method java/lang/StringBuilder.append:(I)Ljava/lang/StringBuilder;
34: invokevirtual #12 // Method java/lang/StringBuilder.toString:()Ljava/lang/String;
37: invokevirtual #13 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
40: return
LineNumberTable:
line 5: 0
line 6: 8
line 7: 12
line 8: 40
static {};
descriptor: ()V
flags: ACC_STATIC
Code:
stack=1, locals=0, args_size=0
0: iconst_1
1: putstatic #10 // Field i:I
4: ldc #14 // String string
6: putstatic #8 // Field s:Ljava/lang/String;
9: return
LineNumberTable:
line 2: 0
line 3: 4
}
SourceFile: "CheckoutJavaP.java"
Right, now you can see the InnerClass
as well as the private propery i
. To get a high-level introspection of your class, use javap
, but if you want to deep-dive, use javap -v