Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4251061

javac-ea bug accessing protected method of enclosing class' superclass

XMLWordPrintable

    • kestrel
    • generic
    • generic



      Name: mc57594 Date: 06/30/99


      Javac-ea (early access release, May 1999)

      1. javac-ea says it is an error for an anonymous class to call a
      protected method of the enclosing class' superclass.
      (Anonymous classes have the same access rights as their
      enclosing class, and should be able to call a protected method of
      the enclosing class' superclass).

      2. javac-ea runs into an internal error if the target qualifier is left off.

      ..............................................................................
      /**/import java.util.Vector; // example superclass with protected method
      /**/
      /**/public class BugProtectedSuperAccessFromAnonClass extends Vector {
      /**/ public static void main(String[] args) {
      /**/ new BugProtectedSuperAccessFromAnonClass().test();
      /**/ }
      /**/ public void test() {
      /**/ Runnable r = new Runnable() {
      /**/ public void run() {
      /**/ // call protected method of enclosing class' superclass
      /**/ BugProtectedSuperAccessFromAnonClass.this.removeRange(0,0);
      /**/ /* Produces the following error
      /**/ BugProtectedSuperAccessFromAnonClass.java:11:
      /**/ method removeRange(int,int) has protected access
      /**/ in class java.util.Vector
      /**/ BugProtectedSuperAccessFromAnonClass.this.removeRange(0,0);
      /**/ ^
      /**/ Note: an alternative,
      /**/ removeRange(0,0);
      /**/ Produces the following error:
      /**/ java.lang.InternalError: assertion failed: class def not found:
      /**/ method removeRange(int,int) in class java.util.Vector
      /**/ at com.sun.tools.javac.v8.util.Util.assert(Util.java:32)
      /**/ at com.sun.tools.javac.v8.comp.TransInner.makeAccessible(TransInner.java:685)
      /**/ at com.sun.tools.javac.v8.comp.TransInner.translateTopLevelClass(TransInner.java:1446)
      /**/ at com.sun.tools.javac.v8.JavaCompiler.compile(JavaCompiler.java:348)
      /**/ at com.sun.tools.javac.v8.Main.compile(Main.java:247)
      /**/ at com.sun.tools.javac.Main.main(Main.java:16)
      /**/ */
      /**/ }};
      /**/ }
      /**/}
      ..............................................................................
      (Review ID: 84873)
      ======================================================================

            wmaddoxsunw William Maddox (Inactive)
            mchamnessunw Mark Chamness (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: