Accessing static members on type variables

Remi Forax forax at univ-mlv.fr
Fri Apr 4 18:47:55 UTC 2014


On 04/04/2014 08:20 PM, Alex Buckley wrote:
> 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

My bad, I've read the email of Raffaele too fast,
I was thinking of bug 7022052, see 
https://bugs.openjdk.java.net/browse/JDK-7022052

Anyway, it's quite ugly.

Rémi

>
> 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