type paths for some annotated array references

10 views
Skip to first unread message

Andrew Clement

unread,
Apr 17, 2013, 2:34:57 PM4/17/13
to jsr308-...@googlegroups.com
Hi,

Thanks Mike for answering my previous question, I'm actually working on this implementation for the Eclipse Compiler (resurrecting a patch from a while ago).

I had another quick question, I'm trying to determine whether I need a type path in a certain situation.

I compile two statements:

Object o = new @A String[1];
Object o = new String @A[1];

with javac build 81 (or seemingly with the latest jsr308 lang tools, if I'm using them correctly), I get the same output attribute:

0: #15(): NEW, offset=8

I think I expected the first one to have a type path:

0: #15(): NEW, offset=8, location=[ARRAY]

I'm making this assumption based on the example later in the spec:

@I String @F[] @G[] @H

which suggests that for @F type path is empty whilst @I has a type path of [ARRAY,ARRAY,ARRAY] (i.e. skip over the array components), and on what happens in other places when I use (@A String []).

is new special? am I just getting confused? I seem to be going into areas where I can't quite trust javac now (I know b81 is a little old).

many thanks,
Andy
---
Andy Clement
VMware

ps. maybe the second byte of the type path entry for 'deeper in array' could indicate how much deeper into the array (similarly for deeper in nested type). Use two of them if going deeper than 255 levels in the array but if you have arrays that deep you probably have other problems :)  Not sure how much you care about saving a few bytes here and there...

Werner Dietl

unread,
Apr 17, 2013, 7:10:50 PM4/17/13
to jsr308-...@googlegroups.com, type-annot...@openjdk.java.net
Hi Andy,

> I had another quick question, I'm trying to determine whether I need a type
> path in a certain situation.
>
> I compile two statements:
>
> Object o = new @A String[1];
> Object o = new String @A[1];
>
> with javac build 81 (or seemingly with the latest jsr308 lang tools, if I'm
> using them correctly), I get the same output attribute:
>
> 0: #15(): NEW, offset=8
>
> I think I expected the first one to have a type path:
>
> 0: #15(): NEW, offset=8, location=[ARRAY]

Thanks for noticing this mismatch!
I've fixed it:

http://hg.openjdk.java.net/type-annotations/type-annotations/langtools/rev/fa40c85d24b2

If you're interested in the JSR 308 reference implementation, the
right mailing list is:

http://mail.openjdk.java.net/pipermail/type-annotations-dev/

Comments about the spec should go to:

http://mail.openjdk.java.net/pipermail/type-annotations-spec-comments/

jsr308-discuss is for jsr308-langtools, which is an extension of the
official JSR 308 RI.


> ps. maybe the second byte of the type path entry for 'deeper in array' could
> indicate how much deeper into the array (similarly for deeper in nested
> type). Use two of them if going deeper than 255 levels in the array but if
> you have arrays that deep you probably have other problems :) Not sure how
> much you care about saving a few bytes here and there...

This was discussed and rejected by the EG (unfortunately, as I also
proposed this):

http://mail.openjdk.java.net/pipermail/type-annotations-spec-experts/2012-November/000027.html

Please do let us know if you come across anything else!

Cheers,
cu, WMD.

--
http://www.google.com/profiles/wdietl
Reply all
Reply to author
Forward
0 new messages