Error while instrumenting class files (asm.ClassWriter.getCommonSuperClass)

前端 未结 1 993
[愿得一人]
[愿得一人] 2021-02-06 10:34

Getting error on instrumentation

java.lang.RuntimeException: java.lang.ClassNotFoundException: Deposit
    at org.objectweb.asm.ClassWriter.getCommonSuperClass(U         


        
相关标签:
1条回答
  • 2021-02-06 11:03

    This error is occurring because ASM is generating stack map frames, and for some bytecodes, the stack map frames must contain the common superclass of two classes. By default, ASM implements this by loading classes via Class.forName and then implements the proper algorithm using reflection. Presumably, the ASM library is unable to load your Deposit class from its class loader.

    To avoid the error, you'll need to either use SKIP_FRAMES (note: version 51.0 of class file used by Java 7 requires stack map frames, so this is a non-option if you're generating Java 7 bytecode), or you need to subclass ClassWriter and override getCommonSuperClass. Depending on what your code is doing, perhaps you can hard-code the answers using string comparisons, or perhaps you can take the ASM implementation and rewrite it to use a ClassLoader that you specify.

    0 讨论(0)
提交回复
热议问题