How do I print the class structures in a jar file using the javap tool?

后端 未结 3 2098
暖寄归人
暖寄归人 2020-12-28 16:14

I want to list the methods of the class files in the jar using the javap tool. How do I do it so that it lists the methods and members of all the class files in the jar. Rig

3条回答
  •  醉话见心
    2020-12-28 16:50

    First unzip the jar file, this will yield a series of directories for each package, then apply the javap command per directory.

    So for example with tomcat you can unzip the catalina-balancer.jar file in webapps\balancer and then use

    javap -classpath org\apache\webapp\balancer Rule

    which gives

    Compiled from "Rule.java"
    interface org.apache.webapp.balancer.Rule{
        public abstract boolean matches(javax.servlet.http.HttpServletRequest);
        public abstract java.lang.String getRedirectUrl();
    }

    If you need to do this for all the class files in a package you will need to write a script or program to walk the classpath and strip the .class from the filenames and pass it to javap.

    (It would be fairly easy to write in perl/bash/java).

提交回复
热议问题