JDK-4035186 : local class instances of inner classes lack a parent
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 1.1
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.5.1
  • CPU: sparc
  • Submitted: 1997-02-27
  • Updated: 1997-09-02
  • Resolved: 1997-09-02
Related Reports
Duplicate :  
Description

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 - ###@###.###
======================================================================

Comments
WORK AROUND Name: mc57594 Date: 02/27/97 ======================================================================
11-06-2004