I am looking for a tool (or chain of tools) that can parse .class files for a Java object. Sort of:
JavaClass parsed = myTool.parse("/some_folder/SomeClassFile.class");
The analyzed object would have such methods as:
List<JavaMethod> methods = parsed.getMethods(); List<JavaInterface> interfaces = parsed.getImplementedInterfaces(); List<JavaMethod> calls = someMethod.getCalls();
My limitations:
- The goal is to analyze all classes of the project, including banks, so it is important to complete .
- The parser should parse Java 8..class files
- Java is my main language, so I feel better if it is in Java.
Of course, I can do some encoding, for example, if the xml output is normal.
So, here are the options that I have found so far - none of them satisfy:
- BCEL or ASM look like a weapon of choice, but they also look like they are no longer supported. They are also a bit overloaded for my purpose.
- Elipse AST will work, but from the fact that I saw it only for the source files, and I need to parse the binaries (jars ...)
- Grammar for a parser like antlr, yacc, bison ... will work, but I have yet to find reference grammar for .class files! Also, antlr for text files, and I don't know of any other Java parser referencing mechanism (as I said, I would like a better Java tool).
- At first I thought that the class loader would complete the task and that I could just load the class and then use reflection. But in fact, I realized that I need things that Java api reflection does not provide, for example, receiving calls from a specific method.
So that's where I am now! Thanks in advance for your help!
source share