views:

62

answers:

1

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?

+3  A: 

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).

Rex Kerr