Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8256266

Binding variables don't correctly support declaration annotations and the final modifier

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: 16
    • Fix Version/s: 16
    • Component/s: tools
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b31
    • Verification:
      Verified

      Backports

        Description

        Consider this code:
        ---
        public class B {
             public void test(Object o) {
                 if (o instanceof @Deprecated String s) {}
             }
        }
        ---
        This produces:
        ---
        /tmp/B.java:3: error: annotation @Deprecated not applicable in this type context
                 if (o instanceof @Deprecated String s) {}
                                  ^
        1 error
        ---

        That is not correct, declaration annotations are currently allowed on the binding variables.

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                jlahoda Jan Lahoda
                Reporter:
                jlahoda Jan Lahoda
                Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: