[JSR308] array-valued annotations

Gary T. Leavens leavens at cs.iastate.edu
Thu Jan 25 12:47:47 EST 2007


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




More information about the JSR308 mailing list