All scenarios below (JMockit 1.9, 1.10, 1.11) work flawlessly with Oracle JDK 1.6:
java -version
java version "1.6.0_45"
Java(TM) SE Runtime Environment (build 1.6.0_45-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.45-b01, mixed mode)
IBM JDK Summary:
1.9 - works fine
1.10 - error
1.11 - error
Versions 1.9, 1.10 and 1.11 with IBM JDK detailed results:
java -version
java version "1.6.0"
Java(TM) SE Runtime Environment (build pwi3260sr9fp1ifix-20110401_01(SR9 FP1+IZ95392+IZ95393+IZ97453))
IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 Windows 7 x86-32 jvmwi3260sr9-20110216_75791 (JIT enabled, AOT enabled)
J9VM - 20110216_075791
JIT - r9_20101028_17488ifx4
GC - 20101027_AA)
JCL - 20110401_02
I have the following code:
package test;
public class Foo {
public String getValue() {
return "FOO VALUE!";
}
}
package test;
import mockit.Expectations;
import mockit.Mocked;
import org.junit.Test;
public class FooTest {
@Mocked
Foo foo;
@Test
public void test() {
new Expectations() {{
foo.getValue();
result = "MOCK";
}};
System.out.println(foo.getValue());
}
}
Works fine with JMockit 1.9.
Error with JMockit 1.10 (test does not run):
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)
at java.lang.reflect.Method.invoke(Method.java:611)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:335)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:350)
Caused by: java.lang.ClassFormatError: JVMCFRE009 interface field must be public static and final; class=org/omg/CORBA/portable/IDLEntity, offset=198
at com.ibm.oti.vm.VM.findClassOrNull(Native Method)
at com.ibm.oti.vm.BootstrapClassLoader.loadClass(BootstrapClassLoader.java:62)
at com.ibm.oti.vm.VM.findClassOrNull(Native Method)
at com.ibm.oti.vm.BootstrapClassLoader.loadClass(BootstrapClassLoader.java:62)
at java.lang.ClassLoader.loadClass(ClassLoader.java:643)
at java.lang.ClassLoader.loadClass(ClassLoader.java:645)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:358)
at java.lang.ClassLoader.loadClass(ClassLoader.java:619)
at mockit.internal.startup.MockingBridgeFields.createSyntheticFieldsInJREClassToHoldMockingBridges(MockingBridgeFields.java:30)
at mockit.internal.startup.Startup.initialize(Startup.java:57)
at mockit.internal.startup.Startup.premain(Startup.java:49)
... 6 more
Fatal error: processing of -javaagent failed
Error with JMockit 1.11 (test runs but unexpected error):
java.lang.IllegalStateException: Attempted to record invocation to mocked method from outside expectation block:
test.Foo#getValue()
on mock instance: test.Foo@60e860e8
at test.Foo.getValue(Foo.java)
at test.FooTest$1.(FooTest.java:16)
at test.FooTest.test(FooTest.java:15)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.lang.reflect.Method.invoke(Method.java:611)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:49)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
All scenarios below (JMockit 1.9, 1.10, 1.11) work flawlessly with Oracle JDK 1.6:
java -version
IBM JDK Summary:
Versions 1.9, 1.10 and 1.11 with IBM JDK detailed results:
java -version
I have the following code:
Works fine with
JMockit 1.9
.Error with
JMockit 1.10
(test does not run):Error with
JMockit 1.11
(test runs but unexpected error):