JavascriptObject.createObject().cast() ClassCastException

2017-09-08 Thread Thomas Broyer
Do you have any other class implementing the failing interface?
When there's only one implementation, the compiler can "tighten" the types and 
consider/replace every use of the interface as/with the implementing class. The 
class then extends JSO so GWT knows it doesn't need any cast (actually, it can 
infer the type type argument of the cast() method).

Just a supposition hereā€¦

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


JavascriptObject.createObject().cast() ClassCastException

2017-09-08 Thread Kirill Prazdnikov
I do not see any usage of *Impl, are they there ?

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.


Re: Emulating CompletableFuture with Promise

2017-09-08 Thread Peter Donald
That is pretty awesome. Thanks!

On Thu, Sep 7, 2017 at 6:55 AM, Benjamin DeLillo  wrote:

> I decided to package this up in a standalone library so it can be used
> until such time that it makes it into a GWT release.
>
> https://github.com/OneGeek/GWT-CompletableFuture
>
> On Monday, September 5, 2016 at 4:47:10 AM UTC-4, Andrei Korzhevskii wrote:
>>
>> I guess you need to super-source this class so the gwt compiler could use
>> it.
>>
>> You can take a look at my initial CompletableFuture implementation here:
>>
>> https://github.com/nordligulv/gwt/tree/completable-future
>> https://github.com/nordligulv/gwt/commit/ea70c5358bac3c939cb
>> 0c1628a58ccc462cd7423
>>
>> Feel free to use it but note that I haven't tested it properly yet.
>>
>>
>>
>> On Monday, September 5, 2016 at 3:28:27 AM UTC+3, Ian Preston wrote:
>>>
>>> I'm trying to emulate CompletableFuture by backing directly onto
>>> Promise, but when compiling it gives this error:
>>> "No source code is available for type java.util.concurrent.Completab
>>> leFuture"
>>> (it finds other JRE classes I've replaced fine)
>>>
>>> My source I'm including is below. Am I doing anything illegal?
>>> 
>>> package java.util.concurrent;
>>>
>>> import com.google.gwt.user.client.*;
>>> import jsinterop.annotations.*;
>>>
>>> import java.util.function.*;
>>>
>>> @JsType(isNative=true, name = "Promise", namespace = JsPackage.GLOBAL)
>>> public class CompletableFuture implements CompletionStage {
>>>
>>> @JsMethod(name = "then")
>>> public native  CompletableFuture thenApply(Function>> T,? extends U> fn);
>>>
>>> @JsMethod(name = "then")
>>> public native CompletableFuture thenAccept(Consumer
>>> action);
>>>
>>> @JsMethod(name = "then")
>>> public native  CompletableFuture thenCompose(Function>> T, ? extends CompletionStage> fn);
>>>
>>> @JsMethod(name = "reject")
>>> public native boolean completeExceptionally(Throwable ex);
>>>
>>> @JsMethod(name = "resolve")
>>> public native boolean complete(T value);
>>>
>>> @JsMethod(name = "resolve")
>>> public static native  CompletableFuture completedFuture(U
>>> value);
>>>
>>> @JsOverlay
>>> public T get() throws InterruptedException, ExecutionException {
>>> Window.alert("Calling synchronous get() on CompletableFuture is
>>> not possible in Javascript!");
>>> throw new IllegalStateException("Unimplemented!");
>>> }
>>> }
>>>
>> --
> 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+unsubscr...@googlegroups.com.
> To post to this group, send email to google-web-toolkit@googlegroups.com.
> Visit this group at https://groups.google.com/group/google-web-toolkit.
> For more options, visit https://groups.google.com/d/optout.
>



-- 
Cheers,

Peter Donald

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at https://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.