The $entry function in GWT is used to get uncaught exceptions reported from JavaScript to GWT.
What is the difference between the following $entry calls and which one is the correct one?
The following versions call instance Java functions.
Version 1:
public final native String test(double arg) /*-{
var instance = this;
var callExternal = $entry(function(arg) {
return [email protected]::javaFunction(D)(arg);
});
var x = callExternal(arg);
}-*/;
Version 2:
public final native String test(double arg) /*-{
var x = $entry([email protected]::javaFunction(D)(arg));
}-*/;
Is there a different use whether I use static or non static java functions?
Update:
The following versions call static Java functions.
Version 1:
public final native String test(double arg) /*-{
var callExternal = $entry(function(arg) {
[email protected]::javaFunction(D)(arg);
});
var x = callExternal(arg);
}-*/;
Version 2:
public final native String test(double arg) /*-{
var x = $entry(@com.example.MyClass::staticJavaFunction(D)(arg));
}-*/;
The second one is wrong: it calls the method then wraps the result. It's useless, possibly even broken.
$entry wraps a function in another function that uses a try/catch.
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