8074661: Forward port AbstractJSObject.getDefaultValue(JSObject, Class)

Reviewed-by: hannesw, sundar
This commit is contained in:
Attila Szegedi 2015-03-11 17:47:28 +01:00
parent 984eae0ebf
commit 7cd70cfbde
2 changed files with 23 additions and 8 deletions

View File

@ -161,9 +161,8 @@ public abstract class AbstractJSObject implements JSObject {
* @return set of property names
*/
@Override
@SuppressWarnings("unchecked")
public Set<String> keySet() {
return Collections.EMPTY_SET;
return Collections.emptySet();
}
/**
@ -172,9 +171,8 @@ public abstract class AbstractJSObject implements JSObject {
* @return set of property values.
*/
@Override
@SuppressWarnings("unchecked")
public Collection<Object> values() {
return Collections.EMPTY_SET;
return Collections.emptySet();
}
// JavaScript instanceof check
@ -249,10 +247,27 @@ public abstract class AbstractJSObject implements JSObject {
* Returns this object's numeric value.
*
* @return this object's numeric value.
* @deprecated use {@link #getDefaultValue(Class)} with {@link Number} hint instead.
*/
@SuppressWarnings("deprecation")
@Override
@Override @Deprecated
public double toNumber() {
return Double.NaN;
}
/**
* When passed an {@link AbstractJSObject}, invokes its {@link #getDefaultValue(Class)} method. When passed any
* other {@link JSObject}, it will obtain its {@code [[DefaultValue]]} method as per ECMAScript 5.1 section
* 8.6.2.
*
* @param jsobj the {@link JSObject} whose {@code [[DefaultValue]]} is obtained.
* @param hint the type hint. Should be either {@code null}, {@code Number.class} or {@code String.class}.
* @return this object's default value.
* @throws UnsupportedOperationException if the conversion can't be performed. The engine will convert this
* exception into a JavaScript {@code TypeError}.
* @deprecated use {@link JSObject#getDefaultValue(Class)} instead.
*/
@Deprecated
public static Object getDefaultValue(final JSObject jsobj, final Class<?> hint) {
return jsobj.getDefaultValue(hint);
}
}

View File

@ -813,7 +813,7 @@ public final class ScriptObjectMirror extends AbstractJSObject implements Bindin
}
}
@Override
@Override @Deprecated
public double toNumber() {
return inGlobal(new Callable<Double>() {
@Override public Double call() {
@ -823,7 +823,7 @@ public final class ScriptObjectMirror extends AbstractJSObject implements Bindin
}
@Override
public Object getDefaultValue(Class<?> hint) {
public Object getDefaultValue(final Class<?> hint) {
return inGlobal(new Callable<Object>() {
@Override public Object call() {
try {