JDK-6246814 : Private member of type variable wrongly accesible
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0
  • Priority: P4
  • Status: Closed
  • Resolution: Cannot Reproduce
  • OS: generic
  • CPU: generic
  • Submitted: 2005-03-28
  • Updated: 2017-05-09
  • Resolved: 2009-01-21
Related Reports
Relates :  
Description
This program compiles:

class T<X extends T<X>> {
    private int t = 123;
    {
        X x = null;
        x.t = 456; // X inherits private member t? Not according to JLS
    }
}

According to the JLS 4.4 (Type Variables) the members of
a type variable are the same as the intersection type 4.9
(Intersection Types), meaning that this is equivalent:

class T {
    private int t = 123;
    {
        class X extends T {}
        X x = null;
        x.t = 456;
    }
}

This program doesn't compile.

###@###.### 2005-03-28 19:33:39 GMT

Comments
EVALUATION This has been fixed by the fix of 6711619 in 7 b40
21-01-2009

EVALUATION A bug.
01-09-2005