-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
8u152, 9, 10, 11
-
b148
-
x86_64
-
windows_8
ADDITIONAL SYSTEM INFORMATION :
Microsoft Windows [Version 6.3.9600]
java version "1.8.0_172"
Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)
A DESCRIPTION OF THE PROBLEM :
When having a host object (JSObject implementation) in the global scope, and calling it like a function (without an owner), the global scope object is erroneously passed as an argument to the JSObject's call(Object,Object[]) method as the first argument.
This is regardless of strict mode: it happens either way.
Extra information: my guess would be that this is a result of changes made forJDK-8170565
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the supplied code.
Uncomment the "use strict" line to see that this happens regardless of strict mode.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The following output:
undefined
ACTUAL -
The following output:
[object global]
---------- BEGIN SOURCE ----------
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import jdk.nashorn.api.scripting.AbstractJSObject;
import jdk.nashorn.api.scripting.JSObject;
import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
public class A {
public static void main(String[] args) throws Exception {
ScriptEngine se = ((NashornScriptEngineFactory) new ScriptEngineManager()
.getEngineFactories()
.get(0))
.getScriptEngine( //
// "-strict"
);
JSObject o = (JSObject) se.eval("var a = ({}); a;");
o.setMember("something", new AbstractJSObject() {
@Override
public Object call(Object thiz, Object... args) {
System.out.println(thiz);
return null;
}
});
se.eval("var b = a.something; b();");
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
There is no workaround.
FREQUENCY : always
Microsoft Windows [Version 6.3.9600]
java version "1.8.0_172"
Java(TM) SE Runtime Environment (build 1.8.0_172-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.172-b11, mixed mode)
A DESCRIPTION OF THE PROBLEM :
When having a host object (JSObject implementation) in the global scope, and calling it like a function (without an owner), the global scope object is erroneously passed as an argument to the JSObject's call(Object,Object[]) method as the first argument.
This is regardless of strict mode: it happens either way.
Extra information: my guess would be that this is a result of changes made for
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Run the supplied code.
Uncomment the "use strict" line to see that this happens regardless of strict mode.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The following output:
undefined
ACTUAL -
The following output:
[object global]
---------- BEGIN SOURCE ----------
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import jdk.nashorn.api.scripting.AbstractJSObject;
import jdk.nashorn.api.scripting.JSObject;
import jdk.nashorn.api.scripting.NashornScriptEngineFactory;
public class A {
public static void main(String[] args) throws Exception {
ScriptEngine se = ((NashornScriptEngineFactory) new ScriptEngineManager()
.getEngineFactories()
.get(0))
.getScriptEngine( //
// "-strict"
);
JSObject o = (JSObject) se.eval("var a = ({}); a;");
o.setMember("something", new AbstractJSObject() {
@Override
public Object call(Object thiz, Object... args) {
System.out.println(thiz);
return null;
}
});
se.eval("var b = a.something; b();");
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
There is no workaround.
FREQUENCY : always
- relates to
-
JDK-8170565 JSObject call() is passed undefined for the argument 'thiz'
-
- Resolved
-