JDK-7118412 : Shadowing of type-variables vs. member types
  • Type: Bug
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: unknown
  • Submitted: 2011-12-06
  • Updated: 2018-12-13
  • Resolved: 2013-08-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 8
8 b106Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
5060485 made an attempt at fixing an issue with shadowing of type-variables w.r.t. member type declarations. Unfortunately the fix is incomplete - the following code works:

public class X<Y> {

  static public class Y {}

  static public class Y1 <T extends X<Y>> {
  }

}

Showing that, in the declaration of Y1, Y is correctly resolved to the nested class, not the type-parameter. However there are cases in which javac still gets shadowing wrong:

class Test<T> {
    static class T { }
    static T q;
} 

This fails with the following message:

TestBug.java:13: non-static class T cannot be referenced from a static context
    static T q;
           ^
1 error

Revealing that javac is resolving T to the type-variable type rather than to the class type.

Comments
Awaiting final reviews.
20-08-2013

CCC finalized and resubmitted.
23-07-2013

Fix is prepared, CCC approval pending experiments on the code corpus.
19-06-2013

After discussions with Dan Smith and Alex Buckley, we deemed that the shadowing of non-static inner classes by type parameters is also incorrect.. The root cause of this issue is the way that javac sets up its scopes. Fixing it is not trivial.
14-05-2013