Details
-
Bug
-
Resolution: Fixed
-
P4
-
None
-
None
-
b94
-
Verified
Description
Error.stack in other JavaScript engines is usually a string, and has different contents. To help embedders switching from other JavaScript engines, nashorn should present Error.stack in a compatible way. Consider the following -
function error() {
try {
throw new Error('foo');
} catch (e) {
var s = e.stack;
print(typeof s + ' ' + Array.isArray(s));
print(s);
}
}
error();
when run with v8, this prints -
string false
Error: foo
at error (error.js:3:11)
at error.js:11:1
when run with spidermonkey, this prints -
string false
error@error.js:3
@error.js:11
when run with nashorn, this prints -
object true
jdk.nashorn.internal.scripts.Script$error.error(error.js:3),jdk.nashorn.internal.scripts.Script$error.runScript(error.js:11)
The 'jdk.nashorn.internal.scripts.Script$error' is unnecessary and should be removed. runScript is also internal and should be removed. The array should be converted to a String.
function error() {
try {
throw new Error('foo');
} catch (e) {
var s = e.stack;
print(typeof s + ' ' + Array.isArray(s));
print(s);
}
}
error();
when run with v8, this prints -
string false
Error: foo
at error (error.js:3:11)
at error.js:11:1
when run with spidermonkey, this prints -
string false
error@error.js:3
@error.js:11
when run with nashorn, this prints -
object true
jdk.nashorn.internal.scripts.Script$error.error(error.js:3),jdk.nashorn.internal.scripts.Script$error.runScript(error.js:11)
The 'jdk.nashorn.internal.scripts.Script$error' is unnecessary and should be removed. runScript is also internal and should be removed. The array should be converted to a String.