[JSR308] array-valued annotations

Eugene Kuleshov eu at javatx.org
Tue Jan 30 16:04:23 EST 2007


  Those are very good points.

  I also think it worth to clarify explicitly that Java VM don't really 
have direct support for the multidimensional arrays and as been already 
pointed out, deal with them as with sub arrays. Syntax for the array 
access in the Java language is very compact and clear:

    Document o12 = oo[1][2];

  But then it is compiled into the following bytecode:

    ALOAD 2: oo  // loads variable oo to the stack
    AALOAD  // loads oo[1] value to the stack (let's call it oo'1)
    AALOAD  // loads oo'1[1] value to the stack
    ASTORE 4: o12  // store oo'1[1] value to variable o12

  It is easy to see that we have several values of potentially different 
different types (meaning Java type + annotation-based custom type) and 
it does make sense to be able to express these types for those values.

  Also note that, these annotations not necessary have to come from the 
Java source code (even so they could). Nothing stops from implementing 
domain specific language (with less verbose type declarations) that 
could be compiled into the Java bytecode and but still need to preserve 
its type system for static code analysis.


Perry James wrote:
> Hi all,
>    I've enjoyed the discussion the last few days, but it seems the 
> arguments have started going circles.  If we can reach agreement on 
> how one-dimensional array are to be treated, the case of higher 
> dimensions should take care of itself.  If not, it should at least be 
> much clearer how to proceed.
>    Doesn't the question that we've been discussing boil down to, "Are 
> the reference to an array and the references to its elements the same 
> thing?"  I hope we'll all agree that they aren't.  So far, we are only 
> able to declare an array reference--but not its elements--as final.  
> Why are array elements the only references in the language that we 
> can't make final? 
>    Once nullity attributes are added to the mix, it will become very 
> desirable to annotate an array and its elements differently.
>    Best regards,
>    Perry
> On 1/30/07, *Ted Neward* <ted at tedneward.com 
> <mailto:ted at tedneward.com>> wrote:
>  ...
>     That said, I still question the wisdom of varying the type (where
>     by type I
>     mean type + the locally-declared annotations) within a jagged array
>     declaration. Just seems to contravene the intent of how array
>     declarations
>     work in Java today.
>     ...
> ==
> Perry James
> perry.james at computer.org <mailto:perry.james at computer.org>
> ------------------------------------------------------------------------
> _______________________________________________
> JSR308 mailing list
> JSR308 at lists.csail.mit.edu
> https://lists.csail.mit.edu/mailman/listinfo/jsr308

More information about the JSR308 mailing list