Static nested class visibility issue with Scala / Java interop

Posted by Matt R on Stack Overflow See other posts from Stack Overflow or by Matt R
Published on 2010-05-08T13:26:48Z Indexed on 2010/05/08 13:28 UTC
Read the original article Hit count: 287

Filed under:
|
|
|
|

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?

© Stack Overflow or respective owner

Related posts about scala

Related posts about java