[JSR308] Enhanced for loops

Mahmood Ali mahmood at MIT.EDU
Sat Aug 9 16:47:24 EDT 2008

Hi Artemus again,

> Once a type is already a generic type (like in Iterator), I fail to  
> see why you would need to use InnerUnique.
> Once a type is generic its generic parameters are fixed. It is  
> incompatible to add additional parameters to an already generic  
> type. Generics can get overboard:
> JList<String, DefaultListModel<String>, DefaultCellEditor<String>,  
> DefaultListSelectionModel, DefaultListCellRenderer, ListUI>
> what would all that "expressiveness" buy you?
Let me rephrase my earlier statement:  Once a type is already a  
generic type __ and the desired polymorphism is already achieved with  
generic polymorphism __ (like in Iterator, List, Collection, Map), I  
fail to see why you would need to use InnerUnique.

 From the last thread, we are both in agreement that it's desirable to  
have another mechanism to supply qualifier arguments independent from  
generics.  In our case studies, we only needed polymorphic qualifiers  
as specified in the manual.  I recognize that you seem to desire more  
qualifier argument capabilities.

Reusing generics to abstract over annotated types (like in containers,  
unlike JList) provides a clean interface for the interfaces.  Consider  
the Iterator interface for example.  We can use the same interface  
without adding any annotations in the cases of the Interned and  
Nullness Checker (and possibly even your Unique system).

Your proposal would require each 'E' in the interface to be  
'@Unique({"T"}) E'.  This clatters the interface.  Furthermore, even  
clients who don't care about uniqueness would need understand this  

> But...
> 1. I would need 2 additional annotations: MaybeUnique and NotUnique.  
> The first would be needed to indicate that the class supports the  
> Unique annotation on its type, the second for cases where the method  
> cannot be executed for unique parameters.
How do you represent such constraints with InnerUnique?  I thought  
that you actually needed this.


More information about the JSR308 mailing list