How can I get the sinatures function from a jar file?

In Eclipse or NetBeans, when you “control + click” a function, you can at least see your entire signature, even if it is in the jar file.

I am wondering if it is possible to write a tool to extract all function signatures from a jar file. Is there an API for this?

I know jDepend seems to offer features for this. However, I believe that there are several more general ways to do this.

+4
source share
2 answers

Jars are zip files, so you can use zip routines to get the byte code definition for each class in the jar file.

Then, given the byte code, you can use a byte code analysis tool like javassist to load the byte code into ClassFile, and then get MethodInfo, which you can then process as you like.

+2
source

I think the javap tool is what you need.

Something like javap -classpath ./lib/ MyClass should do the trick.

See also this tutorial and reference information for javap (google javap , I don't have enough reputation to post more than 1 link).

+4
source

All Articles