“p”是什么意思?在“javap”中代表?

发布于 2024-10-15 09:21:09 字数 44 浏览 4 评论 0原文

“javap”中的“p”代表什么? (“javac”中的“c”代表编译器)

What does "p" in "javap" stand for? (The "c" in "javac" stands for compiler)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

小姐丶请自重 2024-10-22 09:21:09

默认情况下,javap 打印在命令行上指定的每个类的非私有成员的声明

参考:http://docstore.mik.ua/orelly/java/javanut/ch16_08.htm

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

我ぃ本無心為│何有愛 2024-10-22 09:21:09

p = print

javap 是官方 Java 工具的一部分,允许反汇编一个或多个类文件。

在这种情况下,“p”代表 print,如 官方文档报道称:

...javap 命令打印包、受保护和公共字段以及传递给它的类的方法。 javap 命令将其输出打印到 stdout。

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. The javap command prints its output to stdout.

会发光的星星闪亮亮i 2024-10-22 09:21:09

它代表java打印机......

it stands for java printer....

诗化ㄋ丶相逢 2024-10-22 09:21:09

javap 官方文档(Java 13)

p 表示 print

正如您所看到的,从选项 description 中,javap 中的 p 最有可能代表 print(因为助手主要由 print 组成)这个,打印那个,显示这个,显示那个......)。

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

根据其官方文档,
javap 命令打印 被声明两次。

javap 命令反汇编一个或多个类文件。输出
取决于所使用的选项。当没有使用选项时,[[HERE:]] javap
命令打印包、受保护和公共字段以及方法
传递给它的类。 [[HERE:]] javap 命令将其输出打印到
标准输出。

javap

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;}
}

 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 {};
    }

javap -v(详细)

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"

javap Official Documentation(Java 13).

p means print

As you can see, from the options description, p in javap most probably stands for print(as the helper 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

As per its official documentation,
the javap command prints is stated TWICE.

The javap command disassembles one or more class files. The output
depends on the options used. When no options are used, then the [[HERE:]] javap
command prints the package, protected and public fields, and methods
of the classes passed to it. [[HERE:]] The javap command prints its output to
stdout.

javap

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;}
}

 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 {};
    }

javap -v (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"
埖埖迣鎅 2024-10-22 09:21:09

它打印类中的方法声明,这是查看编译器如何工作的好方法
已解释您的代码并将源文件转换为 .class 格式。

It prints the methods declarations in your class and its a very good way to see the how your compiler
has interpreted your code and convert your source file into .class format.

折戟 2024-10-22 09:21:09

javap 命令反汇编一个或多个类文件。其输出取决于所使用的选项。如果没有使用选项,javap 会打印出传递给它的类的包、受保护的以及公共字段和方法。 javap 将其输出打印到 stdout。

The javap command disassembles one or more class files. Its output depends on the options used. If no options are used, javap prints out the package, protected, and public fields and methods of the classes passed to it. javap prints its output to stdout.

不再让梦枯萎 2024-10-22 09:21:09

它列出了指定类包含的所有方法和变量。
您只需在命令行上使用 javap 命令将类名命名为 paas 即可。
例如
C:\jdk1.3\bin> javap java.lang.Object
它将列出 Object 类包含的所有方法。

It lists all the methods and variable the specified class contains.
You just need to paas the class name with javap command on command-line.
e.g.
C:\jdk1.3\bin> javap java.lang.Object
it will list all the methods Object class contains.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文