Type annotations on inner type that is an array components

Alex Buckley alex.buckley at oracle.com
Fri Jul 20 01:40:06 UTC 2018


Hi Mike,

javac's generation of target_path items for annotated nested types is 
clearly sub-par, and fixing this particular issue may tickle (or even 
create) related issues. I'd therefore lean towards this issue being a P3 
rather than a P4, although javac developers would govern.

The rampdown schedule is at http://openjdk.java.net/projects/jdk/11/. I 
doubt that this P3 can be reported, fixed, tested, and reviewed by the 
start of RDP2, which is when a P3 (or P4) would expect to be dropped or 
deferred. Do you have a fix ready to go?

(Please note that LTS is a non-factor in JEP 3, which describes the 
release process and is linked from the URL above.)

Alex

On 7/19/2018 5:03 PM, Michael Ernst wrote:
> 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
> <mailto: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
>


More information about the compiler-dev mailing list