[JSR308] Syntax of annotations on arrays

Eugene Kuleshov eu at javatx.org
Tue Jan 30 20:12:22 EST 2007

Michael Ernst wrote:
>>   The problem I see with this syntax is that it may interfere with the 
>> expression used for array dimensions. Java language currently allow to 
>> write something like this:
>>   int n;
>>   Document[] d = new Document[n = 5];
>>   and we may end up with something like new Document[@Readonly n = 5], 
>> which doesn't seem allow to identify if annotation belong to the array 
>> element or to the expression defining its index or dimensions.
> At present, the proposal does not permit an annotation to be directly
> attached to an arbitrary expression.  Therefore, in the above it is clear
> that the annotation applies to the array element.
> If we were to change the proposal to permit annotation of arbitrary
> expressions, then the example would indeed be ambiguous.  So at such time
> as we permit such annotations, we could re-visit this example.
  I've used bad wording and meant to say that @ReadOnly annotation could 
belong to the "n" variable.

  We should clarify "local variables" in Figure 2 table (page 8) if it 
is for declaration only or also for access.
  There are some use cases when annotation need to be scoped by the 
location where access happens, but that can be addressed at some level 
by annotating code blocks.


More information about the JSR308 mailing list