-
Bug
-
Resolution: Fixed
-
P3
-
8u112, 9
-
None
-
b148
-
generic
-
generic
Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8183884 | 8u161 | Sundararajan Athijegannathan | P3 | Resolved | Fixed | b01 |
JDK-8170658 | 8u152 | Sundararajan Athijegannathan | P3 | Resolved | Fixed | b01 |
JDK-8192727 | emb-8u161 | Sundararajan Athijegannathan | P3 | Resolved | Fixed | b01 |
This issue was reported by Art Fiedler via nashorn-dev openjdk alias:
http://mail.openjdk.java.net/pipermail/nashorn-dev/2016-November/006662.html
email content cut-pasted here for convenience:
--- email from Art Fiedler ----
When calling the following code, I expected the call to myJSObject inside
testJSOCall to pass the current
scope as a ScriptObjectMirror to JSObjectImpl's call method as the thiz
argument. In this case without
modifying the call to myJSObject() should 'this' automatically be passed to
the call() method?
Thanks,
Arthur Fiedler
public class NashornBugTest
{
public static void main(String[] args) throws Exception {
NashornScriptEngineFactory factory = new
NashornScriptEngineFactory();
ScriptEngine scriptEngine = factory.getScriptEngine();
scriptEngine.put("myJSObject", new JSObjectImpl());
scriptEngine.eval(
"var a = 42;\n" +
"function testJSOCall(b) {\n" +
" myJSObject('text purposely did not pass b');\n" +
"}\n" +
"testJSOCall(a);\n");
}
public static class JSObjectImpl extends AbstractJSObject
{
@Override
public Object call(Object thiz, Object... args)
{
if (ScriptObjectMirror.isUndefined(thiz) || thiz == null)
throw new IllegalArgumentException("'thiz' is
undefined/null");
// TODO: need the value of 'b' in the calling function
return super.call(thiz, args);
}
@Override
public boolean isFunction()
{
return true;
}
}
}
http://mail.openjdk.java.net/pipermail/nashorn-dev/2016-November/006662.html
email content cut-pasted here for convenience:
--- email from Art Fiedler ----
When calling the following code, I expected the call to myJSObject inside
testJSOCall to pass the current
scope as a ScriptObjectMirror to JSObjectImpl's call method as the thiz
argument. In this case without
modifying the call to myJSObject() should 'this' automatically be passed to
the call() method?
Thanks,
Arthur Fiedler
public class NashornBugTest
{
public static void main(String[] args) throws Exception {
NashornScriptEngineFactory factory = new
NashornScriptEngineFactory();
ScriptEngine scriptEngine = factory.getScriptEngine();
scriptEngine.put("myJSObject", new JSObjectImpl());
scriptEngine.eval(
"var a = 42;\n" +
"function testJSOCall(b) {\n" +
" myJSObject('text purposely did not pass b');\n" +
"}\n" +
"testJSOCall(a);\n");
}
public static class JSObjectImpl extends AbstractJSObject
{
@Override
public Object call(Object thiz, Object... args)
{
if (ScriptObjectMirror.isUndefined(thiz) || thiz == null)
throw new IllegalArgumentException("'thiz' is
undefined/null");
// TODO: need the value of 'b' in the calling function
return super.call(thiz, args);
}
@Override
public boolean isFunction()
{
return true;
}
}
}
- backported by
-
JDK-8170658 JSObject call() is passed undefined for the argument 'thiz'
-
- Resolved
-
-
JDK-8183884 JSObject call() is passed undefined for the argument 'thiz'
-
- Resolved
-
-
JDK-8192727 JSObject call() is passed undefined for the argument 'thiz'
-
- Resolved
-
- relates to
-
JDK-8204560 Global scope passed as "thiz" arg in JSObject.call(Object,Object[])
-
- Closed
-