8186180: Symbol.__proto__ results in error with format string placeholder

Reviewed-by: sundar, hannesw
This commit is contained in:
Priya Lakshmi Muthuswamy 2017-09-22 11:52:38 +02:00 committed by Hannes Wallnöfer
parent ea3a3f20d5
commit 6c1410fffa
3 changed files with 47 additions and 1 deletions
src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects
test/nashorn/script/basic/es6

@ -93,7 +93,7 @@ public final class NativeSymbol extends ScriptObject {
} else if (self instanceof NativeSymbol) {
return ((NativeSymbol) self).symbol;
} else {
throw typeError("not.a.symbol");
throw typeError("not.a.symbol", ScriptRuntime.safeToString(self));
}
}

@ -0,0 +1,43 @@
/*
* Copyright (c) 2017, 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-8186180: Symbol.__proto__ results in error with format string placeholder
*
* @test
* @run
* @option --language=es6
*/
var sym = Symbol('foo');
try {
print(sym.__proto__);
} catch (e) {
print(e);
}
try {
print(Symbol.prototype.toString());
} catch (e) {
print(e);
}
print(Symbol('foo').toString());

@ -0,0 +1,3 @@
TypeError: [object Symbol] is not a symbol.
TypeError: [object Symbol] is not a symbol.
Symbol(foo)