attila@1226: /* attila@1226: * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. attila@1226: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. attila@1226: * attila@1226: * This code is free software; you can redistribute it and/or modify it attila@1226: * under the terms of the GNU General Public License version 2 only, as attila@1226: * published by the Free Software Foundation. attila@1226: * attila@1226: * This code is distributed in the hope that it will be useful, but WITHOUT attila@1226: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or attila@1226: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License attila@1226: * version 2 for more details (a copy is included in the LICENSE file that attila@1226: * accompanied this code). attila@1226: * attila@1226: * You should have received a copy of the GNU General Public License version attila@1226: * 2 along with this work; if not, write to the Free Software Foundation, attila@1226: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. attila@1226: * attila@1226: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA attila@1226: * or visit www.oracle.com if you need additional information or have any attila@1226: * questions. attila@1226: */ attila@1226: attila@1226: /** attila@1226: * JDK-8067139: Finally blocks inlined incorrectly attila@1226: * attila@1226: * @test attila@1226: * @run attila@1226: */ attila@1226: attila@1226: // Test case for JDK-8067139 attila@1226: // as well as for JDK-8030198 which is a duplicate. attila@1226: (function(){ attila@1226: var catchCount = 0; attila@1226: try { attila@1226: (function (){ attila@1226: try { attila@1226: return; attila@1226: } catch(x) { attila@1226: ++catchCount; attila@1226: } finally { attila@1226: throw 0; attila@1226: } attila@1226: })(); attila@1226: Assert.fail(); // must throw attila@1226: } catch(e) { attila@1226: Assert.assertEquals(e, 0); // threw 0 attila@1226: Assert.assertEquals(catchCount, 0); // inner catch never executed attila@1226: } attila@1226: })(); attila@1226: attila@1226: // Test case for JDK-8048862 which is a duplicate of this bug attila@1226: var ret = (function(o) { attila@1226: try{ attila@1226: with(o) { attila@1226: return x; attila@1226: } attila@1226: } finally { attila@1226: try { attila@1226: return x; attila@1226: } catch(e) { attila@1226: Assert.assertTrue(e instanceof ReferenceError); attila@1226: return 2; attila@1226: } attila@1226: } attila@1226: })({x: 1}); attila@1226: Assert.assertEquals(ret, 2); // executed the catch block attila@1226: attila@1226: // Test cases for JDK-8066231 that is a duplicate of this bug attila@1226: // Case 1 attila@1226: (function (){ try { Object; } catch(x if x >>>=0) { throw x2; } finally { } })(); attila@1226: // Case 2 attila@1226: try { attila@1226: (function (){ try { return; } catch(x) { return x ^= 0; } finally { throw 0; } })(); attila@1226: Assert.fail(); attila@1226: } catch(e) { attila@1226: Assert.assertEquals(e, 0); // threw 0 attila@1226: } attila@1226: // Case 3 attila@1226: try { attila@1226: (function (){ try { return; } catch(x) { return x ^= Object; } finally { throw Object; } })(); attila@1226: Assert.fail(); attila@1226: } catch(e) { attila@1226: Assert.assertEquals(e, Object); // threw Object attila@1226: } attila@1226: // Case from comment attila@1226: try { attila@1226: (function () { try { Object } catch(x) { (x=y); return; } finally { throw Object; } })(); attila@1226: Assert.fail(); attila@1226: } catch(e) { attila@1226: Assert.assertEquals(e, Object); // threw Object attila@1226: }