sundar@314: /* sundar@314: * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. sundar@314: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. attila@962: * sundar@314: * This code is free software; you can redistribute it and/or modify it sundar@314: * under the terms of the GNU General Public License version 2 only, as sundar@314: * published by the Free Software Foundation. attila@962: * sundar@314: * This code is distributed in the hope that it will be useful, but WITHOUT sundar@314: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or sundar@314: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License sundar@314: * version 2 for more details (a copy is included in the LICENSE file that sundar@314: * accompanied this code). attila@962: * sundar@314: * You should have received a copy of the GNU General Public License version sundar@314: * 2 along with this work; if not, write to the Free Software Foundation, sundar@314: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. attila@962: * sundar@314: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA sundar@314: * or visit www.oracle.com if you need additional information or have any sundar@314: * questions. sundar@314: */ sundar@314: sundar@314: sundar@314: /** sundar@314: * JDK-8012164: Error.stack needs trimming sundar@314: * sundar@314: * @test sundar@314: * @run sundar@314: */ sundar@314: sundar@314: function func() { sundar@314: error(); sundar@314: } sundar@314: sundar@314: function error() { sundar@314: try { sundar@314: throw new Error('foo'); sundar@314: } catch (e) { sundar@378: var frames = e.getStackTrace(); sundar@378: for (i in frames) { sundar@378: printFrame(frames[i]); sundar@314: } sundar@314: } sundar@314: } sundar@314: sundar@314: func(); sundar@320: attila@962: // See JDK-8015855: test/script/basic/JDK-8012164.js fails on Windows sundar@320: // Replace '\' to '/' in class and file names of StackFrameElement objects sundar@320: function printFrame(stack) { sundar@320: var fileName = stack.fileName.replace(/\\/g, '/'); sundar@320: var className = stack.className.replace(/\\/g, '/'); sundar@320: print(className + '.' + stack.methodName + '(' + attila@962: fileName + ':' + stack.lineNumber + ')'); sundar@320: }