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

Finally blocks inlined incorrectly

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: core-libs
    • Subcomponent:
    • Resolved In Build:
      b49
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Backports

        Description

        function f(){
            try {
                return;
            } catch(x) {
                print("Caught " + x);
            } finally {
                throw 0;
            }
        } f()

        This program prints "Caught 0"; it should not. The issue here is that the "throw 0" is inlined in place of the "return" statement, but the catch block still guards the whole block (with the inline finally replacement). We should inline finallies as blocks, flag them as such, and handle flagged blocks when CodeGenerator processes try/catch/finally nodes to split the exception table ranges to exclude inlined finallies (that's the same strategy javac follows).

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  attila Attila Szegedi
                  Reporter:
                  attila Attila Szegedi
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  3 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: