8

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?

1 Answer 1

10

Hmm, I could just read the Java Interoperability FAQ:

http://www.scala-lang.org/faq/4#4n1381

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.