<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Wed, Jul 11, 2018 at 7:28 PM Werner Dietl <<a href="mailto:wdietl@gmail.com" target="_blank">wdietl@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Maybe `copyNewClassAnnotationsToOwner` should now be renamed to<br>
`propagateNewClassAnnotationsToOwner`<br></blockquote><div><br></div><div>Thanks, done.</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">JDK-8207018 seems very related to the current issue, so it would seem<br>
worth-while to fix it at the same time. I added a comment there.<br></blockquote><div><br></div><div>I investigated <span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">JDK-8207018.</span></div><div><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div><div><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">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: <a href="http://hg.openjdk.java.net/jdk/jdk/file/220c9188db4f/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java#l2165" target="_blank">http://hg.openjdk.java.net/jdk/jdk/file/220c9188db4f/src/jdk.compiler/share/classes/com/sun/tools/javac/parser/JavacParser.java#l2165</a>. </span>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.</div><div><br></div><div>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 <span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">JDK-8207018 is fixed.</span></div><div><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline"><br></span></div><div><span style="font-size:small;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Here's the updated webrev: <a href="http://cr.openjdk.java.net/~cushon/8198945/webrev.04/">http://cr.openjdk.java.net/~cushon/8198945/webrev.04/</a></span></div></div></div>