btrace visualvm 接口需要 ASM 5

btrace visualvm interfaces require ASM 5

当我运行这个简单的Java8程序

package test;

public class TraceInt {
public static void main(String args[]) throws InterruptedException{
    TraceInt ti = new TraceInt();
    while(true){
        Integer.valueOf((int)System.currentTimeMillis());
        ti.sleep(1000);
        //System.getProperty("user.dir");
    }
}

public void sleep(int millis){
    try {
        Thread.sleep(millis);
    } catch (InterruptedException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
}

和运行这个针对它的btrace脚本

@OnMethod(
    clazz = "/.*/",
    method = "/java.lang.*/",
    location = @Location(value = Kind.ENTRY, where = Where.BEFORE)
)
public static void onEntry(Object obj) {
    println(Strings.strcat("on entry: ", identityStr(obj)));
}

我在程序中遇到这个错误

java.lang.IllegalArgumentException: INVOKESPECIAL/STATIC on interfaces require ASM 5
at com.sun.btrace.org.objectweb.asm.MethodVisitor.visitMethodInsn(Unknown Source)
at com.sun.btrace.util.templates.TemplateExpanderVisitor.visitMethodInsn(TemplateExpanderVisitor.java:85)
at com.sun.btrace.org.objectweb.asm.MethodVisitor.visitMethodInsn(Unknown Source)
at com.sun.btrace.org.objectweb.asm.ClassReader.a(Unknown Source)
at com.sun.btrace.org.objectweb.asm.ClassReader.b(Unknown Source)
at com.sun.btrace.org.objectweb.asm.ClassReader.accept(Unknown Source)
at com.sun.btrace.org.objectweb.asm.ClassReader.accept(Unknown Source)
at com.sun.btrace.runtime.InstrumentUtils.accept(InstrumentUtils.java:66)
at com.sun.btrace.runtime.InstrumentUtils.accept(InstrumentUtils.java:62)
at com.sun.btrace.agent.Client.instrument(Client.java:392)
at com.sun.btrace.agent.Client.doTransform(Client.java:213)
at com.sun.btrace.agent.Client.transform(Client.java:165)
at sun.instrument.TransformerManager.transform(TransformerManager.java:188)
at sun.instrument.InstrumentationImpl.transform(InstrumentationImpl.java:428)
at sun.instrument.InstrumentationImpl.retransformClasses0(Native Method)
at sun.instrument.InstrumentationImpl.retransformClasses(InstrumentationImpl.java:144)
at com.sun.btrace.agent.Main.run(Main.java:464)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)

感谢任何帮助

过了一会儿,我意识到我正在对 Java8 使用旧版本的 btrace。一旦我转移到最新版本,一切都很好。