hannesw@1076: /* hannesw@1076: * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. hannesw@1076: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. hannesw@1076: * hannesw@1076: * This code is free software; you can redistribute it and/or modify it hannesw@1076: * under the terms of the GNU General Public License version 2 only, as hannesw@1076: * published by the Free Software Foundation. hannesw@1076: * hannesw@1076: * This code is distributed in the hope that it will be useful, but WITHOUT hannesw@1076: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or hannesw@1076: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License hannesw@1076: * version 2 for more details (a copy is included in the LICENSE file that hannesw@1076: * accompanied this code). hannesw@1076: * hannesw@1076: * You should have received a copy of the GNU General Public License version hannesw@1076: * 2 along with this work; if not, write to the Free Software Foundation, hannesw@1076: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. hannesw@1076: * hannesw@1076: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA hannesw@1076: * or visit www.oracle.com if you need additional information or have any hannesw@1076: * questions. hannesw@1076: */ hannesw@1076: hannesw@1076: /** hannesw@1076: * JDK-8062583: Throwing object with error prototype causes error proto to be caught hannesw@1076: * hannesw@1076: * @test hannesw@1076: * @run hannesw@1076: */ hannesw@1076: hannesw@1076: function CustomError() { hannesw@1076: this.name = "CustomError"; hannesw@1076: } hannesw@1076: hannesw@1076: CustomError.prototype = new Error(); hannesw@1076: hannesw@1076: var c1 = new CustomError(); hannesw@1076: hannesw@1076: try { hannesw@1076: throw c1; hannesw@1076: } catch (e) { hannesw@1076: print(e === c1); hannesw@1076: print(e === CustomError.prototype); hannesw@1076: print(e.stack.replace(/\\/g, '/')); hannesw@1076: print(e.nashornException.toString().replace(/\\/g, '/')); hannesw@1076: } hannesw@1076: hannesw@1076: var c2 = new CustomError(); hannesw@1076: Error.captureStackTrace(c2); hannesw@1076: print(c2.stack.replace(/\\/g, '/')); hannesw@1076: print(c2.nashornException.toString().replace(/\\/g, '/'));