本文介绍了Java,ASM org.objectweb.asm.util.CheckClassAdapter导致不支持的major.minor版本0.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到以下异常:

java.lang.UnsupportedClassVersionError: net/sourceforge/barbecue/BarcodeException : **Unsupported major.minor version 0.0**
    at java.lang.ClassLoader.defineClass1(Native Method)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
    at java.lang.ClassLoader.defineClass(ClassLoader.java:466)
    at pl.wroc.pwr.judy2.master.TestClassLoader.loadClass(TestClassLoader.java:51)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    at java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.lang.Class.privateGetDeclaredConstructors(Class.java:2389)
    at java.lang.Class.getConstructor0(Class.java:2699)
    at java.lang.Class.getConstructor(Class.java:1657)
    at junit.framework.TestSuite.getTestConstructor(TestSuite.java:83)
    at junit.framework.TestSuite.<init>(TestSuite.java:131)
    at org.junit.internal.runners.JUnit38ClassRunner.<init>(JUnit38ClassRunner.java:67)
    at org.junit.internal.builders.JUnit3Builder.runnerForClass(JUnit3Builder.java:14)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.internal.builders.AllDefaultPossibilitiesBuilder.runnerForClass(AllDefaultPossibilitiesBuilder.java:29)
    at org.junit.runners.model.RunnerBuilder.safeRunnerForClass(RunnerBuilder.java:57)
    at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:24)
    at junit.framework.JUnit4TestAdapter.<init>(JUnit4TestAdapter.java:31)
    at junit.framework.JUnit4TestAdapter.<init>(JUnit4TestAdapter.java:24)
    at pl.wroc.pwr.judy2.util.JUnitTestRunner.runTest(JUnitTestRunner.java:26)

尝试时用下面的源代码编制一些字节码。 (确切地说,当我尝试执行修改的字节码时,我得到这个例外)

When trying to instrument some bytecode with below source code. (to be precise, I get this exception when I am trying to execute modified bytecode)

 public byte[] instrument(byte[] bytecode)
        {

        ClassReader cr = new ClassReader(bytecode);
        ClassWriter cw = new ClassWriter(cr, 0);

        // create new class adapter
        AbstractInstrumentClassAdapter ca = new InstrumentClassAdapterTracer(cw, tracer);
        // System.out.println("----------------------------------- Daikon start");
        cr.accept(ca, 0);

        ClassReader cr2 = new ClassReader(cw.toByteArray());
        ClassWriter cw2 = new ClassWriter(cr2, 0);
        ClassAdapter checker = new CheckClassAdapter(cw);
        AbstractInstrumentClassAdapter ca2 = new InstrumentClassAdapterInstrumenter(checker);

        cr2.accept(checker, 0);
        return cw2.toByteArray();
    }

我以为可能是我的InstrumentClassAdapterInstrumenter实现,所以我把它丢出来目前只使用CheckClassAdapter。任何人可以看到我做错了什么?

I thought it could be my InstrumentClassAdapterInstrumenter implementation, so I left it out and I am using only CheckClassAdapter at the moment. Can anybody see what am I doing wrong?

干杯,

推荐答案

LOL,最后我在这里问了一些问题,似乎是简单的打字错误,应该是

LOL, finally as I've asked some question here, it seems to be simple typing error, should be

 ClassWriter cw2 = new ClassWriter(cr2, 0);
 ClassAdapter checker = new CheckClassAdapter(cw2);

 ClassWriter cw2 = new ClassWriter(cr2, 0);
 ClassAdapter checker = new CheckClassAdapter(cw);

这篇关于Java,ASM org.objectweb.asm.util.CheckClassAdapter导致不支持的major.minor版本0.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-31 12:50