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

Finally blocks inlined incorrectly

XMLWordPrintable

    • b49
    • generic
    • generic
    • Verified

        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).

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

                Created:
                Updated:
                Resolved: