Unrecoverable stackoverflow error when creating JavaScript links to Java

I encountered a "fatal error" that I cannot understand. From 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 exchange code and use of 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 is the JavaScript code using this object:

 window.testFoo = function() { window.foo.bar(); } 

This happens if I fire it manually, as shown above, or if I fire it through some kind of JavaScript event.

+5
source share
1 answer

The answer was in the comments, I can’t believe that I tried everything for several hours, and it was a very quick fix.

It turns out that the open interface should be public .

+1
source

All Articles