Tuesday, September 6, 2016

Re: lambda being compiled to empty method

From a quick look at your code, not sure how are you compiling your class HTTPCoreNode.java using GWT (CompletableFuture and most of java.util.concurrent classes are not emulated in GWT).
But, client side, we have been using Lambdas with no issues with 2.8rc1 (and 2.8beta-1 before that), can you try if it works with with that?


On Tuesday, September 6, 2016 at 4:29:46 PM UTC-4, Ian Preston wrote:
This is the Function interface code:
https://github.com/Peergos/Peergos/blob/google/src/peergos/gwt/emu/java/util/function/Function.java

On Tuesday, 6 September 2016 21:00:11 UTC+1, harshyadav wrote:
Can you share your functional interface code?

On Tuesday, September 6, 2016 at 3:35:32 PM UTC-4, Ian Preston wrote:
Thank you for all your awesome work on GWT.

I'm getting a lambda being compiled to an empty method. As the method is empty, it returns null, and the caller gets a null dereference. I'm using the latest HEAD from gwt github. 

The lambda is the following (the whole class is at https://github.com/Peergos/Peergos/blob/google/src/peergos/shared/corenode/HTTPCoreNode.java   -  the getUsername method)
res -> {
                System.out.println("HttpCoreNode.getUsername2");
                DataInputStream din = new DataInputStream(new ByteArrayInputStream(res));
                try {
                    String username = Serialize.deserializeString(din, CoreNode.MAX_USERNAME_SIZE);
                    return username;
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

This is being compiled to this empty function:

var com_google_gwt_lang_ClassLiteralHolder_Lpeergos_1shared_1corenode_1HTTPCoreNode$lambda$0$Type_12_1classLit = java_lang_Class_createForClass__Ljava_lang_String_2Ljava_lang_String_2Lcom_google_gwt_core_client_JavaScriptObject_2Ljava_lang_Class_2Ljava_lang_Class_2($intern_74, 'HTTPCoreNode/lambda$0$Type', 268);
function peergos_shared_corenode_HTTPCoreNode$lambda$1$Type_HTTPCoreNode$lambda$1$Type__V(){
}

Am I doing something wrong? Any help very much appreciated. 

--
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 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.

No comments:

Post a Comment