如何确定Java类使用哪些方法 [英] How do I determine which methods are used by a Java class
问题描述
我需要提供一份报告,告诉我们的代码使用了哪些API,以及调用哪些方法。对于Windows DLL,我会使用dumpbin / imports - 是否有一个等同的Java .class文件?
I need to provide a report of which APIs are used by our code, and exactly which methods are called. For a Windows DLL, I would use "dumpbin /imports" - is there an equivalent for a Java .class file?
javap似乎是显而易见的地方,但是我找不到任何看起来像我以后做的选项。
javap seems to be the obvious place to look, but I can't find any options that seem to do what I'm after.
推荐答案
javap -c class1 class2 ... | grep invoke
您将获得所有的运行时调用。
You will get all the runtime calls. You should filter them from your APIs and you will get calls to imported methods.
您可能还需要确定使用的导入字段:
You might also want to determine used imported fields:
javap -c class1 class2 ... | grep getstatic
(搜索也putstatic,putfield,getfield)
javap -c class1 class2 ... | grep getstatic
(search also putstatic, putfield, getfield)
这篇关于如何确定Java类使用哪些方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!