How to read a .class file?

Do I need to read the contents of the .class java file in my java program or is there any method available to read the same. In fact, I want to get a table of local variables, a table of line numbers, etc. from a .class java file, but I get no way to read the same?

+7
source share
3 answers

I want to get a table of local variables, a table of line numbers, etc.

To read the ones you need ASM , BCEL, or a similar bytecode library. The Java reflection API does not tell them.

+4
source

You will need a Java decompiler or something like that

+2
source

You can get this information using BCEL

The byte code library is designed to provide users with the convenient ability to parse, create, and process (binary) Java class files (those ending in .class). Classes are represented by objects that contain, in particular, all the symbolic information of a given class: methods, fields, and byte code instructions.

Or you can also use the reflection API to retrieve information from the class file.

0
source

All Articles