[Checkers] Q about wildcard bounds

Mahmood Ali mahmood at MIT.EDU
Sun Feb 8 18:23:24 EST 2009


I have been thinking about the alternative proposals regarding  
wildcard bounds.  I am not quite sure that if I fully understood you.   
So let me explain what I understood and then talk about it.

My understanding:
We treat wildcard bounds just like generics.  So we modify section  
4.3.12 to specify 'Generic Type Annotations and Arrays and Wildcards'  
and have the additional fields be:
     // for generic location
     u2 location_length;
     u1 location[location_length];

     u1 is_wildcard_bound; // info can be put in target_type_value
     //  if is_wildcard_bound
     u2 wildcard_location_length;
     u1 wildcard_location[wildcard_location_length];

With this proposal reference_info would really be describing the  
wildcard itself and simply use the additional fields to locate the  
annotation within the wildcard bound.  This is analogues to generics  
where reference_info really describes the location of the raw type.

I have formed my opinion, and I think that I am more inclined to such  
change.  It's consistent with the current inside-outness (I forgot  
your naming convention) and may lead to a more compact reference_info.

However, the additional fields need to be modified to address nested  
wildcards, e.g. List<? extends List<? extends List<? extends @A  

Here is a slightly different proposal for 4.3.12
   u2 location_length;
   u1 location[location_length];

   u1 no_wildcards;  // number of nested wildcards
   // if no_wildcards != 0
     u2 wildcard_location_length;
     u1 wildcard_location[wildcard_location_length];
   } wildcard_info[no_wildcards];

I don't have a strong opinion about the order of the elements in  
wildcard_info array.

This proposal is superior to the current info as reference_info field  
is duplicated multiple times now.  In the case List<? extends List<?  
extends @A String>>, the reference_info of both wildcards will contain  
similar info about their location (e.g. method return type or not).


P.S. Sorry I wrote this email in a rush.

More information about the checkers mailing list