title: How to return array from javascript call in java?
body: <p>I have the following in a js file:</p>
  
  <pre><code>function serialize() {
  return new Uint8Array(1024);
  }
  </code></pre>
  
  <p>I invoke that function with the java scripting api like so:</p>
  
  <pre><code>byte[] bytes = (byte[]) ((Invocable)engine).invokeFunction(SERIALIZE_FUNC);
  </code></pre>
  
  <p>Which immediately throws the exception: </p>
  
  <pre><code>javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "Uint8Array" is not defined. (&lt;Unknown source&gt;#1) in &lt;Unknown source&gt; at line number 1
  sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "Uint8Array" is not defined. (&lt;Unknown source&gt;#1)
  </code></pre>
  
  <p>I dont know much about javascript, but I thought this is how you define an array in JavaScript?</p>