The same source file in both directories
I have the following sealed trait in Errors.scala that I would like to reference in a Java class. In Scala 2.9.1, I was able to reference Errors.TooBig from Java as $ TooBig $ errors, which no longer compiles in 2.9.2.
Errors.scala
package com.abc sealed trait Error object Errors { case object TooBig extends Error }
JavaTest.java
import com.abc.Errors$TooBig$; public class JavaTest { }
I have the same source files in two different directories (2.9.1 / 2.9.2). I can compile the source using 2.9.1, but not 2.9.2.
>2.9.1$ brew switch scala 2.9.1 >2.9.1$ scalac Errors.scala >2.9.1$ javac -classpath .:/usr/local/Cellar/scala/2.9.1/libexec/lib/scala-library.jar JavaTest.java >2.9.1$ >2.9.1$ cd ../2.9.2 >2.9.2$ brew switch scala 2.9.2 >2.9.2$ scalac Errors.scala >2.9.2$ javac -classpath .:/usr/local/Cellar/scala/2.9.2/libexec/lib/scala-library.jar JavaTest.java JavaTest.java:1: cannot find symbol symbol : class Errors$TooBig$ location: package com.abc import com.abc.Errors$TooBig$; ^ 1 error } }
Here is a spread of the javap dump of the com.abc.Errors $ TooBig $ class files:
mhughes:~/scalatest$ diff 2.9.1/TooBig.txt 2.9.2/TooBig.txt 2c2 < public final class com.abc.Errors$TooBig$ extends java.lang.Object implements com.abc.Error,scala.ScalaObject,scala.Product,scala.Serializable --- > public final class com.abc.Errors$TooBig$ extends java.lang.Object implements com.abc.Error,scala.Product,scala.Serializable 5a6,7 > InnerClass: > public final #68= #9 of #67; //TooBig$=class com/abc/Errors$TooBig$ of class com/abc/Errors 73,80c75,84 < const #65 = Asciz com/abc/Error; < const #66 = class #65; // com/abc/Error < const #67 = Asciz scala/ScalaObject; < const #68 = class #67; // scala/ScalaObject < const #69 = Asciz scala/Product; < const #70 = class #69; // scala/Product < const #71 = Asciz scala/Serializable; < const #72 = class #71; // scala/Serializable --- > const #65 = Asciz InnerClasses; > const #66 = Asciz com/abc/Errors; > const #67 = class #66; // com/abc/Errors > const #68 = Asciz TooBig$; > const #69 = Asciz com/abc/Error; > const #70 = class #69; // com/abc/Error > const #71 = Asciz scala/Product; > const #72 = class #71; // scala/Product > const #73 = Asciz scala/Serializable; > const #74 = class #73; // scala/Serializable
You can see that there clearly exists a class called "$ TooBig $ Errors" generated by both 2.9.1 and 2.9.2.
source share