문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top