Tue, 13 Oct 2015 18:43:30 +0300
Merge
attila@1226 | 1 | /* |
sundar@1482 | 2 | * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
attila@1226 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
sundar@1482 | 4 | * |
attila@1226 | 5 | * This code is free software; you can redistribute it and/or modify it |
attila@1226 | 6 | * under the terms of the GNU General Public License version 2 only, as |
attila@1226 | 7 | * published by the Free Software Foundation. |
sundar@1482 | 8 | * |
attila@1226 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
attila@1226 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
attila@1226 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
attila@1226 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
attila@1226 | 13 | * accompanied this code). |
sundar@1482 | 14 | * |
attila@1226 | 15 | * You should have received a copy of the GNU General Public License version |
attila@1226 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
attila@1226 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
sundar@1482 | 18 | * |
attila@1226 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
attila@1226 | 20 | * or visit www.oracle.com if you need additional information or have any |
attila@1226 | 21 | * questions. |
attila@1226 | 22 | */ |
attila@1226 | 23 | |
attila@1226 | 24 | /** |
attila@1226 | 25 | * JDK-8067139: Finally blocks inlined incorrectly |
attila@1226 | 26 | * |
attila@1226 | 27 | * @test |
attila@1226 | 28 | * @run |
attila@1226 | 29 | */ |
attila@1226 | 30 | |
attila@1226 | 31 | // Test case for JDK-8067139 |
attila@1226 | 32 | // as well as for JDK-8030198 which is a duplicate. |
attila@1226 | 33 | (function(){ |
attila@1226 | 34 | var catchCount = 0; |
attila@1226 | 35 | try { |
attila@1226 | 36 | (function (){ |
attila@1226 | 37 | try { |
attila@1226 | 38 | return; |
attila@1226 | 39 | } catch(x) { |
attila@1226 | 40 | ++catchCount; |
attila@1226 | 41 | } finally { |
attila@1226 | 42 | throw 0; |
attila@1226 | 43 | } |
attila@1226 | 44 | })(); |
attila@1226 | 45 | Assert.fail(); // must throw |
attila@1226 | 46 | } catch(e) { |
attila@1226 | 47 | Assert.assertEquals(e, 0); // threw 0 |
attila@1226 | 48 | Assert.assertEquals(catchCount, 0); // inner catch never executed |
attila@1226 | 49 | } |
attila@1226 | 50 | })(); |
attila@1226 | 51 | |
attila@1226 | 52 | // Test case for JDK-8048862 which is a duplicate of this bug |
attila@1226 | 53 | var ret = (function(o) { |
attila@1226 | 54 | try{ |
attila@1226 | 55 | with(o) { |
attila@1226 | 56 | return x; |
attila@1226 | 57 | } |
attila@1226 | 58 | } finally { |
attila@1226 | 59 | try { |
attila@1226 | 60 | return x; |
attila@1226 | 61 | } catch(e) { |
attila@1226 | 62 | Assert.assertTrue(e instanceof ReferenceError); |
attila@1226 | 63 | return 2; |
attila@1226 | 64 | } |
attila@1226 | 65 | } |
attila@1226 | 66 | })({x: 1}); |
attila@1226 | 67 | Assert.assertEquals(ret, 2); // executed the catch block |
attila@1226 | 68 | |
attila@1226 | 69 | // Test cases for JDK-8066231 that is a duplicate of this bug |
attila@1226 | 70 | // Case 1 |
attila@1226 | 71 | (function (){ try { Object; } catch(x if x >>>=0) { throw x2; } finally { } })(); |
attila@1226 | 72 | // Case 2 |
attila@1226 | 73 | try { |
attila@1226 | 74 | (function (){ try { return; } catch(x) { return x ^= 0; } finally { throw 0; } })(); |
attila@1226 | 75 | Assert.fail(); |
attila@1226 | 76 | } catch(e) { |
attila@1226 | 77 | Assert.assertEquals(e, 0); // threw 0 |
attila@1226 | 78 | } |
attila@1226 | 79 | // Case 3 |
attila@1226 | 80 | try { |
attila@1226 | 81 | (function (){ try { return; } catch(x) { return x ^= Object; } finally { throw Object; } })(); |
attila@1226 | 82 | Assert.fail(); |
attila@1226 | 83 | } catch(e) { |
attila@1226 | 84 | Assert.assertEquals(e, Object); // threw Object |
attila@1226 | 85 | } |
attila@1226 | 86 | // Case from comment |
attila@1226 | 87 | try { |
attila@1226 | 88 | (function () { try { Object } catch(x) { (x=y); return; } finally { throw Object; } })(); |
attila@1226 | 89 | Assert.fail(); |
attila@1226 | 90 | } catch(e) { |
attila@1226 | 91 | Assert.assertEquals(e, Object); // threw Object |
attila@1226 | 92 | } |