Merge

Wed, 23 Oct 2013 20:21:23 +0530

author
sundar
date
Wed, 23 Oct 2013 20:21:23 +0530
changeset 650
640c1854f742
parent 647
734f71f8a2c3
parent 649
f31ee3a2847d
child 651
767e85d2a1b3
child 701
b9fdc55a6e28

Merge

src/jdk/nashorn/internal/runtime/ScriptObjectListAdapter.java file | annotate | diff | comparison | revisions
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/jdk/nashorn/api/scripting/AbstractJSObject.java	Wed Oct 23 20:21:23 2013 +0530
     1.3 @@ -0,0 +1,254 @@
     1.4 +/*
     1.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
     1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     1.7 + *
     1.8 + * This code is free software; you can redistribute it and/or modify it
     1.9 + * under the terms of the GNU General Public License version 2 only, as
    1.10 + * published by the Free Software Foundation.  Oracle designates this
    1.11 + * particular file as subject to the "Classpath" exception as provided
    1.12 + * by Oracle in the LICENSE file that accompanied this code.
    1.13 + *
    1.14 + * This code is distributed in the hope that it will be useful, but WITHOUT
    1.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    1.16 + * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    1.17 + * version 2 for more details (a copy is included in the LICENSE file that
    1.18 + * accompanied this code).
    1.19 + *
    1.20 + * You should have received a copy of the GNU General Public License version
    1.21 + * 2 along with this work; if not, write to the Free Software Foundation,
    1.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    1.23 + *
    1.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    1.25 + * or visit www.oracle.com if you need additional information or have any
    1.26 + * questions.
    1.27 + */
    1.28 +
    1.29 +package jdk.nashorn.api.scripting;
    1.30 +
    1.31 +import java.util.Collection;
    1.32 +import java.util.Collections;
    1.33 +import java.util.Set;
    1.34 +
    1.35 +/**
    1.36 + * This is the base class for nashorn ScriptObjectMirror class.
    1.37 + *
    1.38 + * This class can also be subclassed by an arbitrary Java class. Nashorn will
    1.39 + * treat objects of such classes just like nashorn script objects. Usual nashorn
    1.40 + * operations like obj[i], obj.foo, obj.func(), delete obj.foo will be glued
    1.41 + * to appropriate method call of this class.
    1.42 + */
    1.43 +public abstract class AbstractJSObject implements JSObject {
    1.44 +    /**
    1.45 +     * Call this object as a JavaScript function. This is equivalent to
    1.46 +     * 'func.apply(thiz, args)' in JavaScript.
    1.47 +     *
    1.48 +     * @param thiz 'this' object to be passed to the function
    1.49 +     * @param args arguments to method
    1.50 +     * @return result of call
    1.51 +     */
    1.52 +    @Override
    1.53 +    public Object call(final Object thiz, final Object... args) {
    1.54 +        throw new UnsupportedOperationException("call");
    1.55 +    }
    1.56 +
    1.57 +    /**
    1.58 +     * Call this 'constructor' JavaScript function to create a new object.
    1.59 +     * This is equivalent to 'new func(arg1, arg2...)' in JavaScript.
    1.60 +     *
    1.61 +     * @param args arguments to method
    1.62 +     * @return result of constructor call
    1.63 +     */
    1.64 +    @Override
    1.65 +    public Object newObject(final Object... args) {
    1.66 +        throw new UnsupportedOperationException("newObject");
    1.67 +    }
    1.68 +
    1.69 +    /**
    1.70 +     * Evaluate a JavaScript expression.
    1.71 +     *
    1.72 +     * @param s JavaScript expression to evaluate
    1.73 +     * @return evaluation result
    1.74 +     */
    1.75 +    @Override
    1.76 +    public Object eval(final String s) {
    1.77 +        throw new UnsupportedOperationException("eval");
    1.78 +    }
    1.79 +
    1.80 +    /**
    1.81 +     * Retrieves a named member of this JavaScript object.
    1.82 +     *
    1.83 +     * @param name of member
    1.84 +     * @return member
    1.85 +     */
    1.86 +    @Override
    1.87 +    public Object getMember(final String name) {
    1.88 +        return null;
    1.89 +    }
    1.90 +
    1.91 +    /**
    1.92 +     * Retrieves an indexed member of this JavaScript object.
    1.93 +     *
    1.94 +     * @param index index slot to retrieve
    1.95 +     * @return member
    1.96 +     */
    1.97 +    @Override
    1.98 +    public Object getSlot(final int index) {
    1.99 +        return null;
   1.100 +    }
   1.101 +
   1.102 +    /**
   1.103 +     * Does this object have a named member?
   1.104 +     *
   1.105 +     * @param name name of member
   1.106 +     * @return true if this object has a member of the given name
   1.107 +     */
   1.108 +    @Override
   1.109 +    public boolean hasMember(final String name) {
   1.110 +        return false;
   1.111 +    }
   1.112 +
   1.113 +    /**
   1.114 +     * Does this object have a indexed property?
   1.115 +     *
   1.116 +     * @param slot index to check
   1.117 +     * @return true if this object has a slot
   1.118 +     */
   1.119 +    @Override
   1.120 +    public boolean hasSlot(final int slot) {
   1.121 +        return false;
   1.122 +    }
   1.123 +
   1.124 +    /**
   1.125 +     * Remove a named member from this JavaScript object
   1.126 +     *
   1.127 +     * @param name name of the member
   1.128 +     */
   1.129 +    @Override
   1.130 +    public void removeMember(final String name) {
   1.131 +        //empty
   1.132 +    }
   1.133 +
   1.134 +    /**
   1.135 +     * Set a named member in this JavaScript object
   1.136 +     *
   1.137 +     * @param name  name of the member
   1.138 +     * @param value value of the member
   1.139 +     */
   1.140 +    @Override
   1.141 +    public void setMember(final String name, final Object value) {
   1.142 +        //empty
   1.143 +    }
   1.144 +
   1.145 +    /**
   1.146 +     * Set an indexed member in this JavaScript object
   1.147 +     *
   1.148 +     * @param index index of the member slot
   1.149 +     * @param value value of the member
   1.150 +     */
   1.151 +    @Override
   1.152 +    public void setSlot(final int index, final Object value) {
   1.153 +        //empty
   1.154 +    }
   1.155 +
   1.156 +    // property and value iteration
   1.157 +
   1.158 +    /**
   1.159 +     * Returns the set of all property names of this object.
   1.160 +     *
   1.161 +     * @return set of property names
   1.162 +     */
   1.163 +    @Override
   1.164 +    @SuppressWarnings("unchecked")
   1.165 +    public Set<String> keySet() {
   1.166 +        return Collections.EMPTY_SET;
   1.167 +    }
   1.168 +
   1.169 +    /**
   1.170 +     * Returns the set of all property values of this object.
   1.171 +     *
   1.172 +     * @return set of property values.
   1.173 +     */
   1.174 +    @Override
   1.175 +    @SuppressWarnings("unchecked")
   1.176 +    public Collection<Object> values() {
   1.177 +        return Collections.EMPTY_SET;
   1.178 +    }
   1.179 +
   1.180 +    // JavaScript instanceof check
   1.181 +
   1.182 +    /**
   1.183 +     * Checking whether the given object is an instance of 'this' object.
   1.184 +     *
   1.185 +     * @param instance instace to check
   1.186 +     * @return true if the given 'instance' is an instance of this 'function' object
   1.187 +     */
   1.188 +    @Override
   1.189 +    public boolean isInstance(final Object instance) {
   1.190 +        return false;
   1.191 +    }
   1.192 +
   1.193 +    /**
   1.194 +     * Checking whether this object is an instance of the given 'clazz' object.
   1.195 +     *
   1.196 +     * @param clazz clazz to check
   1.197 +     * @return true if this object is an instance of the given 'clazz'
   1.198 +     */
   1.199 +    @Override
   1.200 +    public boolean isInstanceOf(final Object clazz) {
   1.201 +        if (clazz instanceof JSObject) {
   1.202 +            return ((JSObject)clazz).isInstance(this);
   1.203 +        }
   1.204 +
   1.205 +        return false;
   1.206 +    }
   1.207 +
   1.208 +    /**
   1.209 +     * ECMA [[Class]] property
   1.210 +     *
   1.211 +     * @return ECMA [[Class]] property value of this object
   1.212 +     */
   1.213 +    @Override
   1.214 +    public String getClassName() {
   1.215 +        return getClass().getName();
   1.216 +    }
   1.217 +
   1.218 +    /**
   1.219 +     * Is this a function object?
   1.220 +     *
   1.221 +     * @return if this mirror wraps a ECMAScript function instance
   1.222 +     */
   1.223 +    @Override
   1.224 +    public boolean isFunction() {
   1.225 +        return false;
   1.226 +    }
   1.227 +
   1.228 +    /**
   1.229 +     * Is this a 'use strict' function object?
   1.230 +     *
   1.231 +     * @return true if this mirror represents a ECMAScript 'use strict' function
   1.232 +     */
   1.233 +    @Override
   1.234 +    public boolean isStrictFunction() {
   1.235 +        return false;
   1.236 +    }
   1.237 +
   1.238 +    /**
   1.239 +     * Is this an array object?
   1.240 +     *
   1.241 +     * @return if this mirror wraps a ECMAScript array object
   1.242 +     */
   1.243 +    @Override
   1.244 +    public boolean isArray() {
   1.245 +        return false;
   1.246 +    }
   1.247 +
   1.248 +    /**
   1.249 +     * Returns this object's numeric value.
   1.250 +     *
   1.251 +     * @return this object's numeric value.
   1.252 +     */
   1.253 +    @Override
   1.254 +    public double toNumber() {
   1.255 +        return Double.NaN;
   1.256 +    }
   1.257 +}
     2.1 --- a/src/jdk/nashorn/api/scripting/JSObject.java	Tue Oct 22 22:12:24 2013 +0530
     2.2 +++ b/src/jdk/nashorn/api/scripting/JSObject.java	Wed Oct 23 20:21:23 2013 +0530
     2.3 @@ -30,14 +30,12 @@
     2.4  import java.util.Set;
     2.5  
     2.6  /**
     2.7 - * This is the base class for nashorn ScriptObjectMirror class.
     2.8 - *
     2.9 - * This class can also be subclassed by an arbitrary Java class. Nashorn will
    2.10 + * This interface can be implemented by an arbitrary Java class. Nashorn will
    2.11   * treat objects of such classes just like nashorn script objects. Usual nashorn
    2.12   * operations like obj[i], obj.foo, obj.func(), delete obj.foo will be glued
    2.13 - * to appropriate method call of this class.
    2.14 + * to appropriate method call of this interface.
    2.15   */
    2.16 -public abstract class JSObject {
    2.17 +public interface JSObject {
    2.18      /**
    2.19       * Call this object as a JavaScript function. This is equivalent to
    2.20       * 'func.apply(thiz, args)' in JavaScript.
    2.21 @@ -46,9 +44,7 @@
    2.22       * @param args arguments to method
    2.23       * @return result of call
    2.24       */
    2.25 -    public Object call(final Object thiz, final Object... args) {
    2.26 -        throw new UnsupportedOperationException("call");
    2.27 -    }
    2.28 +    public Object call(final Object thiz, final Object... args);
    2.29  
    2.30      /**
    2.31       * Call this 'constructor' JavaScript function to create a new object.
    2.32 @@ -57,9 +53,7 @@
    2.33       * @param args arguments to method
    2.34       * @return result of constructor call
    2.35       */
    2.36 -    public Object newObject(final Object... args) {
    2.37 -        throw new UnsupportedOperationException("newObject");
    2.38 -    }
    2.39 +    public Object newObject(final Object... args);
    2.40  
    2.41      /**
    2.42       * Evaluate a JavaScript expression.
    2.43 @@ -67,20 +61,7 @@
    2.44       * @param s JavaScript expression to evaluate
    2.45       * @return evaluation result
    2.46       */
    2.47 -    public Object eval(final String s) {
    2.48 -        throw new UnsupportedOperationException("eval");
    2.49 -    }
    2.50 -
    2.51 -    /**
    2.52 -     * Call a JavaScript function member of this object.
    2.53 -     *
    2.54 -     * @param name name of the member function to call
    2.55 -     * @param args arguments to be passed to the member function
    2.56 -     * @return result of call
    2.57 -     */
    2.58 -    public Object callMember(final String name, final Object... args) {
    2.59 -        throw new UnsupportedOperationException("call");
    2.60 -    }
    2.61 +    public Object eval(final String s);
    2.62  
    2.63      /**
    2.64       * Retrieves a named member of this JavaScript object.
    2.65 @@ -88,9 +69,7 @@
    2.66       * @param name of member
    2.67       * @return member
    2.68       */
    2.69 -    public Object getMember(final String name) {
    2.70 -        return null;
    2.71 -    }
    2.72 +    public Object getMember(final String name);
    2.73  
    2.74      /**
    2.75       * Retrieves an indexed member of this JavaScript object.
    2.76 @@ -98,9 +77,7 @@
    2.77       * @param index index slot to retrieve
    2.78       * @return member
    2.79       */
    2.80 -    public Object getSlot(final int index) {
    2.81 -        return null;
    2.82 -    }
    2.83 +    public Object getSlot(final int index);
    2.84  
    2.85      /**
    2.86       * Does this object have a named member?
    2.87 @@ -108,9 +85,7 @@
    2.88       * @param name name of member
    2.89       * @return true if this object has a member of the given name
    2.90       */
    2.91 -    public boolean hasMember(final String name) {
    2.92 -        return false;
    2.93 -    }
    2.94 +    public boolean hasMember(final String name);
    2.95  
    2.96      /**
    2.97       * Does this object have a indexed property?
    2.98 @@ -118,18 +93,14 @@
    2.99       * @param slot index to check
   2.100       * @return true if this object has a slot
   2.101       */
   2.102 -    public boolean hasSlot(final int slot) {
   2.103 -        return false;
   2.104 -    }
   2.105 +    public boolean hasSlot(final int slot);
   2.106  
   2.107      /**
   2.108       * Remove a named member from this JavaScript object
   2.109       *
   2.110       * @param name name of the member
   2.111       */
   2.112 -    public void removeMember(final String name) {
   2.113 -        //empty
   2.114 -    }
   2.115 +    public void removeMember(final String name);
   2.116  
   2.117      /**
   2.118       * Set a named member in this JavaScript object
   2.119 @@ -137,9 +108,7 @@
   2.120       * @param name  name of the member
   2.121       * @param value value of the member
   2.122       */
   2.123 -    public void setMember(final String name, final Object value) {
   2.124 -        //empty
   2.125 -    }
   2.126 +    public void setMember(final String name, final Object value);
   2.127  
   2.128      /**
   2.129       * Set an indexed member in this JavaScript object
   2.130 @@ -147,9 +116,7 @@
   2.131       * @param index index of the member slot
   2.132       * @param value value of the member
   2.133       */
   2.134 -    public void setSlot(final int index, final Object value) {
   2.135 -        //empty
   2.136 -    }
   2.137 +    public void setSlot(final int index, final Object value);
   2.138  
   2.139      // property and value iteration
   2.140  
   2.141 @@ -158,20 +125,14 @@
   2.142       *
   2.143       * @return set of property names
   2.144       */
   2.145 -    @SuppressWarnings("unchecked")
   2.146 -    public Set<String> keySet() {
   2.147 -        return Collections.EMPTY_SET;
   2.148 -    }
   2.149 +    public Set<String> keySet();
   2.150  
   2.151      /**
   2.152       * Returns the set of all property values of this object.
   2.153       *
   2.154       * @return set of property values.
   2.155       */
   2.156 -    @SuppressWarnings("unchecked")
   2.157 -    public Collection<Object> values() {
   2.158 -        return Collections.EMPTY_SET;
   2.159 -    }
   2.160 +    public Collection<Object> values();
   2.161  
   2.162      // JavaScript instanceof check
   2.163  
   2.164 @@ -181,9 +142,7 @@
   2.165       * @param instance instace to check
   2.166       * @return true if the given 'instance' is an instance of this 'function' object
   2.167       */
   2.168 -    public boolean isInstance(final Object instance) {
   2.169 -        return false;
   2.170 -    }
   2.171 +    public boolean isInstance(final Object instance);
   2.172  
   2.173      /**
   2.174       * Checking whether this object is an instance of the given 'clazz' object.
   2.175 @@ -191,56 +150,40 @@
   2.176       * @param clazz clazz to check
   2.177       * @return true if this object is an instance of the given 'clazz'
   2.178       */
   2.179 -    public boolean isInstanceOf(final Object clazz) {
   2.180 -        if (clazz instanceof JSObject) {
   2.181 -            return ((JSObject)clazz).isInstance(this);
   2.182 -        }
   2.183 -
   2.184 -        return false;
   2.185 -    }
   2.186 +    public boolean isInstanceOf(final Object clazz);
   2.187  
   2.188      /**
   2.189       * ECMA [[Class]] property
   2.190       *
   2.191       * @return ECMA [[Class]] property value of this object
   2.192       */
   2.193 -    public String getClassName() {
   2.194 -        return getClass().getName();
   2.195 -    }
   2.196 +    public String getClassName();
   2.197  
   2.198      /**
   2.199       * Is this a function object?
   2.200       *
   2.201       * @return if this mirror wraps a ECMAScript function instance
   2.202       */
   2.203 -    public boolean isFunction() {
   2.204 -        return false;
   2.205 -    }
   2.206 +    public boolean isFunction();
   2.207  
   2.208      /**
   2.209       * Is this a 'use strict' function object?
   2.210       *
   2.211       * @return true if this mirror represents a ECMAScript 'use strict' function
   2.212       */
   2.213 -    public boolean isStrictFunction() {
   2.214 -        return false;
   2.215 -    }
   2.216 +    public boolean isStrictFunction();
   2.217  
   2.218      /**
   2.219       * Is this an array object?
   2.220       *
   2.221       * @return if this mirror wraps a ECMAScript array object
   2.222       */
   2.223 -    public boolean isArray() {
   2.224 -        return false;
   2.225 -    }
   2.226 +    public boolean isArray();
   2.227  
   2.228      /**
   2.229       * Returns this object's numeric value.
   2.230       *
   2.231       * @return this object's numeric value.
   2.232       */
   2.233 -    public double toNumber() {
   2.234 -        return Double.NaN;
   2.235 -    }
   2.236 +    public double toNumber();
   2.237  }
     3.1 --- a/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java	Tue Oct 22 22:12:24 2013 +0530
     3.2 +++ b/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java	Wed Oct 23 20:21:23 2013 +0530
     3.3 @@ -51,7 +51,7 @@
     3.4  /**
     3.5   * Mirror object that wraps a given Nashorn Script object.
     3.6   */
     3.7 -public final class ScriptObjectMirror extends JSObject implements Bindings {
     3.8 +public final class ScriptObjectMirror extends AbstractJSObject implements Bindings {
     3.9      private static AccessControlContext getContextAccCtxt() {
    3.10          final Permissions perms = new Permissions();
    3.11          perms.add(new RuntimePermission(Context.NASHORN_GET_CONTEXT));
    3.12 @@ -162,7 +162,6 @@
    3.13          });
    3.14      }
    3.15  
    3.16 -    @Override
    3.17      public Object callMember(final String functionName, final Object... args) {
    3.18          functionName.getClass(); // null check
    3.19          final ScriptObject oldGlobal = Context.getGlobal();
     4.1 --- a/src/jdk/nashorn/internal/runtime/JSType.java	Tue Oct 22 22:12:24 2013 +0530
     4.2 +++ b/src/jdk/nashorn/internal/runtime/JSType.java	Wed Oct 23 20:21:23 2013 +0530
     4.3 @@ -1043,6 +1043,10 @@
     4.4              return toNumber((ScriptObject)obj);
     4.5          }
     4.6  
     4.7 +        if (obj instanceof JSObject) {
     4.8 +            return ((JSObject)obj).toNumber();
     4.9 +        }
    4.10 +
    4.11          return Double.NaN;
    4.12      }
    4.13  
     5.1 --- a/src/jdk/nashorn/internal/runtime/ListAdapter.java	Tue Oct 22 22:12:24 2013 +0530
     5.2 +++ b/src/jdk/nashorn/internal/runtime/ListAdapter.java	Wed Oct 23 20:21:23 2013 +0530
     5.3 @@ -33,6 +33,7 @@
     5.4  import java.util.RandomAccess;
     5.5  import java.util.concurrent.Callable;
     5.6  import jdk.nashorn.api.scripting.JSObject;
     5.7 +import jdk.nashorn.api.scripting.ScriptObjectMirror;
     5.8  import jdk.nashorn.internal.runtime.linker.Bootstrap;
     5.9  import jdk.nashorn.internal.runtime.linker.InvokeByName;
    5.10  
    5.11 @@ -135,7 +136,8 @@
    5.12       */
    5.13      public static ListAdapter create(final Object obj) {
    5.14          if (obj instanceof ScriptObject) {
    5.15 -            return new ScriptObjectListAdapter((ScriptObject)obj);
    5.16 +            final Object mirror = ScriptObjectMirror.wrap(obj, Context.getGlobal());
    5.17 +            return new JSObjectListAdapter((JSObject)mirror);
    5.18          } else if (obj instanceof JSObject) {
    5.19              return new JSObjectListAdapter((JSObject)obj);
    5.20          } else {
     6.1 --- a/src/jdk/nashorn/internal/runtime/ScriptObjectListAdapter.java	Tue Oct 22 22:12:24 2013 +0530
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,54 +0,0 @@
     6.4 -/*
     6.5 - * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
     6.6 - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     6.7 - *
     6.8 - * This code is free software; you can redistribute it and/or modify it
     6.9 - * under the terms of the GNU General Public License version 2 only, as
    6.10 - * published by the Free Software Foundation.  Oracle designates this
    6.11 - * particular file as subject to the "Classpath" exception as provided
    6.12 - * by Oracle in the LICENSE file that accompanied this code.
    6.13 - *
    6.14 - * This code is distributed in the hope that it will be useful, but WITHOUT
    6.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    6.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    6.17 - * version 2 for more details (a copy is included in the LICENSE file that
    6.18 - * accompanied this code).
    6.19 - *
    6.20 - * You should have received a copy of the GNU General Public License version
    6.21 - * 2 along with this work; if not, write to the Free Software Foundation,
    6.22 - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
    6.23 - *
    6.24 - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
    6.25 - * or visit www.oracle.com if you need additional information or have any
    6.26 - * questions.
    6.27 - */
    6.28 -
    6.29 -package jdk.nashorn.internal.runtime;
    6.30 -
    6.31 -/**
    6.32 - * A ListAdapter that can wrap a ScriptObject.
    6.33 - */
    6.34 -public final class ScriptObjectListAdapter extends ListAdapter {
    6.35 -    /**
    6.36 -     * Creates a new list wrapper for the specified ScriptObject.
    6.37 -     * @param obj script the object to wrap
    6.38 -     */
    6.39 -    public ScriptObjectListAdapter(final ScriptObject obj) {
    6.40 -        super(obj);
    6.41 -    }
    6.42 -
    6.43 -    @Override
    6.44 -    public int size() {
    6.45 -        return JSType.toInt32(((ScriptObject)obj).getLength());
    6.46 -    }
    6.47 -
    6.48 -    @Override
    6.49 -    protected Object getAt(int index) {
    6.50 -        return ((ScriptObject)obj).get(index);
    6.51 -    }
    6.52 -
    6.53 -    @Override
    6.54 -    protected void setAt(int index, Object element) {
    6.55 -        ((ScriptObject)obj).set(index, element, false);
    6.56 -    }
    6.57 -}
     7.1 --- a/src/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java	Tue Oct 22 22:12:24 2013 +0530
     7.2 +++ b/src/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java	Wed Oct 23 20:21:23 2013 +0530
     7.3 @@ -107,8 +107,6 @@
     7.4                  return c > 2 ? findSetMethod(desc) : findSetIndexMethod();
     7.5              case "call":
     7.6                  return findCallMethod(desc);
     7.7 -            case "callMethod":
     7.8 -                return findCallMethodMethod(desc);
     7.9              case "new":
    7.10                  return findNewMethod(desc);
    7.11              default:
    7.12 @@ -134,13 +132,6 @@
    7.13          return new GuardedInvocation(JSOBJECTLINKER_PUT, null, IS_JSOBJECT_GUARD);
    7.14      }
    7.15  
    7.16 -    private static GuardedInvocation findCallMethodMethod(final CallSiteDescriptor desc) {
    7.17 -        final String methodName = desc.getNameToken(2);
    7.18 -        MethodHandle func = MH.insertArguments(JSOBJECT_CALLMEMBER, 1, methodName);
    7.19 -        func = MH.asCollector(func, Object[].class, desc.getMethodType().parameterCount() - 1);
    7.20 -        return new GuardedInvocation(func, null, IS_JSOBJECT_GUARD);
    7.21 -    }
    7.22 -
    7.23      private static GuardedInvocation findCallMethod(final CallSiteDescriptor desc) {
    7.24          final MethodHandle func = MH.asCollector(JSOBJECT_CALL, Object[].class, desc.getMethodType().parameterCount() - 2);
    7.25          return new GuardedInvocation(func, null, IS_JSOBJECT_GUARD);
    7.26 @@ -216,7 +207,6 @@
    7.27      // method handles of JSObject class
    7.28      private static final MethodHandle JSOBJECT_GETMEMBER  = findJSObjectMH("getMember", Object.class, String.class);
    7.29      private static final MethodHandle JSOBJECT_SETMEMBER  = findJSObjectMH("setMember", Void.TYPE, String.class, Object.class);
    7.30 -    private static final MethodHandle JSOBJECT_CALLMEMBER = findJSObjectMH("callMember", Object.class, String.class, Object[].class);
    7.31      private static final MethodHandle JSOBJECT_CALL       = findJSObjectMH("call", Object.class, Object.class, Object[].class);
    7.32      private static final MethodHandle JSOBJECT_NEW        = findJSObjectMH("newObject", Object.class, Object[].class);
    7.33  
     8.1 --- a/test/script/basic/JDK-8024847.js	Tue Oct 22 22:12:24 2013 +0530
     8.2 +++ b/test/script/basic/JDK-8024847.js	Wed Oct 23 20:21:23 2013 +0530
     8.3 @@ -100,3 +100,9 @@
     8.4  var jlist = Java.to(obj, java.util.List);
     8.5  print(jlist instanceof java.util.List);
     8.6  print(jlist);
     8.7 +
     8.8 +var obj = new JSObject() {
     8.9 +    toNumber: function() { return 42; }
    8.10 +};
    8.11 +
    8.12 +print(32 + obj);
     9.1 --- a/test/script/basic/JDK-8024847.js.EXPECTED	Tue Oct 22 22:12:24 2013 +0530
     9.2 +++ b/test/script/basic/JDK-8024847.js.EXPECTED	Wed Oct 23 20:21:23 2013 +0530
     9.3 @@ -10,3 +10,4 @@
     9.4  [hello, world]
     9.5  true
     9.6  [nashorn, js]
     9.7 +74
    10.1 --- a/test/src/jdk/nashorn/api/scripting/PluggableJSObjectTest.java	Tue Oct 22 22:12:24 2013 +0530
    10.2 +++ b/test/src/jdk/nashorn/api/scripting/PluggableJSObjectTest.java	Wed Oct 23 20:21:23 2013 +0530
    10.3 @@ -46,7 +46,7 @@
    10.4   * JSObject implementations.
    10.5   */
    10.6  public class PluggableJSObjectTest {
    10.7 -    public static class MapWrapperObject extends JSObject {
    10.8 +    public static class MapWrapperObject extends AbstractJSObject {
    10.9          private final HashMap<String, Object> map = new LinkedHashMap<>();
   10.10  
   10.11          public HashMap<String, Object> getMap() {
   10.12 @@ -109,7 +109,7 @@
   10.13          }
   10.14      }
   10.15  
   10.16 -    public static class BufferObject extends JSObject {
   10.17 +    public static class BufferObject extends AbstractJSObject {
   10.18          private final IntBuffer buf;
   10.19  
   10.20          public BufferObject(int size) {
   10.21 @@ -170,7 +170,7 @@
   10.22          }
   10.23      }
   10.24  
   10.25 -    public static class Adder extends JSObject {
   10.26 +    public static class Adder extends AbstractJSObject {
   10.27          @Override
   10.28          public Object call(Object thiz, Object... args) {
   10.29              double res = 0.0;
   10.30 @@ -202,7 +202,7 @@
   10.31          }
   10.32      }
   10.33  
   10.34 -    public static class Factory extends JSObject {
   10.35 +    public static class Factory extends AbstractJSObject {
   10.36          @Override
   10.37          public Object newObject(Object... args) {
   10.38              return new HashMap<Object, Object>();
    11.1 --- a/test/src/jdk/nashorn/api/scripting/ScriptObjectMirrorTest.java	Tue Oct 22 22:12:24 2013 +0530
    11.2 +++ b/test/src/jdk/nashorn/api/scripting/ScriptObjectMirrorTest.java	Wed Oct 23 20:21:23 2013 +0530
    11.3 @@ -129,7 +129,7 @@
    11.4          final ScriptEngine e = m.getEngineByName("nashorn");
    11.5          try {
    11.6              e.eval("var obj = { '1': 'world', func: function() { return this.bar; }, bar: 'hello' }");
    11.7 -            JSObject obj = (JSObject) e.get("obj");
    11.8 +            ScriptObjectMirror obj = (ScriptObjectMirror) e.get("obj");
    11.9  
   11.10              // try basic get on existing properties
   11.11              if (!obj.getMember("bar").equals("hello")) {

mercurial