GWT raises DOM.getElementById without throwing a NullPointerException when it should

There is a part of our application that does this ...

int x = DOM.getElementById("x").getPropertyInt("value"); int y = DOM.getElementById("y").getPropertyInt("value"); int w = DOM.getElementById("w").getPropertyInt("value"); int h = DOM.getElementById("h").getPropertyInt("value"); 

Each call to DOM.getElemendById("something") returns null (which I expect when I deleted them), but a call to .getPropertyInt("value") to return a null does not throw a NullPointerException. In dev mode, I can execute all these statements and observe that x, y, w, h are all assigned to zero. If I evaluate one of these statements in Intellij analytics in the debugger, a NullPointerException is thrown.

Doesn't that seem a little crazy for anyone else?

+4
source share
2 answers

The docs say :

 Exceptions: try, catch, finally and user-defined exceptions are supported as normal, although Throwable.getStackTrace() is not meaningfully supported in production mode. Note: Several fundamental exceptions implicitly produced by the Java VM, most notably NullPointerException, StackOverflowError, and OutOfMemoryError, do not occur in production mode as such. Instead, a JavaScriptException is produced for any implicitly generated exceptions. This is because the nature of the underlying JavaScript exception cannot be reliably mapped onto the appropriate Java exception type. 
+1
source

Wow, it looks like everything created by GWT overlay types can do this ...

http://code.google.com/p/google-web-toolkit/issues/detail?id=5030

+3
source

All Articles