java.lang.IncompatibleClassChangeError: Implementing class

1,358 views
Skip to first unread message

mikael petterson

unread,
Mar 11, 2016, 7:21:23 AM3/11/16
to mockito

Hi,


I am running maven to build and test in Eclipse.

So I have updated two libraries so I started to recomplile my product.

I got the following for to classes ( see below). However if I run the testcases separately they work fine.

It is only when I run in maven that I get this problem. An i checked my maven pom.xml and we have the following.



This is how my execution part looks in maven:


<plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.18.1</version>
        <executions>
          <execution>
            <id>default-test</id>
            <phase>test</phase>
            <goals>
              <goal>test</goal>
            </goals>
            <configuration>
              <argLine>-XX:-UseSplitVerifier</argLine>
              <forkCount>4</forkCount>
              <excludes>
                <exclude>**/ManualRestartTest.java</exclude>
                <exclude>**/Fork*.java</exclude>
                <exclude>**/Generate*.java</exclude>
              </excludes>
              <skip>false</skip>
            </configuration>
          </execution>
        </executions>
        <configuration>
          <argLine>-XX:-UseSplitVerifier</argLine>
          <forkCount>4</forkCount>
          <excludes>
            <exclude>**/ManualRestartTest.java</exclude>
            <exclude>**/Fork*.java</exclude>
            <exclude>**/Generate*.java</exclude>
          </excludes>
          <skip>false</skip>
        </configuration>
      </plugin>


Could it be that something is running in parallel?


java.lang.IncompatibleClassChangeError: Implementing class

                           at java.lang.ClassLoader.defineClass1(Native Method)

                           at java.lang.ClassLoader.defineClass(ClassLoader.java:800)

                           at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)

                           at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)

                           at java.net.URLClassLoader.access$100(URLClassLoader.java:71)

                           at java.net.URLClassLoader$1.run(URLClassLoader.java:361)

                           at java.net.URLClassLoader$1.run(URLClassLoader.java:355)

                           at java.security.AccessController.doPrivileged(Native Method)

                           at java.net.URLClassLoader.findClass(URLClassLoader.java:354)

                           at java.lang.ClassLoader.loadClass(ClassLoader.java:425)

                           at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)

                           at java.lang.ClassLoader.loadClass(ClassLoader.java:358)

                           at java.lang.Class.getDeclaredConstructors0(Native Method)

                           at java.lang.Class.privateGetDeclaredConstructors(Class.java:2493)

                           at java.lang.Class.getDeclaredConstructors(Class.java:1901)

                           at org.mockito.internal.creation.jmock.ClassImposterizer.setConstructorsAccessible(ClassImposterizer.java:75)

                           at org.mockito.internal.creation.jmock.ClassImposterizer.imposterise(ClassImposterizer.java:70)

                           at org.mockito.internal.creation.jmock.ClassImposterizer.imposterise(ClassImposterizer.java:56)

                           at org.mockito.internal.creation.CglibMockMaker.createMock(CglibMockMaker.java:23)

                           at org.powermock.api.mockito.internal.mockmaker.PowerMockMaker.createMock(PowerMockMaker.java:43)

                           at org.mockito.internal.util.MockUtil.createMock(MockUtil.java:26)

                           at org.mockito.internal.MockitoCore.mock(MockitoCore.java:51)

                           at org.mockito.Mockito.mock(Mockito.java:1243)

                           at org.mockito.Mockito.mock(Mockito.java:1120)


Has anyone found this? We run mockito 1.10.19.


br,


//mikael


Brice Dutheil

unread,
Mar 11, 2016, 8:11:58 AM3/11/16
to moc...@googlegroups.com
Hi,

I don't know such problem with mockito, but Eclipse compiler is known to overwrite classes written by a mvn compile, that may be the case here, i.e. your code is somehow desychronized. And when loaded loaded in the JVM, it raises an error.

The bottom line advise would be to check your dev environment.


-- Brice

--
You received this message because you are subscribed to the Google Groups "mockito" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mockito+u...@googlegroups.com.
To post to this group, send email to moc...@googlegroups.com.
Visit this group at https://groups.google.com/group/mockito.
To view this discussion on the web visit https://groups.google.com/d/msgid/mockito/80ca3b98-9bfd-4a90-9fa4-45a095719d79%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mikael petterson

unread,
Mar 13, 2016, 12:48:12 PM3/13/16
to mockito
Hi,

I have this problem only when I use the changed version the class being mocked. If I use the unchanged version of the class being mocked I don't see this problem.
So I guess that there must be something in my changed class ( the one being mocked) that has something new that is causing this error.

Any more ideas?

//mike
 

Szczepan Faber

unread,
Apr 7, 2016, 12:27:58 AM4/7/16
to mockito
Did you try with latest beta?

--
You received this message because you are subscribed to the Google Groups "mockito" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mockito+u...@googlegroups.com.
To post to this group, send email to moc...@googlegroups.com.
Visit this group at https://groups.google.com/group/mockito.
Reply all
Reply to author
Forward
0 new messages