-
Notifications
You must be signed in to change notification settings - Fork 829
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When InterfaceAdapter is used, the wrong thisObj is used #1453
base: master
Are you sure you want to change the base?
When InterfaceAdapter is used, the wrong thisObj is used #1453
Conversation
@@ -152,9 +152,8 @@ Object invokeImpl( | |||
} | |||
} | |||
} | |||
Scriptable thisObj = wf.wrapAsJavaObject(cx, topScope, thisObject, null); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thisObject
is an instance of JavaAdapterInvokeTest.AdapterClass
and we want to call a method on target
This seems logical to me but it's a pretty fundamental thing to the Java embedding support and I'd like to see someone who works with this stuff regularly take a look before merging it. |
@Before | ||
public void enterContext() { | ||
cx = Context.enter(); | ||
cx.setOptimizationLevel(-1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dunno what our policy is, but should this test not also be run in non-interpreted mode?
public void testInvokeJsOnly() throws NoSuchMethodException { | ||
String testCode = | ||
"'use strict'\n" | ||
+ "function Obj() { this.myObj = {one: 1} }\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about a testcase where .myObj is added on the prototype, instead of the this
inside the constructor?
Not a regular user of code that uses code constructs like the testcases, calling a java method passing as argument a JavaScript objects that implements a java interface, but the change looks ok to me |
I had an issue when I pass a JS object to Java class and an InterfaceAdapter is constructed:
Java interface
Corresponding impl. in javascript:
When I pass this object in my AdapterClass, I get the error:
this.myObj is undefined
This PR provides a test and a possible fix