JDK-8027261 : Single codepath for attaching annotations to symbols
  • Type: Sub-task
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 8
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • Submitted: 2013-10-24
  • Updated: 2014-07-10
  • Resolved: 2014-06-06
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b19Fixed
Description
Presently, there are two separate codepaths for attaching type annotations to symbols.  Annotations on a base type will be attached by TypeAnnotations.separateAnnotationsKinds, while annotations on arrays, method parameters, and type parameters are attached by TypeAnnotations.findPosition/resolveFrame.

In the following example:

public $A int @B [];

@A will be attached by separateAnnotationsKinds, while @B will be attached by resolveFrame/findPosition.

This leads to confusion, errors, and unmaintainable code.  There should be a single path for attaching annotations.
Comments
8-defer-request: See parent task for justification.
29-10-2013

I agree that this would be desirable. One complication is that for @A, the type annotation in a declaration annotation position, the AST doesn't contain an annotated type tree. The @A needs to be "moved" to the left-most type in the AST. For @B, the type annotations in unique type annotation positions, we have a unique annotated type tree. No "movement" of the annotation is necessary.
24-10-2013