bytecode manipulation - java disassemble reassemble -


say want take java class file, disassemble it, tweak java bytecode output, , reassemble again.

i need rename symbol in constant pool table. don't have access source code, , using decompiler seems overkill this. i'm not trying optimize - java fine job @ that.

is there... simple way this? i've found several tools either disassembly or reassembly, none both; or no pairs of tools seem use same format representing bytecode in text.

did check asm api?

here code sample (adapted official documentation) explaining how modify class bytecode:

classswriter cw = new classwriter(); classadapter ca = new classadapter(cw); // ca forwards events cw // ca should modify class data classreader cr = new classreader("myclass"); cr.accept(ca, 0); byte[] b2 = cw.tobytearray(); // b2 represents same class myclass, modified ca 

then b2 can stored in .class file future use. can use method classloader.defineclass(string,byte[],int,int) load if define own classloader.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -