Mysterious "unknown constant: 18" error with Scala 2.11 and Java 8

Hi,

I get this error now, trying to compile my Scala/Java project in Java8 and Scala 2.11.  I have no idea what it means, and there is no line number, or file, so some component (looks like maybe sbt?) has a bug in it.  Anyone know what this is or how to fix it?  I flushed caches, restarted, rebuilt project.  I'm using IDEA 13.

Rob

scala: Error: Unknown constant: 18
java.lang.RuntimeException: Unknown constant: 18
 at scala.sys.package$.error(package.scala:27)
 at sbt.classfile.Parser$.getConstant(Parser.scala:150)
 at sbt.classfile.Parser$.parse$1(Parser.scala:127)
 at sbt.classfile.Parser$.sbt$classfile$Parser$$parseConstantPool(Parser.scala:132)
 at sbt.classfile.Parser$$anon$1.<init>(Parser.scala:32)
 at sbt.classfile.Parser$.parseImpl(Parser.scala:24)
 at sbt.classfile.Parser$.sbt$classfile$Parser$$parse(Parser.scala:20)
 at sbt.classfile.Parser$$anonfun$apply$1.apply(Parser.scala:19)
 at sbt.classfile.Parser$$anonfun$apply$1.apply(Parser.scala:19)
 at sbt.Using.apply(Using.scala:25)
 at sbt.classfile.Parser$.apply(Parser.scala:19)
 at sbt.classfile.Analyze$$anonfun$apply$2.apply(Analyze.scala:32)
 at sbt.classfile.Analyze$$anonfun$apply$2.apply(Analyze.scala:31)
 at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
 at scala.collection.TraversableLike$$anonfun$map$1.apply(TraversableLike.scala:244)
 at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
 at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:47)
 at scala.collection.TraversableLike$class.map(TraversableLike.scala:244)
 at scala.collection.AbstractTraversable.map(Traversable.scala:105)
 at sbt.classfile.Analyze$.apply(Analyze.scala:31)
 at sbt.compiler.AggressiveCompile$$anonfun$6$$anonfun$compileJava$1$2$$anonfun$apply$mcV$sp$2.apply(AggressiveCompile.scala:147)
 at sbt.compiler.AggressiveCompile$$anonfun$6$$anonfun$compileJava$1$2$$anonfun$apply$mcV$sp$2.apply(AggressiveCompile.scala:145)
 at scala.collection.TraversableLike$WithFilter$$anonfun$foreach$1.apply(TraversableLike.scala:772)
 at scala.collection.immutable.List.foreach(List.scala:309)
 at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:771)
 at sbt.compiler.AggressiveCompile$$anonfun$6$$anonfun$compileJava$1$2.apply$mcV$sp(AggressiveCompile.scala:145)
 at sbt.compiler.AggressiveCompile$$anonfun$6$$anonfun$compileJava$1$2.apply(AggressiveCompile.scala:145)
 at sbt.compiler.AggressiveCompile$$anonfun$6$$anonfun$compileJava$1$2.apply(AggressiveCompile.scala:145)
 at sbt.compiler.AggressiveCompile.sbt$compiler$AggressiveCompile$$timed(AggressiveCompile.scala:173)
 at sbt.compiler.AggressiveCompile$$anonfun$6.compileJava$1(AggressiveCompile.scala:144)
 at sbt.compiler.AggressiveCompile$$anonfun$6.apply(AggressiveCompile.scala:151)
 at sbt.compiler.AggressiveCompile$$anonfun$6.apply(AggressiveCompile.scala:89)
 at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:39)
 at sbt.inc.IncrementalCompile$$anonfun$doCompile$1.apply(Compile.scala:37)
 at sbt.inc.Incremental$.cycle(Incremental.scala:75)
 at sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:34)
 at sbt.inc.Incremental$$anonfun$1.apply(Incremental.scala:33)
 at sbt.inc.Incremental$.manageClassfiles(Incremental.scala:42)
 at sbt.inc.Incremental$.compile(Incremental.scala:33)
 at sbt.inc.IncrementalCompile$.apply(Compile.scala:27)
 at sbt.compiler.AggressiveCompile.compile2(AggressiveCompile.scala:164)
 at sbt.compiler.AggressiveCompile.compile1(AggressiveCompile.scala:73)
 at org.jetbrains.jps.incremental.scala.local.CompilerImpl.compile(CompilerImpl.scala:61)
 at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:26)
 at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:31)
 at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)
 at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
 at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
 at java.lang.reflect.Method.invoke(Method.java:601)
 at com.martiansoftware.nailgun.NGSession.run(Unknown Source)

2 comments
Comment actions Permalink

I should add: it seems to be triggered by using the new Java lambda syntax.  I got it to compile by changing:

    arg -> { ... }

back to the old verbose way:

    new MyFunctionType<Abc>() {
        @Override public Abc run(Xyz arg) { ... }
    }


Rob

0
Comment actions Permalink

I doubt this is IntelliJ IDEA related.

I get the same error, but it occurs when running 'activator compile' on code that uses Java 8 syntax. I think it is because your version of sbt does not support Java 8:
https://github.com/sbt/sbt/issues/842
https://github.com/sbt/sbt/issues/887

The solution is probably to update project/build.properties to refer to a newer sbt version, i.e. minimum 0.13.1, it seems.

0

Please sign in to leave a comment.