I've encountered an "unrecoverable stack overflow error" that I can't figure out. From the docs : you need to create an interface object (of any class) and make it known to JavaScript by calling JSObject.setMember()
.
Here's the Java code sharing and using the interface object :
// somewhere in the code
JSObject window = (JSObject) engine.executeScript("window");
window.setMember("foo", new Foo()); // <-- shares
window.call("testFoo"); // <-- uses
// somewhere else
class Foo {
public void bar() {
System.out.println("baz");
}
}
And here's the JavaScript code using that object :
window.testFoo = function() {
window.foo.bar();
}
It occurs if I trigger it manually like show above, or if I trigger it through some JavaScript event.
Answer was in the comments, I can't believe I've been trying everything for hours and it was a very quick fix.
Turns out that the exposed interface has to be public.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With