[JSR308] Section 3.5, syntax of array annotations

Lex Spoon lex at lexspoon.org
Fri Aug 3 07:47:46 EDT 2007


Bill Pugh <pugh at cs.umd.edu> wrote:
> Anyway, the annotation you are going want to use most frequently on a  
> multidimensional array is
> 
> @Matrix double [][] data;
> 
> which indicates that data is a rectangular unaliased and unchanging  
> matrix.
> 
> If you want to do something for arrays, I'd encourage attemping  
> something simplier: just come up with a way to annotate the element  
> at the bottom of the array nesting. For example,
> 
> @Nonnull int [] @Nonnegative data;
> 
> to represent a nonnull reference to an array of nonnegative integers.  


Incidentally, the above notation looks backwards to my eye.  The
annotation next to the variable (data) applies to the innermost type
(int), while the annotation next to the innermost type applies to the
variable.  Normally you would expect an annotation to apply to what it
is sitting closest to.

-Lex



More information about the JSR308 mailing list