Thursday, September 10, 2020

Re: Weird type error in lambdas with generics, with JsInterop

Thanks Jens. The NullPointerException was my first line of investigation. But there are no fields, object or method called 'inspectivity' - it's part of the package names. When debugging in Chrome DevTools, the exception occurred while it was executing the "method declaration line", AFAIK the GWT boilerplate code before it executes the actual method.

Unfortunately I can't share the full code, but I think I've pinned it down to invoking callbacks based with generics from JsInterop (similar code is working with JSNI callbacks):

public interface FileCallback<S, E> {
         public void onSuccess(S entry);
         public void onFailure(E error);
}

public abstract class DelegatingFileCallback<S> implements FileCallback<S, FileError> {
    private static final Logger log = Logger.getLogger(DelegatingFileCallback.class.getName());
    private final FileCallback<?, FileError> delegate;
    private final String operation;
    protected DelegatingFileCallback(FileCallback<?, FileError> delegate, String operation) {
        this.delegate = delegate;
        this.operation = operation;
    }
    @Override
    public final void onFailure(FileError error) {
        log.warning(error.buildErrorMessage(operation, ""));
        delegate.onFailure(error);
    }
}

I'm gradually replacing these callbacks by specific ones and it seems to be working.

Thanks,
Thomas

--
You received this message because you are subscribed to the Google Groups "GWT Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-web-toolkit/CAAJnK2nkEy3Nh7NG1bL2UubWoLd6%3DSjdJW-xzP7BNEFWhZdn3w%40mail.gmail.com.

No comments:

Post a Comment