Monday 15 June 2015

Java, ASM: How to Get Opcode Name and TagValue from ASM InsnNode? -



Java, ASM: How to Get Opcode Name and TagValue from ASM InsnNode? -

i working on class file analysis , working on using asm read classes. in javap opcode , tagname , tagvalue printed inline, in each abstractinsnnode, see fields int (and not tagvalue)

for(abstractinsnnode abstractinsnnode : instructionlist) { system.out.println("\topcode: " + + abstractinsnnode.getopcode() + " type: " + abstractinsnnode.gettype()); }

how of instruction asm, such as:

5: invokeinterface #6, 2 // interfacemethod java/util/set.add:(ljava/lang/object;)z

and in case of loading strings , constants etc, need access values well. come tagvalue of javap. don't need print these, need programatic access values.

i need access basic operation information, eg these fields:

jvmoperations": [{ "byteoffset": 0, "constantpoolindex": null, "opcode": 42, "opcodename": "aload_0", "type": null, "tagname": null, "tagvalue": null }, { "byteoffset": 1, "constantpoolindex": null, "opcode": 180, "opcodename": "getfield", "type": null, "tagname": "field", "tagvalue": "val$foo:lcom/example/graph/demo/foo;" }, { "byteoffset": 4, "constantpoolindex": null, "opcode": 182, "opcodename": "invokevirtual", "type": null, "tagname": "method", "tagvalue": "com/example/graph/demo/foo.dosomething:()ljava/lang/integer;" }, { "byteoffset": 7, "constantpoolindex": null, "opcode": 176, "opcodename": "areturn", "type": null, "tagname": null, "tagvalue": null }]

i check source of asmifier , textifier classes how print stuff out..

java java-bytecode-asm

No comments:

Post a Comment