title: Nashorn does not find function when eval with bindings
body: <p>There is a strange difference when I evaluate a nashorn script with or without bindings: without bindings there is no problem invoking a function, but with the bindings the function is not found. Here is an example:</p>
  
  <pre><code>public class SimpleNashornTester {
  
      public static void main(String[] args) throws ScriptException, NoSuchMethodException {
          ScriptEngine jsEngine = new ScriptEngineManager().getEngineByName("nashorn");
          Compilable jsCompilable = (Compilable) jsEngine;
          Invocable jsInvocable = (Invocable) jsEngine;
  
          ScriptContext scriptCtxt = new SimpleScriptContext();
          Bindings engineScope = scriptCtxt.getBindings(ScriptContext.ENGINE_SCOPE);
          CompiledScript jsScript = jsCompilable.compile("function definition() {print(\"Hello\")}");
          jsScript.eval(engineScope); // no error with jsScript.eval() !
          jsInvocable.invokeFunction("definition", new Object[] {});
      }
  }
  </code></pre>
  
  <p>This yields the error:</p>
  
  <pre><code>Exception in thread "main" java.lang.NoSuchMethodException: No such function definition
      at jdk.nashorn.api.scripting.ScriptObjectMirror.callMember(ScriptObjectMirror.java:204)
  </code></pre>
  
  <p>Without the parameter engineScope in the evaluation of the script the function is found and invoked. Can anybody explain this difference? How can I use bindings without getting an error?</p>