Are there any libraries for extracting class, method, member and field dependency names from a .class file (bytecode)?

StackOverflow https://stackoverflow.com/questions/11360162

Question

As the title says, are there any libraries for extracting class, method, member and field dependency names from a .class file (bytecode)?

For example, if I a compiled Scala .class file uses something like this:

var xs = new List[java.lang.String]();
"blah" :: xs;
xs(0).charAt(0);

I should get that I use these classes and methods:

java.lang.String
java.lang.String#charAt
scala.collection.immutable.List
scala.collection.immutable.List#apply

Is there any library with API I can use in my own Scala program that can do this for me?

Était-ce utile?

La solution

Here is ASM framework tutorial explaining how to collect dependencies from classes.

Autres conseils

You need to be able to read the code of method bodies. I would use a byte code library such as ObjectWeb's ASM, BCEL or JavaAssist.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top