Java equivalent to python “dir”?

前端 未结 2 553
[愿得一人]
[愿得一人] 2021-01-19 21:49

Is there an equivalent to \"dir\" in python for java, or a library which provides similar functionality (i.e. properties of objects and classes output as informative strings

2条回答
  •  感动是毒
    2021-01-19 22:13

    I was thinking if using javap would be a good choice. The man says javap - The Java Class File Disassembler

    and I could see the built in methods by

    javap java.lang.Double | grep -i int
    public static final int MAX_EXPONENT;
    public static final int MIN_EXPONENT;
    public static final int SIZE;
    public int intValue();
    public int hashCode();
    public int compareTo(java.lang.Double);
    public static int compare(double, double);
    public int compareTo(java.lang.Object);
    

    Taking System.out.println(),

    javap -c java.lang.System | grep -i out
    public static final java.io.PrintStream out;
    public static void setOut(java.io.PrintStream);
       4: invokestatic  #4                  // Method setOut0:(Ljava/io/PrintStream;)V
       8: putstatic     #98                 // Field out:Ljava/io/PrintStream;
    

    and then do javap java.io.PrintStream

提交回复
热议问题