2

This compiles without error on Scala 2.8.0 final:

import javax.swing.tree.TreePath

object A extends Application {

  val path1 = new TreePath()
  val path2 = new TreePath(path1, "foo")

}

However, on execution I get:

java.lang.IllegalAccessError: tried to access method javax.swing.tree.TreePath.<init>()V from class A$
  at A$.<init>(A.scala:5)
  at A$.<clinit>(A.scala)
 at A.main(A.scala)

Is this a bug, feature, or a known limitation?

1 Answer 1

4

This is a sort-of-bug, sort-of-feature. You certainly should get the access error (feature) because that's what protected is supposed to do. The compiler arguably ought to know enough about the context to be able to tell, however, and warn you instead of leaving it to runtime (bug, or at least candidate-for-enhancement).

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.