Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

During compilation of a GWT class I got some compiler exception. I filed a bug report for that here: http://code.google.com/p/google-web-toolkit/issues/detail?id=6623

Now I found how to make it compile anyway, by using "draftCompile". However, the generated JavaScript code doesn't work when executed.

The Java source files are available from the bug tracker, and the compiled project is here: http://clientssh1.rbg.informatik.tu-darmstadt.de:9000/war/Gwittest.html

The error is: (Chrome) "Uncaught TypeError: Cannot read property 'testpackage_shared_ship_Level_boards' of null". In Firefox its another error.

The code works in Dev Mode (from Eclipse).

How do I work around this error? Is it related to the compilation/optimization bug? How do I work around it? If it is a bug in and of itself, I should report this too, no?

Edit: the class in question is here: https://gist.github.com/1139147

share|improve this question
    
My only advice will be to compile it with -style PRETTY and try to find where exactly is the problem. I've recently had a problem with the same symptoms (code.google.com/p/google-web-toolkit/issues/detail?id=6579), the only way how to solve it, is to compare compiled Js vs source Java code, to find out where compiler screwed up (btw, when i tried your app in latest firefox it showed a totally different error [17:35:46.422] this$static is null @ clientssh1.rbg.informatik.tu-darmstadt.de:9000/war/gwittest/…) – jusio Aug 9 '11 at 15:39
up vote 2 down vote accepted

The error sounds like the compiled javascript contains code like:

null.testpackage_shared_ship_Level_boards

This would happen if the GWT optimizer believes that your variable of type "Level" which has its field "boards" read, must be null. The optimizer is usually right about that.

So, an approach is to: Compile the code into human readable javascript (-style pretty). Get the javascript error and find the line that caused it. Find the corresponding line your Java source, and trace back where the value of your variable comes from. You will likely find that the variable was not initialized.

share|improve this answer
    
It is already human readable. You can see the source in the bug report. The optimizer is disabled. It works in development mode. – Janus Troelsen Aug 13 '11 at 7:57
    
@user309483: As you accepted this answer, and I can't see how it would help, could you describe how you found the problem in your case? – Paŭlo Ebermann Dec 22 '11 at 13:40
    
@Paulo: Well, I figure it was a GWT compiler bug. I solved the problem by running more code server-side (i.e. not GWT compiled)... This answer showed effort and I accept it for confirming my suspicion that the GWT compiler has issues. Also, I didn't wanna get my acceptance quota too low, as I think it will prevent people from answering my questions. Sorry. Note that I had this problem with GWT 2.3.0, they might have fixed whatever caused it. – Janus Troelsen Dec 22 '11 at 14:03
    
You can answer your own question. – Glen Pierce Apr 20 at 0:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.