Search code examples
javaclassanalytics.class-file

How to analyze Java class files?


I have a Java .class-file. Now I'd like to find out which methods an fields it provides to the outside world.

I'd like to get a list of all methods and fields plus their visibility. The output could be:

1) final static String CONST = "Test"
2) final public void print(String)
3) protected(com.stackoverflow.package) void pprint(String)

Solution

  • Use javap

    javap DocFooter.class
    

    To get the static final constants

    javap -constants DocFooter.class
    

    Check this out