Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

scala 2.12.1 ClassNotFoundException Product$class

Tags:

scala

I recently updated scala from v2.11.8 to 2.12.1 and got a CNF exception:

java.lang.ClassNotFoundException: scala.Product$class

I saw the class is shipped by scala-library.jar. The error happens when running a scalatest (the project is still at a very early stage so I have only tests).

Do you have any idea? I found nothing on the release notes.

like image 746
Alessandro Caproni Avatar asked Dec 13 '16 10:12

Alessandro Caproni


2 Answers

libraries are not binary compatible between 2.11 and 2.12, most likely one of your libraries has to be recompiled with scala 2.12

like image 97
Alexej Haak Avatar answered Oct 21 '22 21:10

Alexej Haak


In particular, trait implementations are no longer provided in classes named with the $class suffix. You'll find the notice about "trait encoding" in the release notes.

Probably you want to use sbt or ammonite if experimenting with any dependencies besides built-ins. One day they will have a tidy "platform" to help you.

$ cat notraitclass.scala

package notraitclass

trait T {
  def t: Int = 42
}
$ scalac211 notraitclass.scala
$ ls notraitclass
T.class  T$class.class
$ rm -rf notraitclass
$ scalac notraitclass.scala
$ ls notraitclass
T.class
like image 35
som-snytt Avatar answered Oct 21 '22 19:10

som-snytt