RFR: JDK-8198945: Invalid RuntimeVisibleTypeAnnotations for annotation on anonymous class type parameter
cushon at google.com
Thu Jul 26 16:04:47 UTC 2018
On Wed, Jul 11, 2018 at 7:28 PM Werner Dietl <wdietl at gmail.com> wrote:
> Maybe `copyNewClassAnnotationsToOwner` should now be renamed to
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:
. 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:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the compiler-dev