Type annotations on inner type that is an array components
Michael Ernst
mernst at cs.washington.edu
Fri Jul 20 00:03:28 UTC 2018
Alex,
Thanks for the confirmation. I appreciate it.
We suspect that this was introduced in a refactoring and not noticed due to
a lack of tests. I would think that this particular scenario is relatively
rare (a public interface that mentions an array of inner types), but it is
a serious issue for some of our users.
I'm not sure what phase of rampdown JDK 11 is in. What are the chances that
this could be fixed before the next LTS release is made?
Thanks,
Mike
On Thu, Jul 19, 2018, 12:23 PM Alex Buckley <alex.buckley at oracle.com> wrote:
> Hi Werner,
>
> On 7/18/2018 4:49 PM, Werner Dietl wrote:
> > class ArrayOfInner {
> > class Inner {}
> >
> > @TA(1) ArrayOfInner. @TA(2) Inner oi;
> > @TA(3) ArrayOfInner. @TA(4) Inner [] oia;
> > @TA(5) Inner i;
> > @TA(6) Inner [] ia;
> > }
> >
> >
> > Compile with javac 8 and according to javap -v field ia has the
> annotation:
> >
> > ArrayOfInner$Inner[] ia;
> > descriptor: [LArrayOfInner$Inner;
> > flags: (0x0000)
> > RuntimeVisibleTypeAnnotations:
> > 0: #10(#11=I#21): FIELD, location=[ARRAY, INNER_TYPE]
> >
> > Compile with javac 9, 10, or a recent 11 build and ia has the annotation:
> >
> > ArrayOfInner$Inner[] ia;
> > descriptor: [LArrayOfInner$Inner;
> > flags: (0x0000)
> > RuntimeVisibleTypeAnnotations:
> > 0: #10(#11=I#21): FIELD, location=[ARRAY]
> >
> > Note the missing INNER_TYPE location.
> >
> > I would like to argue that the Java 8 behavior was correct.
>
> Sounds right. Given source code that denotes the array type "Inner[]",
> the question is whether the component type of that array type is a
> nested type (ArrayOfInner.Inner) or not (just Inner). Logically, yes,
> it's a nested type, so the target_path item deserves an INNER_TYPE entry.
>
> This feels like the kind of detail we've been round and round on in the
> past. That said, I don't see any mails that would have led to javac
> changing how it emits target_path between 8 and 9. The closest suspect
> is a compiler-dev thread from Jan/Feb 2016 -- "Bug in encoding type
> annotations for supertype_targets" -- which spoke about the target_path
> being omitted entirely for an annotated nested type. (JDK-8148504 was
> filed against 8, but it's still open, so it can't have caused any
> collateral damage for a field type's annotation.)
>
> Alex
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20180719/8b3d5ebd/attachment.html>
More information about the compiler-dev
mailing list