createForClass fail in javascript compiled version

52 views
Skip to first unread message

PhilBeaudoin

unread,
Apr 12, 2010, 6:00:31 PM4/12/10
to Google Web Toolkit
Hi,

I'm using the new google-gin AsyncProvider to implement code splitting
in my GWT application. It works well in most situations, but I ran
into a strange issue recently which might hint at a problem in GWT
itself.

My app works well in development mode: I call
myAsyncProvider.get(myCallback) and the code makes it to the
onSuccess() method of my AsyncCallback eventually.

When I compile my app to javascript, however, the code makes it all
the way to myAsyncProvider.get() and beyond, but then neither my
onSuccess() nor my onFailure() is executed. I also get the following
javascript error (compiled with -style DETAILED):
Uncaught ReferenceError:
java_lang_Class_createForClass__Ljava_lang_String_2Ljava_lang_String_2Ljava
_lang_String_2Ljava_lang_Class_2Ljava_lang_Class_2 is not defined

I've pasted the entire generated javascript here:
http://pastebin.com/iQ44u3bY
The error is on line 322.

I also posted the java files generated by google-gin and GWT there:
AsyncLoader1*.java: http://pastebin.com/b1tfWD9m
AsyncLoader2*.java: http://pastebin.com/7Jh5Rqvv
MyGinjectorImpl.java: http://pastebin.com/cyamcuKg

For info: It's AsyncProvider<MainPagePresenter> that fails. The
AsyncProvider<ResponsePresenter> works fine. Also, if I remove the
AsyncProvider<ResponsePresenter> then the
AsyncProvider<MainPagePresenter> works.

According to Peter Schmitt, "it almost looks as if some piece of code
is calling the GWT function createForClass[1] but can't find it. Maybe
an issue with GWT's code splitting?"

[1] http://www.google.com/codesearch/p?hl=en#MTQ26449crI/com/google/gwt/emul/java/lang/Class.java&q=createForClass&sa=N&cd=2&ct=rc


For reference, the original thread on the google-gin board:
http://groups.google.com/group/google-gin/browse_thread/thread/995db1ebccbc3104

Sripathi Krishnan

unread,
Apr 13, 2010, 12:14:50 AM4/13/10
to google-we...@googlegroups.com
Uncaught ReferenceError:
java_lang_Class_createForClass__Ljava_lang_String_2Ljava_lang_String_2Ljava _lang_String_2Ljava_lang_Class_2Ljava_lang_Class_2 is not defined
I have seen this error before when using GWT runAsync.. so I do believe this is somewhat of an issue with GWT compiler.

From what I remember, my RunAsyncCallback was something like this --

new RunAsyncCallback() {
      public void onSuccess() {
                someMethod();
            }
}

public void someMethod() {
   Log.debug("some debug message");
   //nothing after this..
}

Now, post compilation, someMethod() would no longer exist because of the optimizations GWT does, but the onSuccess() method would still call it. My project was a bit more complex with a few more indirection layers, but this was the essences of the problem.

To fix it, I just got rid of the useless method, and put some non-trivial code in the onSuccess() method. I thought I would research and file a bug back then, but I wasn't able to reproduce the issue in a trivial codebase that I could share with the GWT developers.

I haven't used GIN, and the generated classes you pasted are a bit too much for me. But can you verify you don't have any trivial methods in your code? Just don't leave empty methods and try again.. I think that should solve the problem.

--Sri
P.S. I am sorry I can't provide any more specific information. It's 6 months since I encountered the problem, and it was on a project I no longer have access to.



--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.


Reply all
Reply to author
Forward
0 new messages