title: Can't call hasOwnProperty on Java List with Nashorn
body: <p>I've got an application that executes a lot of javascript server side and I'm trying to convert from Rhino to Nashorn but I am running into trouble with my scripts. Using Rhino I would always convert whatever arguments I had for a function into a JSON string but that's really slow. With Nashorn I'm trying to just pass in the arguments as Java objects but they don't seem to inherit functions from Javascript's Object type. Here is a sample method that illustrates my problem where hasOwnProperty is not available on my array:</p>
  
  <pre><code>public String printArrayValues() throws ScriptException, NoSuchMethodException {
  
    String script =
        "function printArrayValues(objArray) {\n" +
        "  var result = '';\n" +
        "  for(var obj in objArray) {\n" +
        "    if(objArray.hasOwnProperty(obj)) {\n" +
        "      result = result + ' ' + objArray[obj];\n" +
        "    }\n" +
        "  }\n" +
        "  return result;\n" +
        "}";
  
    List&lt;String&gt; data = Arrays.asList(new String[]{ "one", "two", "three"});
  
    ScriptEngine scriptEngine = new NashornScriptEngineFactory().getScriptEngine();
    scriptEngine.eval(script);
    String result = (String) ((Invocable) scriptEngine).invokeFunction("printArrayValues", data);
  }
  </code></pre>
  
  <p>Here the call to invokeFunction throws an exception:</p>
  
  <pre><code>javax.script.ScriptException: TypeError: [one, two, three] has no such function "hasOwnProperty" in &lt;eval&gt; at line number 4
  </code></pre>
  
  <p>If I call the same function in a browser, I get what I would expect:</p>
  
  <pre><code>&gt; printArrayValues(["one", "two", "three"]);
  &gt; " one two three"
  </code></pre>
  
  <p>Is there some way I can accomplish this so I really can use these Java objects without turning them into a JSON string and then eval'ing it into a Javascript object?</p>