Question

I am trying to parse java bytecodes into an intermediate data structure for later use. I stumbled into ASM. It is powerful and stable. However, I am difficult time translating the binary instructions back to normal java expression and statements. Could anybody point out a direction for me?

The deal data structure may look like this:

ClassInfo
- FieldInfo
- MethodInfo
-- ForLoopStatement
-- WhileStatement
--- AssignmentExpression
--- FunctionCallExpression
...

Basically it's nothing more than an abstraction of java language.

Thank you.

Was it helpful?

Solution

At db4o we were using the ironically called BLOAT library to retrieve a fully constructed AST from a method body. It worked well enough for us, but it is not based on ASM.

OTHER TIPS

Why not stay with Java bytecode as it is and if you need a human readable form, simply disassemble it? At least your question does not make it clear why Java bytecode itself can not be the intermediary data structure used for storage.

The official Java SDK release has a tool called javap that converts bytecode back into Java source. Another option for the same job would be javad.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top