So I've run into
MY: WARNING cannot transform class XYZ
java.lang.RuntimeException: Method code too large!
at org.objectweb.asm.MethodWriter.a(Unknown Source)
at org.objectweb.asm.ClassWriter.toByteArray(Unknown Source)
at ...
I am aware of Method code too large! exception using ASM and of the project it links to.
However, I've been provided a modified version of ASM to work with and as such, using that project is not really an option.
That will require my breaking up the offending methods manually. Thankfully, this has happened for exactly one library class (so far -.-) so it should be manageable.
I'd like to detect and report methods that are too large, though. So I can more easily identify which I have to split. (And quite frankly, I don't understand why this information isn't provided with this error by default.)
I have written a MethodVisitor
that wraps all super calls in try-catch blocks and on exception-catch reports the method being worked on, BUT as it's the ClassWriter
's toByteArray
method that's throwing the error, and the MethodVisitor
used to traverse the bytecode is created as a local variable therein, I have not yet figured out how to insert it. Can't override the toByteArray
method because it seems to access class-private fields and simply copying fails because I'd pretty much need to copy the rest of the package, too.
I haven't tried instrumenting the ClassWriter
itself, yet, but before going there, I'd like to know if there is a more reasonable way to figure out what method is too large.
FYI, this commit adds a new exception that contains this info. 6.2.1 has been released with the commit.