src/jdk/nashorn/internal/runtime/ListAdapter.java

Print this page

        

@@ -31,10 +31,11 @@
 import java.util.ListIterator;
 import java.util.NoSuchElementException;
 import java.util.RandomAccess;
 import java.util.concurrent.Callable;
 import jdk.nashorn.api.scripting.JSObject;
+import jdk.nashorn.api.scripting.ScriptObjectMirror;
 import jdk.nashorn.internal.runtime.linker.Bootstrap;
 import jdk.nashorn.internal.runtime.linker.InvokeByName;
 
 /**
  * An adapter that can wrap any ECMAScript Array-like object (that adheres to the array rules for the property

@@ -133,11 +134,12 @@
      * @param obj script object to wrap as a ListAdapter
      * @return A ListAdapter wrapper object
      */
     public static ListAdapter create(final Object obj) {
         if (obj instanceof ScriptObject) {
-            return new ScriptObjectListAdapter((ScriptObject)obj);
+            final Object mirror = ScriptObjectMirror.wrap(obj, Context.getGlobal());
+            return new JSObjectListAdapter((JSObject)mirror);
         } else if (obj instanceof JSObject) {
             return new JSObjectListAdapter((JSObject)obj);
         } else {
             throw new IllegalArgumentException("ScriptObject or JSObject expected");
         }