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

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

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • P2
    • Resolution: Fixed
    • 16
    • 16
    • tools
    • None
    • b31
    • 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

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

                Dates

                  Created:
                  Updated:
                  Resolved: