Static nested class visibility issue with Scala / Java interop
- by Matt R
Suppose I have the following Java file in a library:
package test;
public abstract class AbstractFoo {
protected static class FooHelper {
public FooHelper() {}
}
}
I would like to extend it from Scala:
package test2
import test.AbstractFoo
class Foo extends AbstractFoo {
new AbstractFoo.FooHelper()
}
I get an error, "class FooHelper cannot be accessed in object test.AbstractFoo". (I'm using a Scala 2.8 nightly). The following Java compiles correctly:
package test2;
import test.AbstractFoo;
public class Foo2 extends AbstractFoo {
{ new FooHelper(); }
}
The Scala version also compiles if it's placed in the test package. Is there another way to get it to compile?