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

javac generates unreachable code when using empty semicolon statement

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b15

      Backports

        Description

        The following code is similar to JDK-8022186 with slight difference:

        public class Test {
            void m() {
                try {
                    ;
                } finally {
                    System.out.println("dead code");
                }
            }
        }

        Using javap -v Test:

        void m();
            descriptor: ()V
            flags: (0x0000)
            Code:
              stack=2, locals=2, args_size=1
                 0: getstatic #7 // Field java/lang/System.out:Ljava/io/PrintStream;
                 3: ldc #13 // String dead code
                 5: invokevirtual #15 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
                 8: goto 22
                11: astore_1
                12: getstatic #7 // Field java/lang/System.out:Ljava/io/PrintStream;
                15: ldc #13 // String dead code
                17: invokevirtual #15 // Method java/io/PrintStream.println:(Ljava/lang/String;)V
                20: aload_1
                21: athrow
                22: return
              LineNumberTable:
                line 6: 0
                line 7: 8
                line 6: 11
                line 7: 20
                line 8: 22

          Attachments

            Issue Links

              Activity

                People

                Assignee:
                gli Guoxiong Li
                Reporter:
                yyang Yi Yang
                Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                  Dates

                  Created:
                  Updated:
                  Resolved: