test/script/basic/JDK-8012164.js

Tue, 15 Jan 2019 10:36:25 +0000

author
aefimov
date
Tue, 15 Jan 2019 10:36:25 +0000
changeset 2462
e9169a96a3d1
parent 962
ac62e33a99b0
child 1205
4112748288bb
permissions
-rw-r--r--

Added tag jdk8u202-ga for changeset 7aeae6eb6236

sundar@314 1 /*
sundar@314 2 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
sundar@314 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
attila@962 4 *
sundar@314 5 * This code is free software; you can redistribute it and/or modify it
sundar@314 6 * under the terms of the GNU General Public License version 2 only, as
sundar@314 7 * published by the Free Software Foundation.
attila@962 8 *
sundar@314 9 * This code is distributed in the hope that it will be useful, but WITHOUT
sundar@314 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
sundar@314 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
sundar@314 12 * version 2 for more details (a copy is included in the LICENSE file that
sundar@314 13 * accompanied this code).
attila@962 14 *
sundar@314 15 * You should have received a copy of the GNU General Public License version
sundar@314 16 * 2 along with this work; if not, write to the Free Software Foundation,
sundar@314 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
attila@962 18 *
sundar@314 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
sundar@314 20 * or visit www.oracle.com if you need additional information or have any
sundar@314 21 * questions.
sundar@314 22 */
sundar@314 23
sundar@314 24
sundar@314 25 /**
sundar@314 26 * JDK-8012164: Error.stack needs trimming
sundar@314 27 *
sundar@314 28 * @test
sundar@314 29 * @run
sundar@314 30 */
sundar@314 31
sundar@314 32 function func() {
sundar@314 33 error();
sundar@314 34 }
sundar@314 35
sundar@314 36 function error() {
sundar@314 37 try {
sundar@314 38 throw new Error('foo');
sundar@314 39 } catch (e) {
sundar@378 40 var frames = e.getStackTrace();
sundar@378 41 for (i in frames) {
sundar@378 42 printFrame(frames[i]);
sundar@314 43 }
sundar@314 44 }
sundar@314 45 }
sundar@314 46
sundar@314 47 func();
sundar@320 48
attila@962 49 // See JDK-8015855: test/script/basic/JDK-8012164.js fails on Windows
sundar@320 50 // Replace '\' to '/' in class and file names of StackFrameElement objects
sundar@320 51 function printFrame(stack) {
sundar@320 52 var fileName = stack.fileName.replace(/\\/g, '/');
sundar@320 53 var className = stack.className.replace(/\\/g, '/');
sundar@320 54 print(className + '.' + stack.methodName + '(' +
attila@962 55 fileName + ':' + stack.lineNumber + ')');
sundar@320 56 }

mercurial