2

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

1

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

4 Comments

It is already human readable. You can see the source in the bug report. The optimizer is disabled. It works in development mode.
@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?
@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.
You can answer your own question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.