Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8175198 Javac incorrectly allows receiver parameters in annotation methods
  3. JDK-8179979

Release Note: Javac incorrectly allows receiver parameters in annotation methods

XMLWordPrintable

    • Icon: Sub-task Sub-task
    • Resolution: Delivered
    • Icon: P2 P2
    • 9
    • 9
    • tools
    • Verified

      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.

            vromero Vicente Arturo Romero Zaldivar
            vromero Vicente Arturo Romero Zaldivar
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: