我遇到以下异常:
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)
尝试使用以下源代码检测某些字节码时。 (确切地说,当我尝试执行修改后的字节码时,我得到了这个异常)
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。谁能看到我做错了什么?
干杯,
答案 0 :(得分:0)
LOL,最后我在这里问了一些问题,似乎输入错误很简单,应该是
ClassWriter cw2 = new ClassWriter(cr2, 0);
ClassAdapter checker = new CheckClassAdapter(cw2);
不
ClassWriter cw2 = new ClassWriter(cr2, 0);
ClassAdapter checker = new CheckClassAdapter(cw);