# HG changeset patch # User hannesw # Date 1506073958 -7200 # Node ID 82d45783c13353caeff18b6cf9b70ffefe4c8338 # Parent 7490a799fccf213c463b9c684cfe199eb985eb61 8186180: Symbol.__proto__ results in error with format string placeholder Reviewed-by: sundar, hannesw Contributed-by: priya.lakshmi.muthuswamy@oracle.com diff -r 7490a799fccf -r 82d45783c133 src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeSymbol.java --- a/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeSymbol.java Fri Sep 22 11:48:57 2017 +0200 +++ b/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/objects/NativeSymbol.java Fri Sep 22 11:52:38 2017 +0200 @@ -93,7 +93,7 @@ } else if (self instanceof NativeSymbol) { return ((NativeSymbol) self).symbol; } else { - throw typeError("not.a.symbol"); + throw typeError("not.a.symbol", ScriptRuntime.safeToString(self)); } } diff -r 7490a799fccf -r 82d45783c133 test/nashorn/script/basic/es6/JDK-8186180.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/nashorn/script/basic/es6/JDK-8186180.js Fri Sep 22 11:52:38 2017 +0200 @@ -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()); diff -r 7490a799fccf -r 82d45783c133 test/nashorn/script/basic/es6/JDK-8186180.js.EXPECTED --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/nashorn/script/basic/es6/JDK-8186180.js.EXPECTED Fri Sep 22 11:52:38 2017 +0200 @@ -0,0 +1,3 @@ +TypeError: [object Symbol] is not a symbol. +TypeError: [object Symbol] is not a symbol. +Symbol(foo)