Mercurial > people > rkennke > jdk9-shenandoah-final > nashorn
changeset 313:b4e6cc05ce09
8012164: Error.stack needs trimming
Reviewed-by: lagergren, jlaskey
author | sundar |
---|---|
date | Fri, 31 May 2013 17:39:12 +0530 |
parents | 11b81fa7125a |
children | 64250b3a2f2a |
files | src/jdk/nashorn/internal/objects/NativeError.java test/script/basic/JDK-8012164.js test/script/basic/JDK-8012164.js.EXPECTED test/script/basic/NASHORN-108.js.EXPECTED test/script/basic/NASHORN-109.js.EXPECTED test/script/basic/errorstack.js.EXPECTED |
diffstat | 6 files changed, 61 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- a/src/jdk/nashorn/internal/objects/NativeError.java Fri May 31 12:58:02 2013 +0200 +++ b/src/jdk/nashorn/internal/objects/NativeError.java Fri May 31 17:39:12 2013 +0530 @@ -32,6 +32,7 @@ import java.lang.invoke.MethodHandles; import java.util.ArrayList; import java.util.List; +import jdk.nashorn.internal.codegen.CompilerConstants; import jdk.nashorn.internal.objects.annotations.Attribute; import jdk.nashorn.internal.objects.annotations.Constructor; import jdk.nashorn.internal.objects.annotations.Function; @@ -248,7 +249,13 @@ final List<StackTraceElement> filtered = new ArrayList<>(); for (final StackTraceElement st : frames) { if (ECMAErrors.isScriptFrame(st)) { - filtered.add(st); + final String className = "<" + st.getFileName() + ">"; + String methodName = st.getMethodName(); + if (methodName.equals(CompilerConstants.RUN_SCRIPT.symbolName())) { + methodName = "<program>"; + } + filtered.add(new StackTraceElement(className, methodName, + st.getFileName(), st.getLineNumber())); } } res = filtered.toArray();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8012164.js Fri May 31 17:39:12 2013 +0530 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + + +/** + * JDK-8012164: Error.stack needs trimming + * + * @test + * @run + */ + +function func() { + error(); +} + +function error() { + try { + throw new Error('foo'); + } catch (e) { + for (i in e.stack) { + print(e.stack[i]); + } + } +} + +func();
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/script/basic/JDK-8012164.js.EXPECTED Fri May 31 17:39:12 2013 +0530 @@ -0,0 +1,3 @@ +<test/script/basic/JDK-8012164.js>.error(test/script/basic/JDK-8012164.js:38) +<test/script/basic/JDK-8012164.js>.func(test/script/basic/JDK-8012164.js:33) +<test/script/basic/JDK-8012164.js>.<program>(test/script/basic/JDK-8012164.js:46)
--- a/test/script/basic/NASHORN-108.js.EXPECTED Fri May 31 12:58:02 2013 +0200 +++ b/test/script/basic/NASHORN-108.js.EXPECTED Fri May 31 17:39:12 2013 +0530 @@ -1,3 +1,3 @@ -runScript 33 -runScript 32 +<program> 33 +<program> 32 done