开发者

GWT call to DOM.getElementById not causing a NullPointerException when it should

开发者 https://www.devze.com 2023-03-06 17:35 出处:网络
There is a part of our application that does this... int x = DOM.getElementById(\"x\").getPropertyInt(\"value\");

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");

Every call to DOM.getElemendById("something") returns null (which I expect as I removed them) but calling .getPropertyInt("value") on that return value of null is not causing a NullPointerException. In dev mode I am able to step through all of these statements and watch x,y,w,h all be assigned to zero. If I evaluate one of these statements in the Intellij evaluator in the debugger there 开发者_StackOverflow中文版is a NullPointerException thrown.

Doesn't this seem slightly insane to anybody else?


Wow it looks like anything created by GWT overlay types are able to do this...

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


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

精彩评论

暂无评论...
验证码 换一张
取 消