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

Binding variable surprisingly goes out of scope

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • repo-amber
    • None
    • tools
    • None
    • generic
    • generic

      Consider this corner case:

      public class X {

          public static void main(String args[]) {
              Object o = "Hello";
              if (o __matches String x __matches boolean b1 __matches boolean b2 __matches true) {
                  System.out.println(x);
              }
          }
      }

      I would expect x to be in scope inside the if {} - it is not:

      /home/srikanth/tmp/X.java:6: error: cannot find symbol
                  System.out.println(x);
                                     ^
        symbol: variable x
        location: class X
      1 error

            Unassigned Unassigned
            sadayapalam Srikanth Adayapalam (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: