Domanda

I am using ASM 4.1. I understand that the method visitLdcInsn requires version 49 or higher, however I am wondering how I could get visitLdcInsn to work with version 49 and lower. I know a solution is for people to compile with a higher version, but I do not believe that is a proper solution to suggest to people. Here is some test code that when I try to instrument I get the exception:

package mypackage;
 public class JDK4TEST {
  public static void main(String[] args) {
  }
 }

I get the following exception: Exception in thread "main" java.lang.VerifyError: (class: mypackage/JDK4TEST, method: __cobertura_classmap signature: (Lnet/sourceforge/cobertura/coveragedata/LightClassmapListener;)V) Illegal type in constant pool

If more code is required, this is part of the cobertura 2.0 code on github.

È stato utile?

Soluzione

The visitLdcInsn method were there from the beginning, but some of the accepted parameter types depend on the class format version, e.g. Type and Handle values are acceptable for class format 51.0 and higher. See corresponding JavaDoc.

Also note, that ASM's ClassWriter doesn't check validity of produced bytecode. You need to add CheckClassAdapter into the visitor's chain before ClassWriter.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top