[#281] | project: compiler | priority: medium | category: bug | |
---|---|---|---|---|
submitter | assigned to | status | date submitted | |
Burak | Iulian | fixed | 2004-01-22 11:18:10.0 | |
subject | missing accessors for protected fields of Java superclass | |||
code |
import org.apache.tools.ant.taskdefs.Javac; // put ant.jar in classpath // Javac has a protected field // compileList:Array[java.io.File] !! class A extends Javac { def bar( i:int ) = { for( val j <- List.range( 0, 42 )) { Console.println( compileList ) } } } object Test { def main( args:Array[String] ) = { new A().bar( 4 ) } } |
|||
what happened | /tmp/bugFu> scalac -classpath ${CLASSPATH}:/home/linuxsoft/apps/ant/lib/ant.jar ScalaFU.scala /tmp/bugFu> java -classpath ${CLASSPATH}:/home/linuxsoft/apps/ant/lib/ant.jar Test Exception in thread "main" java.lang.IllegalAccessError: tried to access field org.apache.tools.ant.taskdefs.Jav\ ac.compileList from class A$$anon$0 at A$$anon$0.apply(ScalaFU.scala:10) at A$$anon$0.apply(ScalaFU.scala:9) at scala.List$class.foreach(sources/scala/List.scala:381) at A$class.bar(ScalaFU.scala:9) at Test$.main(ScalaFU.scala:17) at Test.main(ScalaFU.scala) |
|||
what expected | normal execution (42 times output "[java.io.File@iii").
The problem is that the body of the file becomes anonymous class that has no right to access protected fields of the superclass (here Javac.compileList). |
|||
[back to overview] |
Michel edited on 2004-02-03 13:50:49.0 |
Here is a simplified example:
class A extends java.util.Hashtable { class B { def f = rehash() } } object Main { def main(args: Array[String]): Unit = { val a = new A; val b = new a.B; b.f } }The problem is that B accesses a protected method of the super-class of its outer class, namely A . ExplicitOuter should find all the instances of such calls and provide forwarding methods to be used by its enclosing classes. In this example, A should be augmented with a forwarding rehash method, and method f would simply use it instead of rehash itself.
|
Michel edited on 2004-02-03 15:59:36.0 |
Assigned to Philippe (I thought I had done it before, but apparently not). |
Philippe edited on 2004-04-02 15:44:12.0 |
Added creation of access methods for hidden methods/fields accessed from inner classes in ExplicitOuter. |
Gilles edited on 2005-12-15 14:50:05.0 |
This bug is open again for NSC! |
Lex edited on 2006-03-28 14:12:28.0 |
This problem still occurs as of scalac 2.1.0. |
Nikolay edited on 2006-09-13 09:01:29.0 |
Reassigned from Philippe to Martin |
Martin edited on 2006-10-26 16:49:43.0 |
Reassigned to Iulian (this bug is really being pushed around!) |
Iulian edited on 2006-10-26 18:31:43.0 |