Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use GWT $entry Function in JSNI?

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));
}-*/; 
like image 942
confile Avatar asked Dec 29 '25 16:12

confile


1 Answers

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.

like image 88
Thomas Broyer Avatar answered Dec 31 '25 08:12

Thomas Broyer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!