-
Bug
-
Resolution: Fixed
-
P2
-
8u40
-
None
-
b28
-
generic
-
generic
-
Verified
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8056547 | emb-9 | Sundararajan Athijegannathan | P2 | Resolved | Fixed | master |
JDK-8064174 | 8u45 | Attila Szegedi | P2 | Resolved | Fixed | b01 |
JDK-8055640 | 8u40 | Attila Szegedi | P2 | Closed | Fixed | b04 |
JDK-8070411 | emb-8u47 | Attila Szegedi | P2 | Resolved | Fixed | team |
http://mail.openjdk.java.net/pipermail/nashorn-dev/2014-July/003204.html
Inconsistency about conversion to ScriptObjectMirror with getInterface and invokeFunction makes it difficult know which kind of object is being worked with in Nashorn. Example;
package mirrors;
import java.util.*;
import javax.script.*;
public class Mirrors {
public interface Example {
Object test1(Object arg);
Object test2(Object arg);
}
public static void main(String[] args) throws Exception {
ScriptEngineManager engineManager = new ScriptEngineManager();
ScriptEngine engine = engineManager.getEngineByName("nashorn");
Invocable invocable = (Invocable)engine;
engine.eval("function test1(arg) { print(arg.class); return { arg: arg }; }");
engine.eval("function test2(arg) { print(arg.class); return arg; }");
Map<String, Object> map = new HashMap<>();
map.put("option", true);
Example example = invocable.getInterface(Example.class);
Object value1 = invocable.invokeFunction("test1", map);
Object value2 = example.test1(map);
Object value3 = invocable.invokeFunction("test2", value2);
Object value4 = example.test2(value2);
System.out.println(value1.getClass());
System.out.println(value2.getClass());
System.out.println(value3.getClass());
System.out.println(value4.getClass());
}
}
Output:
class java.util.HashMap
class java.util.HashMap
undefined
undefined
class jdk.nashorn.api.scripting.ScriptObjectMirror
class jdk.nashorn.internal.scripts.JO4
class jdk.nashorn.api.scripting.ScriptObjectMirror
class jdk.nashorn.internal.scripts.JO4
Inconsistency about conversion to ScriptObjectMirror with getInterface and invokeFunction makes it difficult know which kind of object is being worked with in Nashorn. Example;
package mirrors;
import java.util.*;
import javax.script.*;
public class Mirrors {
public interface Example {
Object test1(Object arg);
Object test2(Object arg);
}
public static void main(String[] args) throws Exception {
ScriptEngineManager engineManager = new ScriptEngineManager();
ScriptEngine engine = engineManager.getEngineByName("nashorn");
Invocable invocable = (Invocable)engine;
engine.eval("function test1(arg) { print(arg.class); return { arg: arg }; }");
engine.eval("function test2(arg) { print(arg.class); return arg; }");
Map<String, Object> map = new HashMap<>();
map.put("option", true);
Example example = invocable.getInterface(Example.class);
Object value1 = invocable.invokeFunction("test1", map);
Object value2 = example.test1(map);
Object value3 = invocable.invokeFunction("test2", value2);
Object value4 = example.test2(value2);
System.out.println(value1.getClass());
System.out.println(value2.getClass());
System.out.println(value3.getClass());
System.out.println(value4.getClass());
}
}
Output:
class java.util.HashMap
class java.util.HashMap
undefined
undefined
class jdk.nashorn.api.scripting.ScriptObjectMirror
class jdk.nashorn.internal.scripts.JO4
class jdk.nashorn.api.scripting.ScriptObjectMirror
class jdk.nashorn.internal.scripts.JO4
- backported by
-
JDK-8056547 ScriptObjectMirror causing havoc with Invocation interface
- Resolved
-
JDK-8064174 ScriptObjectMirror causing havoc with Invocation interface
- Resolved
-
JDK-8070411 ScriptObjectMirror causing havoc with Invocation interface
- Resolved
-
JDK-8055640 ScriptObjectMirror causing havoc with Invocation interface
- Closed
- relates to
-
JDK-8050977 Java8 Javascript Nashorn exception: no current Global instance for nashorn
- Resolved