20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 25 /** 26 * JDK-8012164: Error.stack needs trimming 27 * 28 * @test 29 * @run 30 */ 31 32 function func() { 33 error(); 34 } 35 36 function error() { 37 try { 38 throw new Error('foo'); 39 } catch (e) { 40 for (i in e.stack) { 41 printFrame(e.stack[i]); 42 } 43 } 44 } 45 46 func(); 47 48 // See JDK-8015855: test/script/basic/JDK-8012164.js fails on Windows 49 // Replace '\' to '/' in class and file names of StackFrameElement objects 50 function printFrame(stack) { 51 var fileName = stack.fileName.replace(/\\/g, '/'); 52 var className = stack.className.replace(/\\/g, '/'); 53 print(className + '.' + stack.methodName + '(' + 54 fileName + ':' + stack.lineNumber + ')'); 55 } | 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 25 /** 26 * JDK-8012164: Error.stack needs trimming 27 * 28 * @test 29 * @run 30 */ 31 32 function func() { 33 error(); 34 } 35 36 function error() { 37 try { 38 throw new Error('foo'); 39 } catch (e) { 40 var frames = e.getStackTrace(); 41 for (i in frames) { 42 printFrame(frames[i]); 43 } 44 } 45 } 46 47 func(); 48 49 // See JDK-8015855: test/script/basic/JDK-8012164.js fails on Windows 50 // Replace '\' to '/' in class and file names of StackFrameElement objects 51 function printFrame(stack) { 52 var fileName = stack.fileName.replace(/\\/g, '/'); 53 var className = stack.className.replace(/\\/g, '/'); 54 print(className + '.' + stack.methodName + '(' + 55 fileName + ':' + stack.lineNumber + ')'); 56 } |