I am having trouble with Scala-Java interop when using Eclipse IDE. I have a Scala structure where a class is nested within nested objects. When trying to use the compiled classes in Java code, I cannot reference the inner class. Has anyone else encountered similar problem or are there any workarounds?
An example to reproduce the problem is below. I am interested in the Inner class of the following Scala code:
package mypackage;
object Outer {
object Middle {
class Inner {
def msg() {
println("Running");
}
}
}
}
To use the class Inner in Java code, I use the following code:
mypackage.Outer$Middle$Inner inner = new mypackage.Outer$Middle$Inner();
inner.msg();
However, Eclipse (Indigo) compiler complains with the following message at the first line:
The nested type mypackage.Outer$Middle$Inner cannot be referenced using its binary name
Interestingly, the Java code above works when used with NetBeans 6.9.1.
Is this an issue with Eclipse compiler when using Scala classes? Or am I referencing the class incorrectly?
I have also posted the question on StackOverflow earlier, thinking this may be an Eclipse issue, but have not got a definite answer there..
Thank you,
~Andrius Velykis