Tue, 16 Aug 2016 21:41:28 -0700
Added tag jdk8u102-b33 for changeset 36e3c21b5fca
hannesw@1076 | 1 | /* |
hannesw@1076 | 2 | * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
hannesw@1076 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
hannesw@1076 | 4 | * |
hannesw@1076 | 5 | * This code is free software; you can redistribute it and/or modify it |
hannesw@1076 | 6 | * under the terms of the GNU General Public License version 2 only, as |
hannesw@1076 | 7 | * published by the Free Software Foundation. |
hannesw@1076 | 8 | * |
hannesw@1076 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
hannesw@1076 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
hannesw@1076 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
hannesw@1076 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
hannesw@1076 | 13 | * accompanied this code). |
hannesw@1076 | 14 | * |
hannesw@1076 | 15 | * You should have received a copy of the GNU General Public License version |
hannesw@1076 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
hannesw@1076 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
hannesw@1076 | 18 | * |
hannesw@1076 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
hannesw@1076 | 20 | * or visit www.oracle.com if you need additional information or have any |
hannesw@1076 | 21 | * questions. |
hannesw@1076 | 22 | */ |
hannesw@1076 | 23 | |
hannesw@1076 | 24 | /** |
hannesw@1076 | 25 | * JDK-8062583: Throwing object with error prototype causes error proto to be caught |
hannesw@1076 | 26 | * |
hannesw@1076 | 27 | * @test |
hannesw@1076 | 28 | * @run |
hannesw@1076 | 29 | */ |
hannesw@1076 | 30 | |
hannesw@1076 | 31 | function CustomError() { |
hannesw@1076 | 32 | this.name = "CustomError"; |
hannesw@1076 | 33 | } |
hannesw@1076 | 34 | |
hannesw@1076 | 35 | CustomError.prototype = new Error(); |
hannesw@1076 | 36 | |
hannesw@1076 | 37 | var c1 = new CustomError(); |
hannesw@1076 | 38 | |
hannesw@1076 | 39 | try { |
hannesw@1076 | 40 | throw c1; |
hannesw@1076 | 41 | } catch (e) { |
hannesw@1076 | 42 | print(e === c1); |
hannesw@1076 | 43 | print(e === CustomError.prototype); |
hannesw@1076 | 44 | print(e.stack.replace(/\\/g, '/')); |
hannesw@1076 | 45 | print(e.nashornException.toString().replace(/\\/g, '/')); |
hannesw@1076 | 46 | } |
hannesw@1076 | 47 | |
hannesw@1076 | 48 | var c2 = new CustomError(); |
hannesw@1076 | 49 | Error.captureStackTrace(c2); |
hannesw@1076 | 50 | print(c2.stack.replace(/\\/g, '/')); |
hannesw@1076 | 51 | print(c2.nashornException.toString().replace(/\\/g, '/')); |