Reputation: 137
I am trying to use JMockit in a JUnit test, but I am getting an UnsupportedClassVersionError while running the tests from Eclipse. This is a Java 1.5 project and I have JDK 1.5.0.22 in build path and the version of JUnit in class path is 4.11 (downloaded from maven repository)
java.lang.UnsupportedClassVersionError: Bad version number in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:133)
I went through the JMockit installation instructions and made the following changes;
I have spent lot of hours trying to fix this :(, but no luck. Please let me know if you have an solution for this? What am I missing here?
Upvotes: 0
Views: 2832
Reputation: 7406
You haven't specified what version of JMockit you are using; however it seems to me like you're running into this:
From this version on, JMockit requires Java 6 or newer when running tests;
JRE 1.5 is no longer supported. Note that this only applies to the JRE/JDK
used for test execution; class files compiled for older versions of Java
are still supported.
That's as of JMockit 1.8, released last April.
This, BTW, is to be expected, since Java 1.5 hasn't been publicly supported in over five years.
Upvotes: 2