Open
Description
This is with Scala 2.8.0.RC3
Steps to reproduce:
in p/Base.java
package p;
public class Base {
protected void test() { }
}
in test.scala
trait Ext {
this: p.Base =>
def run = test // Access Java protected member here
}
object Test {
def main(args: Array[String]) {
val s = new p.Base with Ext
s.run
}
}
compile & run
$$ javac p/Base.java
$$ scalac test.scala
$$ scala Test
java.lang.IllegalAccessError: tried to access method p.Base.test()V from class Ext$$class
at Ext$$class.run(test.scala:3)
at Test$$$$anon$$1.run(test.scala:8)
at Test$$.main(test.scala:9)
at Test.main(test.scala)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at scala.tools.nsc.util.ScalaClassLoader$$$$anonfun$$run$$1.apply(ScalaClassLoader.scala:81)
at scala.tools.nsc.util.ScalaClassLoader$$class.asContext(ScalaClassLoader.scala:24)
at scala.tools.nsc.util.ScalaClassLoader$$URLClassLoader.asContext(ScalaClassLoader.scala:86)
at scala.tools.nsc.util.ScalaClassLoader$$class.run(ScalaClassLoader.scala:81)
at scala.tools.nsc.util.ScalaClassLoader$$URLClassLoader.run(ScalaClassLoader.scala:86)
at scala.tools.nsc.MainGenericRunner$$.main(MainGenericRunner.scala:78)
at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)
If the base class is written in Scala, this doesn't happen (because the protected method is compiled as public).