[JSR308] annotations on arrays
Chin Wei Ngan
chinwn at comp.nus.edu.sg
Thu Feb 1 18:52:32 EST 2007
On Thu, 1 Feb 2007, Neal Gafter wrote:
> On 2/1/07, Chin Wei Ngan <chinwn at comp.nus.edu.sg> wrote:
>> On Thu, 1 Feb 2007, Neal Gafter wrote:
>> > The dimensions of an array type are not part of the array type in Java
>> > arrays are indexing using int, and the bounds of the array are not part
>> > the type), so I see annotating the "dimensions" as being somewhat out of
>> > scope for the JSR. At best an annotation on the array type could give
>> > information about the values that can be used to index arrays of that
>> > It could be in scope if we open the scope of the JSR to include more of
>> > semantically meaningful nonterminals than just types.
>> I have a slightly different view on this. If we view array as
>> a composite type, the bounds of arrays are in fact "int" field
>> of array object. Hence, bound/dimension _is_ a component of the
>> type of array. The only difference is that bound is always an
>> int type in Java, so there is no need to explicitly re-declare it.
>> That is Java is silent on this bound type in its syntax.
> Even if I accept your premise, the conclusion doesn't follow. I can
> annotate a use of the type String, but that doesn't mean I get to say
> anything about the members of String at the site where String is mentioned.
I believe once we start moving to parameterized (wildcard) types,
you could start to talk about any members of a type. For example,
String can be viewed as List<char>, so you can have annotation
on the list or annotation on the char elements.
More information about the JSR308