I'm trying to use the Java ASM library, and after quite a bit of research, I haven't found the solutions to a problem I'm having. I'm trying to make an application that does the following:
- Reads classes from an external Jar file
- Remove completely certain methods from specified classes
- Print to console or store the modified class' compiled bytecode or compiled class contents, like from
new String(cw.toByteArray())
, cw being an instance ofClassWriter
(Similar to how you would see if you edited a class file with notepad)
I have been able to read bytecode and the compiled class contents, but not remove methods. I haven't been able to find any working code, only partial code with very little explanation of how to implement it.
new String(cw.toByteArray())
doesn’t make any sense.new String(cw.toByteArray())
to view contents, why not use a Textifier? It makes reading the class way easier as it prints out the bytecode of a given class in a nicely formatted way.