Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java.lang.IncompatibleClassChangeError: Implementing class with ScalaCheck and ScalaTest

Tags:

I'm facing a nasty exception when trying to write a test using ScalaCheck and ScalaTest. Here's my dependencies:

libraryDependencies ++= Seq(   "org.scalatest" %% "scalatest" % "2.2.6" % "test",   "org.scalacheck" %% "scalacheck" % "1.13.0" % "test" )  

Here's my test:

import org.scalatest.PropSpec import org.scalatest.prop.Checkers  class MyPropSpec extends PropSpec with Checkers {    property("List.concat") {     check((a: List[Int], b: List[Int]) => a.size + b.size == (a ::: b).size)   } } 

When I try to run this I'm getting:

DeferredAbortedSuite:  Exception encountered when attempting to run a suite with class name:      org.scalatest.DeferredAbortedSuite *** ABORTED ***      java.lang.IncompatibleClassChangeError: Implementing class      at java.lang.ClassLoader.defineClass1(Native Method)      at java.lang.ClassLoader.defineClass(ClassLoader.java:760)      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)      at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)      at java.net.URLClassLoader.access$100(URLClassLoader.java:73)      at java.net.URLClassLoader$1.run(URLClassLoader.java:368)      at java.net.URLClassLoader$1.run(URLClassLoader.java:362)      at java.security.AccessController.doPrivileged(Native Method)      at java.net.URLClassLoader.findClass(URLClassLoader.java:361)      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)      ...      java.lang.IncompatibleClassChangeError: Implementing class      at java.lang.ClassLoader.defineClass1(Native Method)      at java.lang.ClassLoader.defineClass(ClassLoader.java:760)      at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)      at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)      at java.net.URLClassLoader.access$100(URLClassLoader.java:73)      at java.net.URLClassLoader$1.run(URLClassLoader.java:368)      at java.net.URLClassLoader$1.run(URLClassLoader.java:362)      at java.security.AccessController.doPrivileged(Native Method)      at java.net.URLClassLoader.findClass(URLClassLoader.java:361)      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)      ... 

What am I missing here?

like image 287
Jeroen Rosenberg Avatar asked Feb 10 '16 10:02

Jeroen Rosenberg


1 Answers

ScalaTest 2.2.6 is incompatible with ScalaCheck 1.13.0. Downgrading to "scalacheck" % "1.12.5" helps.

This was reported as https://github.com/rickynils/scalacheck/issues/217. The issue is closed with following resolution:

All current releases of ScalaTest (2.2.6, 3.0.0 etc) are built against ScalaCheck 1.12.1 (see https://github.com/scalatest/scalatest/blob/master/project/scalatest.scala#L134). Therefore, there are no guarantees that you can simply swap out ScalaCheck 1.12.x for 1.13.y. ScalaCheck only maintains binary compatibility within the same minor version series (1.12.1, 1.12.2, 1.12.3 etc).

like image 115
Suma Avatar answered Jan 04 '23 00:01

Suma