package com.winterbe.java8;

import jdk.nashorn.api.scripting.NashornScriptEngine;

import javax.script.ScriptEngineManager;
import javax.script.ScriptException;

/**
 * @author Benjamin Winterberg
 */
public class Nashorn8 {
    public static void main(String[] args) throws ScriptException, NoSuchMethodException {
        NashornScriptEngine engine = (NashornScriptEngine) new ScriptEngineManager().getEngineByName("nashorn");
        engine.eval("load('res/nashorn8.js')");

        engine.invokeFunction("evaluate1");
        engine.invokeFunction("evaluate2");
        engine.invokeFunction("evaluate3", "Foobar");
        engine.invokeFunction("evaluate3", new Person("John", "Doe"));
    }

}

@@ -519,52 +519,146 @@
 1%22);
-%0A        engine.invokeFunction(%22evaluate2%22);
+                             // %5Bobject global%5D%0A        engine.invokeFunction(%22evaluate2%22);                             // %5Bobject Object%5D
 %0A   
@@ -707,16 +707,44 @@
 oobar%22);
+                   // Foobar
 %0A       
@@ -806,16 +806,47 @@
 %22Doe%22));
+  // %5Bobject global%5D %3C- ???????
 %0A    %7D%0A%0A

Add output as comments