[JSR308] Revisiting array annotations

Michael Ernst mernst at csail.mit.edu
Mon Oct 15 15:40:01 EDT 2007

Sorry for my delayed response to Igor's thoughtful message; I was out
sick at the end of last week (but am getting better now).  Let me
address three issues first, and then devote a separate message to the
most important issue that Igor raised.

1. Igor is right that the list of array syntax proposals is missing 2
items.  Section B.3 of the proposal lays out the space of 6

 * 3 locations for annotations:  inside-brackets, prefix, postfix
 * 2 possibilities for what the annotation modifies:  array, elements

but then explicit enumerates only 4 (not all 6).

I have added the two missing items.  I also changed the proposal
numbers (1-4) to names (ARRAY-IN, ARRAY-PRE, ARRAY-POST, ELTS-IN,

2. I lean against permitting parentheses in type specifications.  I
fear this may change the feel of the Java language, and I want to be
conservative in adopting such changes.  I would also like to see how
often it is necessary in practice.  Obviously, if a compelling case
can be made, then I am willing to change my mind.

3. In a declaration, Java permits array dimensions to be specified
both after the type and after the variable, as in this identity
function on 2-D arrays of Integers:

   Integer[] id(Integer[] x []) [] { return x; }

This syntax was probably motivated by C syntax.  My feeling is that
use of the brackets after the variable is relatively rare and is
usually bad style, so we should focus first on what makes sense and is
readable for the more standard declarations, such as

   Integer[][] id(Integer[][] x) { return x; }

and only then worry about accommodating the other case.


More information about the JSR308 mailing list