jOOQ as a dependency in Scala 3 is broken? - scala

I am trying to use jOOQ as dependency in a Scala 3 codebase:
libraryDependencies ++= Seq("org.jooq" % "jooq" % "3.16.6")
However when I try to do an import from this library -- like import org.jooq.DSLContext -- I get a compilation error.
The easiest way to reproduce this is using ammonite:
cs launch ammonite --scala 3.1.3
Loading...
Welcome to the Ammonite Repl 2.5.4-11-4f5bf2aa (Scala 3.1.3 Java 11.0.15)
# import $ivy.`org.jooq:jooq:3.16.6`, org.jooq.DSLContext
Bad symbolic reference. A signature
refers to ApiStatus/T in package org.jetbrains.annotations which is not available.
It may be completely missing from the current classpath, or the version on
the classpath might be incompatible with the version used when compiling the signature.
Caught: java.lang.AssertionError: assertion failed: failure to resolve inner class:
externalName = org.jetbrains.annotations.ApiStatus$Experimental,
outerName = org.jetbrains.annotations.ApiStatus,
innerName = Experimental
owner.fullName = org.jetbrains.annotations.ApiStatus
while parsing /Users/horta/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jooq/jooq/3.16.6/jooq-3.16.6.jar(org/jooq/Named.class) while parsing annotations in /Users/horta/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jooq/jooq/3.16.6/jooq-3.16.6.jar(org/jooq/Named.class)
Caught: java.lang.RuntimeException: bad constant pool index: 0 at pos: 740 while parsing annotations in /Users/horta/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/org/jooq/jooq/3.16.6/jooq-3.16.6.jar(org/jooq/Named.class)
...
This is not the complete error, it gives the same type of error on a bunch of different classes, always related with this annotation org.jetbrains.annotations.ApiStatus.Experimental.
I've reproduced this using Java 11 and 18 (openjdk), using SBT and ammonite, with all versions of Scala 3.
When using Scala 2.13.* everything works correctly, we're using that in production.
Any idea what might be going on here? Any potential clues or possible workarounds?

This is fixed in Scala 3 from version 3.2.0-RC1.
See reddit post in r/scala.

Related

Can't expand macros compiled by previous versions of Scala

I changed my Scala version from 2.10.x to 2.11.8. I am getting some compilation issues. I tried, but still not able to resolve because I am poor in Scala and sbt.
WebService.scala:36: can't expand macros compiled by previous versions of Scala
[error] logger.error(s"WebService.getSiteData(${Id}): Unknown Error, Error Message: $e")
What might be the issue here?
I resolved this issue but it not a single thing, I did couple of things:
First I gone through the error location in WebService.scala.
Then to the corresponding "Logger" class.
I check from which jar that "Logger" class coming.
I found that it referring to some thing else jar than what I am expecting.
That jar is coming from one of my dependent project (modules) so in build.sbt, those dependent jars I excluded that wrong jar which I found.
After I changed the code in WebService.scala, I removed that import for logger and added new import having Logger what I expecting. I did same all the other places in my project.
WebService.scala:36: can't expand macros compiled by previous versions of Scala
[error] logger.error(s"WebService.getSiteData(${Id}): Unknown Error, Error Message: $e")
This is not particular to logger issue. If you are getting "can't expand macros compiled by previous versions of Scala" issue", you have to do same procedure for corresponding to your error (my case logger).
First time, I search online regarding this issue, I found same issue facing lot of people, but different library classes (I face Logger class issue).

Unable to use ScalaCheck with Scala IDE for Eclipse

I'm trying to follow the instructions in this guide http://lamp.epfl.ch/files/content/sites/lamp/files/teaching/progfun/ScalacheckTutorial.html
in order to use ScalaCheck in Scala IDE.
However, when I create the first file StringSpecification.scala, with this code:
package pp.scalacheck
import org.scalacheck._
import Prop.forAll
object StringSpecification extends Properties("String") {
property("startsWith") = forAll { (x: String, y: String) =>
(x + y).startsWith(x)
}
}
I get the following error in Scala IDE:
bad symbolic reference to scala.util.parsing encountered in class file
'CmdLineParser.class'. Cannot access term parsing in package
scala.util. The current classpath may be missing a definition for
scala.util.parsing, or CmdLineParser.class may have been compiled
against a version that's incompatible with the one found on the
current classpath. (NOTE: It looks like the scala-parser-combinators
module is missing; try adding a dependency on "org.scala-lang.modules"
: "scala-parser-combinators". See
http://docs.scala-lang.org/overviews/core/scala-2.11.html for more
information.)
Error in Scala compiler: bad symbolic reference to
scala.util.parsing.combinator encountered in class file
'CmdLineParser.class'. Cannot access term combinator in value
scala.util.parsing. The current classpath may be missing a definition
for scala.util.parsing.combinator, or CmdLineParser.class may have
been compiled against a version that's incompatible with the one found
on the current classpath. (NOTE: It looks like the
scala-parser-combinators module is missing; try adding a dependency on
"org.scala-lang.modules" : "scala-parser-combinators". See
http://docs.scala-lang.org/overviews/core/scala-2.11.html for more
information.)
SBT builder crashed while compiling. The error message is 'bad
symbolic reference to scala.util.parsing.combinator encountered in
class file 'CmdLineParser.class'. Cannot access term combinator in
value scala.util.parsing. The current classpath may be missing a
definition for scala.util.parsing.combinator, or CmdLineParser.class
may have been compiled against a version that's incompatible with the
one found on the current classpath. (NOTE: It looks like the
scala-parser-combinators module is missing; try adding a dependency on
"org.scala-lang.modules" : "scala-parser-combinators". See
http://docs.scala-lang.org/overviews/core/scala-2.11.html for more
information.)'. Check Error Log for details.
I'm using the latest stable version of Scla IDE (for Eclipse) (3.0.4), ScalaCheck (2.11-1.11.6) and Scala (2.11.2), and I'm running on Windows.
What could be causing this error?
When I added this jar to the project I was able to build the example files:
http://search.maven.org/#artifactdetails%7Corg.scala-lang.modules%7Cscala-parser-combinators_2.11%7C1.0.2%7Cbundle

playframework 2.2.0 scala mockito test

I am currently trying to use Mockclasses in play framework for testing.
I have implemented everything like written in the Documentation. Unfortunately the compiler says:
[error] bad symbolic reference. A signature in MockitoStubs.class refers to term stubbing
[error] in package org.mockito which is not available.
[error] It may be completely missing from the current classpath, or the version on
[error] the classpath might be incompatible with the version used when compiling MockitoStubs.class.
I found some other people which are running play on a mac and have the same error but i could not find any solution.
Does anyone have a solution for this problem? Is it a problem with the mac jdk maybe?
I just installed the new OS X 10.9 Version which included a xCode Update and SDK Updates(I guess Java got updated too). Anyways the error does not occur anymore so it probably was a problem with the jdk...
Mockito is an optional dependency (like most Play2 dependencies). Excerpt from my Build.scala:
"org.mockito" % "mockito-all" % "1.9.5"

sbt can't find scala.reflect.Manifest when getting Unidoc.scala settings with scala 2.10.0

I just updated my project to Scala 2.10.0 using SBT 0.12. But now, when running sbt, I get the following error:
java.lang.NoClassDefFoundError: scala/reflect/ManifestFactory$
at X.build.Unidoc$.<init>(Unidoc.scala:8)
at X.build.Unidoc$.<clinit>(Unidoc.scala)
at X.build.ServicesBuild$.<init>(Build.scala:25)
at X.build.ServicesBuild$.<clinit>(Build.scala)
It seems that the problem is on SettingKey:
8: val unidocDirectory = SettingKey[File]("unidoc-directory")
I heard that Scala 2.10 was doing reflects different than before and thought that that was the issue, yet the Akka project is doing the same exact thing and (I assume) they are doing fine.
https://github.com/akka/akka/blob/master/project/Unidoc.scala (my Unidoc.scala is pretty much a copy&paste of theirs).
Does anyone know what is happening? How can it not find a class in scala itself?
Thanks!

Bad class file error when using Scala 2.8.x (2.8.0 and 2.8.1) in Javafx 1.x (1.2 and 1.3.1)

When trying to import scala.Option in a javafx script, I get the following javafxc error:
cannot access scala.Option.$anonfun$orNull$1
bad class file: scala/Option$$anonfun$orNull$1.class(scala:Option$$anonfun$orNull$1.class)
undeclared type variable: A1
Please remove or make sure it appears in the correct subdirectory of the classpath.
import scala.Option;
I am using Scala 2.8.1, Javafxc 1.3.1_b101, JVM 1.6.0_21-b06, OS Ubuntu 10.10. The same code was working in Scala 2.7.7 .
Later edit:
The same error is reported in case I import scala.immutable.Seq/List/Traversable/Iterable . I have tried the imports in a default Netbeans 6.9.1 JavaFX project which has in the classpath only scala-library.jar.
It reminded me first of #4067, but this one looks quite different.
I would suggest that you try to reproduce the error with 2.8.1 or 2.9 trunk, maybe it is fixed?