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

No compilation error reported not reported for a binding variable when loop broken with label

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 14
    • Component/s: tools
    • Subcomponent:
    • Resolved In Build:
      b26

      Description

      The below code uses instanceof in do S while(e) statement. It should throw a compilation error as S contains a reachable break statement whose break target contains S. However, the compilation goes through successfully.

      public class PatternTest {
          static public Object b0 = "bb";

          public static void main(String[] args) {
              String res = "";
              Object bx = b0;
              A:
              do {
                  res += "t";
                  break A;
              } while (!(bx instanceof String v));
              System.out.println("Got: " + v);
          }
      }

      There is a LinkageError thrown at runtime. The error log is attached below.

        Attachments

          Activity

            People

            • Assignee:
              jlahoda Jan Lahoda
              Reporter:
              vkhatri Vinod Khatri
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: