Accessing static members on type variables
    Alex Buckley 
    alex.buckley at oracle.com
       
    Fri Apr  4 18:20:51 UTC 2014
    
    
  
Membership of the type variable T is specified by JLS 4.4 and 4.9. The 
members of T are the same as the members of a class QQQ whose direct 
superclass is Outer. Since QQQ would inherit FIELD from Outer, T has a 
member FIELD. There is nothing special about FIELD being static.
Alex
On 4/4/2014 12:54 AM, Raffaele Sgarro wrote:
> Consider the following code (ideone <http://ideone.com/GtBQEy>):
>
> class  Outer{
>    public  static  final  String  FIELD=  "Success!";
> }
>
> class  Test<Textends  Outer>{
>    public  String  test()  {
>      return  T.FIELD;
>    }
> }
>
> Does the JSL allow a type variable T to be used to access static members
> of its upper bound?
    
    
More information about the compiler-dev
mailing list