Review request for JDK-8141702: Add support for Symbol property keys

Hannes Wallnoefer hannes.wallnoefer at
Tue Nov 10 14:42:00 UTC 2015

Please review JDK-8141702: Add support for Symbol property keys:

This adds support for Symbols. Symbols are a new type of 
guaranteed-unique property keys that can be used to add properties to 
objects without risking conflicts with existing properties. Symbols are 
used by many other features in ES6, so it helps a lot to have this in.

The patch looks big but for most files it's just the type of property 
keys that changed from String to Object. This change is pretty simple, 
and it does not affect the fast property access path.

I had to jump through some hoops in order to deal with some of the 
strange characteristics of symbols, such as the fact that implicit 
conversion to string or number throws a TypeError. For example, I 
introduced a dedicated toString method in tools.Shell to render results 
so it could display symbols both as top level values and when contained 
in an array (which neither JSType.toString nor 
ScriptRuntime.safeToString would let us do).

I think I explained all these cases sufficiently, but feel free to ask 
if something looks weird.

This change is completely invisible in ES5 mode. I also added a test 
that checks the absence of this and other ES6 features in ES5 mode as 
suggested by Sundar.


More information about the nashorn-dev mailing list