如何使用javap工具在jar文件中打印类结构? [英] How do I print the class structures in a jar file using the javap tool?

查看:127
本文介绍了如何使用javap工具在jar文件中打印类结构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用javap工具列出jar文件中的类文件的方法。我如何做,以便列出jar中所有类文件的方法和成员。现在我一次只能做一个类。

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. Right now I am able to do it for just one class at a time.

我期待的话,如果我说

javap java.lang.*

征求java.lang包中所有类的方法和成员。

it should enlist the methods and members of all the classes in java.lang package. If javap is not capable of that, are there any such tools available?

推荐答案

#!/bin/bash
# Set the JAR name
jar=<JAR NAME>
# Loop through the classes (everything ending in .class)
for class in $(jar -tf $jar | grep '.class'); do 
    # Replace /'s with .'s
    class=${class//\//.};
    # javap
    javap -classpath $jar ${class//.class/}; 
done

这篇关于如何使用javap工具在jar文件中打印类结构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆