8081813: JSONListAdapter should delegate its [[DefaultValue]] to wrapped object

Wed, 03 Jun 2015 16:44:24 +0200

author
attila
date
Wed, 03 Jun 2015 16:44:24 +0200
changeset 1395
fb99aafd5c0d
parent 1394
07f32a26bc1e
child 1396
d5a9705a27b1

8081813: JSONListAdapter should delegate its [[DefaultValue]] to wrapped object
Reviewed-by: lagergren, sundar

src/jdk/nashorn/api/scripting/AbstractJSObject.java file | annotate | diff | comparison | revisions
src/jdk/nashorn/internal/runtime/JSONListAdapter.java file | annotate | diff | comparison | revisions
     1.1 --- a/src/jdk/nashorn/api/scripting/AbstractJSObject.java	Tue Jun 02 10:55:17 2015 +0200
     1.2 +++ b/src/jdk/nashorn/api/scripting/AbstractJSObject.java	Wed Jun 03 16:44:24 2015 +0200
     1.3 @@ -28,6 +28,7 @@
     1.4  import java.util.Collection;
     1.5  import java.util.Collections;
     1.6  import java.util.Set;
     1.7 +import jdk.nashorn.internal.runtime.JSONListAdapter;
     1.8  import jdk.nashorn.internal.runtime.JSType;
     1.9  
    1.10  /**
    1.11 @@ -282,6 +283,8 @@
    1.12      public static Object getDefaultValue(final JSObject jsobj, final Class<?> hint) {
    1.13          if (jsobj instanceof AbstractJSObject) {
    1.14              return ((AbstractJSObject)jsobj).getDefaultValue(hint);
    1.15 +        } else if (jsobj instanceof JSONListAdapter) {
    1.16 +            return ((JSONListAdapter)jsobj).getDefaultValue(hint);
    1.17          }
    1.18          return DefaultValueImpl.getDefaultValue(jsobj, hint);
    1.19      }
     2.1 --- a/src/jdk/nashorn/internal/runtime/JSONListAdapter.java	Tue Jun 02 10:55:17 2015 +0200
     2.2 +++ b/src/jdk/nashorn/internal/runtime/JSONListAdapter.java	Wed Jun 03 16:44:24 2015 +0200
     2.3 @@ -28,6 +28,7 @@
     2.4  import java.util.Collection;
     2.5  import java.util.List;
     2.6  import java.util.Set;
     2.7 +import jdk.nashorn.api.scripting.AbstractJSObject;
     2.8  import jdk.nashorn.api.scripting.JSObject;
     2.9  import jdk.nashorn.api.scripting.ScriptObjectMirror;
    2.10  import jdk.nashorn.internal.objects.Global;
    2.11 @@ -153,4 +154,16 @@
    2.12      public double toNumber() {
    2.13          return obj.toNumber();
    2.14      }
    2.15 +
    2.16 +    /**
    2.17 +     * Implements this object's {@code [[DefaultValue]]} method by returning its wrapped object's {@code [[DefaultValue]]}.
    2.18 +     *
    2.19 +     * @param hint the type hint. Should be either {@code null}, {@code Number.class} or {@code String.class}.
    2.20 +     * @return the wrapped object's default value.
    2.21 +     * @throws UnsupportedOperationException if the conversion can't be performed. The engine will convert this
    2.22 +     * exception into a JavaScript {@code TypeError}.
    2.23 +     */
    2.24 +    public Object getDefaultValue(final Class<?> hint) {
    2.25 +        return AbstractJSObject.getDefaultValue(obj, hint);
    2.26 +    }
    2.27  }

mercurial