[JSR308] array-valued annotations

Ted Neward ted at tedneward.com
Sat Jan 27 22:09:41 EST 2007


I think I see Pavel's point, though; the declaration "doc" implicitly
suggests that all of the dimensions to the "jagged" array behind the
reference are of the same type (Document). I can't declare the different
dimensions to be of different types, a la:

Document[Object[]] doc = ...

Meaning, a single dimenion of Document objects each of which in turn are
also references to Object arrays. (Makes no sense!)

If annotations are to be considered part of the type's signature (which is
WAAAAY beyond what we designed or had in mind), then Pavel's right, a
multidimensional array has to contain all the same type, regardless of the
number of dimensions.

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

> -----Original Message-----
> From: jsr308-bounces at lists.csail.mit.edu [mailto:jsr308-
> bounces at lists.csail.mit.edu] On Behalf Of Gary T. Leavens
> Sent: Thursday, January 25, 2007 9:48 AM
> To: Pavel Krupets
> Cc: jsr308 at lists.csail.mit.edu
> Subject: Re: [JSR308] array-valued annotations
> 
> Hi Pavel and all,
> 
> On Thu, 25 Jan 2007, Pavel Krupets wrote:
> 
> > Hello,
> >
> > I don't think it's appropriate to use annotations like:
> > "Document[][@Readonly]". What I mean is that there is no much sense in
> > specifying different annotations for different dimensions of the array.
> If
> > such behavior is needed other types can be used (like List<...>, etc). I
> > think annotations should be used only with:
> >
> > - array as an object (like: @NonNull @Readonly Document[][] doc = ...)
> > - objects which are stored inside arrays (like: Document @NonNull
> > @Readonly [][] doc = ...)
> >
> > The reason behind this is that array (one or multi-dimensional) is an
> > 'atomic' type which has type of stored object and dimensions. Just want
> to
> > keep things simple.
> 
> I agree that keeping things simple is good when possible.  But
> semantically, each array declared is itself a location which holds a
> collection of locations.  Thus, to simplify to one dimension:
> 
>     Document[] docs;
> 
> could look like
> 
>                        0  1  2  3
>     docs [ *-]------> [  |  |  |  ]
> 
> and the location named doc can be null or readonly independent of the
> locations doc[0]..doc[3].  The same holds for readonly.
> 
> You would lose expressiveness if you can't independently talk about
> these different locations.
> 
>          Gary T. Leavens
>          Department of Computer Science, Iowa State University
>          229 Atanasoff Hall, Ames, Iowa 50011-1041 USA
>          http://www.cs.iastate.edu/~leavens  phone: +1-515-294-1580
> 
> 
> _______________________________________________
> JSR308 mailing list
> JSR308 at lists.csail.mit.edu
> https://lists.csail.mit.edu/mailman/listinfo/jsr308
> 
> --
> No virus found in this incoming message.
> Checked by AVG Free Edition.
> Version: 7.5.432 / Virus Database: 268.17.11/652 - Release Date: 1/25/2007
> 3:32 PM
> 

-- 
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.432 / Virus Database: 268.17.12/653 - Release Date: 1/26/2007
11:11 AM
 




More information about the JSR308 mailing list