[JSR308] array-valued annotations

Ted Neward ted at tedneward.com
Sun Jan 28 20:02:51 EST 2007


> However, Java does support different types at different levels of an
> array.  For instance, consider an array of type Document[][].
> 
>  * The first level of the array has type Document[][].
>  * The next level (i.the first level's elements) has type Document[].
>  * The final level (the leaves) has type Document.
> 
> These are distinct types, though Java enforces that they have a
> specific relationship to one another.
>
Ugh; now we get into the ugly game of semantics, which is not really a game
I want to play. Suffice it to say, however, that at every level (there
really only being two, by the way, since the "first level" you cite is
really just the reference to the array, and not an array instance itself),
the key element here is the "Document" type--all levels are basically
variations on this core theme, that this is a Document array of some
dimensional rank.

In essence, this suggests that the array must be homogeneous around the type
Document, where rank is established by the number of []'s following it (or
]'s prefixing it, if you prefer JVM syntax).

> I agree that the type at the "leaves" must all be the same -- and they
> must all have the same annotation.
>
Cool. :-)

Ted Neward
Java, .NET, XML Services
Consulting, Teaching, Speaking, Writing
http://www.tedneward.com
 

> -----Original Message-----
> From: Michael Ernst [mailto:mernst at csail.mit.edu]
> Sent: Sunday, January 28, 2007 6:59 AM
> To: Ted Neward
> Cc: 'Gary T. Leavens'; 'Pavel Krupets'; jsr308 at lists.csail.mit.edu
> Subject: RE: [JSR308] array-valued annotations
> 
> Ted-
> 
> > a multidimensional array has to contain all the same type,
> > regardless of the number of dimensions.
> 
> I agree that the type at the "leaves" must all be the same -- and they
> must all have the same annotation.
> 
> However, Java does support different types at different levels of an
> array.  For instance, consider an array of type Document[][].
> 
>  * The first level of the array has type Document[][].
>  * The next level (i.the first level's elements) has type Document[].
>  * The final level (the leaves) has type Document.
> 
> These are distinct types, though Java enforces that they have a
> specific relationship to one another.
> 
> It seems useful to permit different annotations on the distinct types
> at each level.  However, the types/annotations at different levels
> should have specific relationships to one another, just as array types
> already do.  The syntax can enforce this, just as that for array types
> already does.  For instance, you correctly note that the type
> "Document[Object[]]" makes no sense; and the Java syntax makes it
> impossible to write such a nonsensical type.
> 
>                     -Michael Ernst
>                      mernst at csail.mit.edu
> 
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.432 / Virus Database: 268.17.12/653 - Release Date: 1/26/2007
> 11:11 AM
> 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.12/655 - Release Date: 1/28/2007
1:12 PM
 




More information about the JSR308 mailing list