JDK-8179979 : Release Note: Javac incorrectly allows receiver parameters in annotation methods
  • Type: Sub-task
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 9
  • Priority: P2
  • Status: Closed
  • Resolution: Delivered
  • Submitted: 2017-05-09
  • Updated: 2017-09-22
  • Resolved: 2017-05-09
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
9Resolved
Description
javac was erroneously accepting receiver parameters in annotations methods. This implies that tests cases like the one below were being accepted:
```
@interface MethodRun {
    int value(MethodRun this);
}
```
The JLS 8, see JLS8 9.6.1, doesn't allow any formal parameter in annotation methods, this extends to receiver parameters. More specifically, the grammar for annotation types does not allow arbitrary method declarations, instead allowing only AnnotationTypeElementDeclarations. The allowed syntax is:
```
AnnotationTypeElementDeclaration:
{AnnotationTypeElementModifier} UnannType Identifier ( ) [Dims] [DefaultValue];
```
Note that nothing is allowed between the parentheses.