IntelliJ IDEA 13 Scala插件& Eclipse Kepler编译错误

时间:2013-12-04 16:42:38

标签: java eclipse scala intellij-idea guava

IntelliJ IDEA Eclipse

代码:

import com.google.common.base.Joiner
import scala.collection.JavaConverters._

object MainJ extends App {
   val fantasyGeneres = Array("Space Opera", "Horror", "Magic realism", "Religion")
   val joined = Joiner.on(',').join(fantasyGeneres.toIterable.asJava)
println(joined)
}

IntelliJ IDEA错误:

scala: error while loading Joiner, class file 'C:\guava-    15.0.jar(com/google/common/base/Joiner.class)' is broken
(class java.lang.RuntimeException/bad constant pool tag 9 at byte 10)

Scala插件版本:

Scala -> 0.26.318
Version: 0.26.318
Date: 2013-12-04 10:46
Since: 133.124
Until: 134.0
Size: 25346.32 Kb

Eclipse错误:

Description Resource    Path    Location    Type
error while loading Joiner, class file 'C:\guava-15.0.jar(com/google/common/base/Joiner.class)' is broken (class java.lang.RuntimeException/bad constant pool tag 9 at byte 10) Scala       Unknown Scala Problem

请看上面的图片,我用Guava库和scala语言编写了一个程序

WHEN 我使用带有Scala插件的 Eclipse IDE&带有Scala插件的IntelliJ IDEA 上面的错误显示,我无法编译它

任何人都可以帮助我吗?

1 个答案:

答案 0 :(得分:3)

这不是IDE的错。实际上它是Scala编译器的工作方式。与Java编译器不同,Scala编译器需要代码直接使用的所有库的所有注释。 Guava依赖于JSR-305注释,因此您必须在构建中包含相应的JAR。

有关详细信息,请参阅herehere。这是从here复制的Maven依赖描述符:

<dependency>
    <groupId>com.google.code.findbugs</groupId>
    <artifactId>jsr305</artifactId>
    <version>2.0.2</version>
</dependency>