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

Compiler reports AssertionError for conditional operator ? : and pattern matching for instanceof

    XMLWordPrintable

Details

    • b26

    Description

      Compiler is reporting AssertionError when pattern matching for instanceof is used in the conditional operator ? :

      Sample Code:

      public class TestPattern {
       
            public static void main(String[] args) {
       
                Object ax = "";

                boolean result = (ax instanceof String a) ? (ax instanceof String a) : (! (ax instanceof String a));
       
                System.out.println("result = " + result);

            }
       }

      Result: AssertionError

      Expected result: result = true


      Compiler log is attached below:

      Attachments

        Activity

          People

            jlahoda Jan Lahoda
            rchandra Ravi Chandra
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: