Thursday, February 26, 2015

JSO: Why does this fail?


We switched to gwt 2.7 and now i have a compilation failure

[ERROR] JSNI method JsPromise.thenJava(Lcom/codenvy/api/promises/client/Thenable;)Lcom/codenvy/api/promises/client/Promise; attempts to call method Thenable.then(Ljava/lang/Object;)Lcom/codenvy/api/promises/client/Thenable; on an instance which might be a JavaScriptObject. Such a method call is only allowed in pure Java (non-JSNI) functions.

The code in question does

    public final <B> Promise<B> then(final Thenable<B> thenable) {
        if (thenable instanceof JavaScriptObject) {
            return this.thenJs((JavaScriptObject)thenable);
        } else {
            return this.thenJava(thenable);

    private final native <B> Promise<B> thenJs(JavaScriptObject thenable) /*-{
        return this.then(thenable);

    private final native <B> Promise<B> thenJava(Thenable<B> thenable) /*-{
        return this.then(function() {
            then: function(arg) {
                return thenable.@com.codenvy.api.promises.client.Thenable::then(*)(arg);

And there's a JSO implementation of the Thenale interface.

I've seen for example, but that's not the case as ThenJava will never be called with a JavaScripObject (unless I misunderstood).

So what's the problem?

You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment