Regression: Calling constructor for MockUp in Test results in java.lang.VerifyError for 1.9 #25

abc2mit opened this Issue Aug 4, 2014 · 1 comment


2 participants

abc2mit commented Aug 4, 2014

I have a mock class that extends MockUp. When running tests in JMockIt 1.9, the tests fail with java.lang.VerifyError. This is through Maven on OSX.

$ mvn --version
Apache Maven 3.2.1 (ea8b2b07643dbb1b84b6d16e1f08391b666bc1e9; 2014-02-14T09:37:52-08:00)
Maven home: /usr/local/Cellar/maven/3.2.1/libexec
Java version: 1.7.0_45, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home/jre
Default locale: en_US, platform encoding: UTF-8

OS name: "mac os x", version: "10.9.4", arch: "x86_64", family: "mac"

I rolled back JMockIt to 1.8 and the tests passed again. Also, tests seem to work in IntelliJ on 1.9 with standard configuration run. Code is below.

Created a mock class that mocks org.mongojack.DBCursor

import mockit.Mock;
import mockit.MockUp;
import org.mongojack.DBCursor;
import org.mongojack.JacksonDBCollection;

import java.util.List;

public class DBCursorMock<T> extends MockUp<DBCursor<T>> {
    private List<T> items = null;

    public DBCursorMock (List<T> items) {
        this.items = items;

    public void $init (JacksonDBCollection<T, ?> jacksonDBCollection,
                       com.mongodb.DBCursor cursor) {


    public List<T> toArray () {
        return items;

Class is called in test like so:

    JacksonDBCollectionMock<User, ObjectId> collection = new JacksonDBCollectionMock<>();
    new DBCursorMock<>(userList);

(Note: JacksonDBCollectionMock is another mock that does not have an $init method.)

Stack trace:

testGetPasscode(net.foodjudge.apiserver.db.DeviceAtomicsTest)  Time elapsed: 0.02 sec  <<< ERROR!
    at sun.instrument.InstrumentationImpl.redefineClasses0(Native Method)
    at net.foodjudge.mock.DBCursorMock.<init>(
    at net.foodjudge.apiserver.db.DeviceAtomicsTest.testGetPasscode(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.lang.reflect.Method.invoke(
    at org.apache.maven.surefire.junit4.JUnit4Provider.execute(
    at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(
    at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.lang.reflect.Method.invoke(
    at org.apache.maven.surefire.util.ReflectionUtils.invokeMethodWithArray(
    at org.apache.maven.surefire.booter.ProviderFactory$ProviderProxy.invoke(
    at org.apache.maven.surefire.booter.ProviderFactory.invokeProvider(
    at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(
    at org.apache.maven.surefire.booter.ForkedBooter.main(

@rliesenfeld rliesenfeld self-assigned this Aug 4, 2014

@rliesenfeld rliesenfeld added the bug label Aug 4, 2014


This comment has been minimized.

Show comment
Hide comment

abc2mit Aug 12, 2014

That's awesome! Thanks @rliesenfeld for fixing it so quickly!

abc2mit commented Aug 12, 2014

That's awesome! Thanks @rliesenfeld for fixing it so quickly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment