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

local class instances of inner classes lack a parent

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.1
    • tools
    • None
    • sparc
    • solaris_2.5.1



      Name: mc57594 Date: 02/27/97


      // 1. Save as Bug.java, then:
      // javac Bug.java
      // java Bug
      // 2. SOURCE (follows
      // 3. Output:
      // mgm@marvin$ java Bug
      // bmeth, A.this=A@1dce0622
      // Bug.this=null
      // java.lang.NullPointerException
      // at Bug$1.bmeth(Bug.java:14)
      // at Bug.test(Bug.java:17)
      // at Bug.main(Bug.java:3)
      // mgm@marvin$
      public class Bug {
          public static void main(String[] args) {
      new Bug().test();
          }
          void test() {
      A anA = new A();

      // b does not get a valid pointer to its enclosing Bug instance!
      // It should have a Bug.this & an A.this
      A.B b = anA.new B() {
      void bmeth() {
      super.bmeth();
      System.out.println("Bug.this="+Bug.this);
      bugmeth();
      }
      };
      b.bmeth();
          }
          void bugmeth() {
      System.out.println("bmeth");
          }
      }
      class A {
          class B {
      void bmeth() {
      System.out.println("bmeth, A.this="+A.this);
      }
          }
      }

      company - Integrity Solutions, Inc. , email - ###@###.###
      ======================================================================

            dstoutamsunw David Stoutamire (Inactive)
            mchamnessunw Mark Chamness (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: