我有一个Scala应用程序可以使用sbt 0.13.9进行编译和运行,但是使用相同的选项它不会在ScalaIDE(Eclipse)中编译。我使用Scala 2.11.7和jdk8_60以及选项-Ydelambdafy:method -Ybackend:GenBCode
。如果我删除它将编译的选项。这对我来说并不是很紧急,但如果它是一个错误,那么找到一个可以找出错误的人就可以记录下来会很好。
感谢。
object TestDataApp extends App {
val outputDir = "src/main/scala"
def writeFile(fileName: String, contents: String) {
import java.nio.file._
val p = Paths.get(outputDir, fileName)
Files.write(p, contents.getBytes)
}
def createLines(strs: IndexedSeq[String]) = {
strs.mkString("\n")
}
def createUsersString() = {
val nums = 1 to 50000
val strs = nums.map("ta_" + _.toString)
createLines("userId" +: strs)
}
def createActorsString(actors: List[String]) = {
def createActorString(actor: String) = {
val searches = actor.scanLeft("")((a,b) => a + b).tail
createLines(searches)
}
// accumulater acc is a StringBuilder - term is header
val initSb = new StringBuilder("term\n" + createActorString(actors.head))
val sb = actors.tail.foldLeft(initSb)((acc, e) => acc.append("\n").append(createActorString(e)))
sb.toString()
}
def readActorList(fileName: String): List[String] = {
import scala.io.{Source, Codec}
import java.io.InputStream
val stream = getClass.getResourceAsStream(fileName)
val lines = Source.fromInputStream(stream)(Codec.UTF8).getLines
lines.map(line => line.split("\\t").head).toList
}
// write the files
println("Writing files...")
writeFile("userId.txt", createUsersString())
val actors = readActorList("input.txt")
writeFile("term.txt", createActorsString(actors))
println("Done.")
}
input.txt文件以制表符分隔,如下所示。
Alex Colls 124
Larry Jacobs 65
Graham Falk 64
Pere Clos 60
Hunter Parrish 41
1.6和1.7和1.8的Jvm目标将无效。 Sbt使用这些选项:scalacOptions ++= Seq("-deprecation", "-feature", "-Ydelambdafy:method", "-Ybackend:GenBCode")
以下是IDE中的错误。
Description Resource Path Location Type
Couldn't create file for class TestDataApp$lambda$$readActorList$1 null TestDataApp.scala /sc-test/src/main/scala line 3 Scala Problem
Couldn't create file for class TestDataApp$lambda$$sb$1 null TestDataApp.scala /sc-test/src/main/scala line 3 Scala Problem
Couldn't create file for class TestDataApp$lambda$$searches$1 null TestDataApp.scala /sc-test/src/main/scala line 3 Scala Problem
Couldn't create file for class TestDataApp$lambda$$strs$1 null TestDataApp.scala /sc-test/src/main/scala line 3 Scala Problem
Error in Scala compiler: assertion failed: Precisely this override requires its invoker to hand out a non-null AbstractFile. while compiling: C:\Users\erichardson\workspaces\scala\sc-test\src\main\scala\TestDataApp.scala during phase: jvm library version: version 2.11.7 compiler version: version 2.11.7 reconstructed args: -Ydelambdafy:method -deprecation -classpath C:\Users\erichardson\workspaces\scala\sc-test\bin;C:\Users\erichardson\eclipse-scala-ide-4.1.1\plugins\org.scala-lang.scala-reflect_2.11.7.v20150622-112736-1fbce4612c.jar;C:\Users\erichardson\eclipse-scala-ide-4.1.1\plugins\org.scala-lang.scala-actors_2.11.7.v20150622-112736-1fbce4612c.jar -Ybackend:GenBCode -javabootclasspath C:\Program Files\Java\jre1.8.0_60\lib\resources.jar;C:\Program Files\Java\jre1.8.0_60\lib\rt.jar;C:\Program Files\Java\jre1.8.0_60\lib\jsse.jar;C:\Program Files\Java\jre1.8.0_60\lib\jce.jar;C:\Program Files\Java\jre1.8.0_60\lib\charsets.jar;C:\Program Files\Java\jre1.8.0_60\lib\jfr.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\cldrdata.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\dnsns.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\jaccess.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\jfxrt.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\localedata.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\nashorn.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\sunec.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\sunmscapi.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\zipfs.jar -javaextdirs -target:jvm-1.7 -bootclasspath C:\Users\erichardson\eclipse-scala-ide-4.1.1\plugins\org.scala-lang.scala-library_2.11.7.v20150622-112736-1fbce4612c.jar last tree to typer: TypeTree(class String) tree position: line 26 of C:\Users\erichardson\workspaces\scala\sc-test\src\main\scala\TestDataApp.scala tree tpe: String symbol: final class String in package lang symbol definition: final class String extends Serializable with Comparable with CharSequence (a ClassSymbol) symbol package: java.lang symbol owners: class String call site: constructor TestDataApp$delayedInit$body in class TestDataApp$delayedInit$body in package <empty> == Source file context for tree position == 23 24 def createActorString(actor: String) = { 25 val searches = actor.scanLeft("")((a,b) => a + b).tail 26 createLines(searches) 27 } 28 29 // accumulater acc is a StringBuilder - term is header sc-test Unknown Scala Problem
SBT builder crashed while compiling. The error message is 'assertion failed: Precisely this override requires its invoker to hand out a non-null AbstractFile. while compiling: C:\Users\erichardson\workspaces\scala\sc-test\src\main\scala\TestDataApp.scala during phase: jvm library version: version 2.11.7 compiler version: version 2.11.7 reconstructed args: -Ydelambdafy:method -deprecation -classpath C:\Users\erichardson\workspaces\scala\sc-test\bin;C:\Users\erichardson\eclipse-scala-ide-4.1.1\plugins\org.scala-lang.scala-reflect_2.11.7.v20150622-112736-1fbce4612c.jar;C:\Users\erichardson\eclipse-scala-ide-4.1.1\plugins\org.scala-lang.scala-actors_2.11.7.v20150622-112736-1fbce4612c.jar -Ybackend:GenBCode -javabootclasspath C:\Program Files\Java\jre1.8.0_60\lib\resources.jar;C:\Program Files\Java\jre1.8.0_60\lib\rt.jar;C:\Program Files\Java\jre1.8.0_60\lib\jsse.jar;C:\Program Files\Java\jre1.8.0_60\lib\jce.jar;C:\Program Files\Java\jre1.8.0_60\lib\charsets.jar;C:\Program Files\Java\jre1.8.0_60\lib\jfr.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\cldrdata.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\dnsns.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\jaccess.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\jfxrt.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\localedata.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\nashorn.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\sunec.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\sunmscapi.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jre1.8.0_60\lib\ext\zipfs.jar -javaextdirs -target:jvm-1.7 -bootclasspath C:\Users\erichardson\eclipse-scala-ide-4.1.1\plugins\org.scala-lang.scala-library_2.11.7.v20150622-112736-1fbce4612c.jar last tree to typer: TypeTree(class String) tree position: line 26 of C:\Users\erichardson\workspaces\scala\sc-test\src\main\scala\TestDataApp.scala tree tpe: String symbol: final class String in package lang symbol definition: final class String extends Serializable with Comparable with CharSequence (a ClassSymbol) symbol package: java.lang symbol owners: class String call site: constructor TestDataApp$delayedInit$body in class TestDataApp$delayedInit$body in package <empty> == Source file context for tree position == 23 24 def createActorString(actor: String) = { 25 val searches = actor.scanLeft("")((a,b) => a + b).tail 26 createLines(searches) 27 } 28 29 // accumulater acc is a StringBuilder - term is header'. Check Error Log for details. sc-test Unknown Scala Problem
sc-test's tests not built due to errors in dependent scope(s) main sc-test Unknown Scala Problem