btrace visualvm接口需要ASM 5

时间:2016-09-22 15:31:01

标签: java jvisualvm btrace

当我运行这个简单的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$4.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)

任何帮助表示赞赏

1 个答案:

答案 0 :(得分:1)

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