I recently asked this question:
Best choice? Edit bytecode (asm) or edit java file before compiling
I’ve chosen to use ASM.
Now while reading documentation I noticed that ASM provides 2 API’s (Event based and Object based)
What would me the most suitable API for my problem?
I’m thinking the event based. Because I want to find every comparison / specific operation
What’s your opinion?
It depends entirely on the type of transformation you want to do. If your transformation only needs to act on specific bytecodes in one method and insert code before or after this bytecode then the event based api is very easy to use.
The tree based api comes in handy when you need information about other methods in the class or if you need more context around the bytecode you want to modify.
Edit: it is also possible to combine both approaches, first build the tree structure and determine some information about the class and then transform this tree node using the event based api.