RFR: JDK-8198945: Invalid RuntimeVisibleTypeAnnotations for annotation on anonymous class type parameter

Werner Dietl wdietl at gmail.com
Fri Jul 27 20:25:35 UTC 2018

Hi Liam,

thanks, this looks very nice! Removing all this incorrect code is
great. The examples I tried worked correctly.

cu, WMD.
On Thu, Jul 26, 2018 at 12:05 PM Liam Miller-Cushon <cushon at google.com> wrote:
> On Wed, Jul 11, 2018 at 7:28 PM Werner Dietl <wdietl at gmail.com> wrote:
>> Maybe `copyNewClassAnnotationsToOwner` should now be renamed to
>> `propagateNewClassAnnotationsToOwner`
> Thanks, done.
>> JDK-8207018 seems very related to the current issue, so it would seem
>> worth-while to fix it at the same time. I added a comment there.
> I investigated JDK-8207018.
> The parser currently attaches annotations on anonymous class declarations to the modifiers tree of the JCNewClass, and relies on the type annotation handling to disambiguate declaration and type annotations and move the type annotations to the super-type: http://hg.openjdk.java.net/jdk/jdk/file/220c9188db4f/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java#l2165. The disambiguation is incorrectly moving the annotations to the inner-most type of the super-type, instead of the 'left-most' type that appeared in source.
> I think this logic may have been left over from an earlier iteration of type annotation implementation, since declaration annotations on anonymous class declarations are illegal, so it's safe to remove that parser logic and attach any annotations to the super-type. With that simplification the compiler still (correctly) rejects any declaration annotations that appear on anonymous class declarations. The disambiguation currently performed in TypeAnnotations becomes unnecessary, and JDK-8207018 is fixed.
> Here's the updated webrev: http://cr.openjdk.java.net/~cushon/8198945/webrev.04/


More information about the compiler-dev mailing list