Export to GitHub

google-web-toolkit - issue #7291

Integer.parseInt("1") fails on BlackBerry/WebKit Browsers


Posted on Mar 30, 2012 by Happy Giraffe

Integer.parseInt("1") throws an uncatchable exception on BlackBerry/webkit browsers.

Found in GWT Release: 2.4.0 (all?) Encountered on OS / Browser (e.g. WinXP, IE8-9, FF7): All modern BlackBerry phones with webkit-based browser. Models/User-Agent strings follow:

BlackBerry Torch 9810: Mozilla/5.0 (BlackBerry; U; BlackBerry 9810; en-US) AppleWebKit/ 534.11+ (KHTML, like Gecko) Version/7.0.0.583 Mobile Safari/5.34.11+

BlackBerry Bold 9900 Mozilla/5.0 (BlackBerry; U; BlackBerry 9900; en-US) AppleWebKit/ 534.11+ (KHTML, like Gecko) Version/7.0.0.576 Mobile Safari/5.34.11+

BlackBerry Curve 9360 Mozilla/5.0 (BlackBerry; U; BlackBerry 9360; en-US) AppleWebKit/ 534.11+ (KHTML, like Gecko) Version/7.0.0.464 Mobile Safari/5.34.11+

Detailed description (please be as specific as possible):

Integer.parseInt("1"); throws some uncatchable exception on BlackBerry browsers. The specific line of GWT code which causes the exception is in java.lang.Number.java:227 from the GWT emulation code in:

google-web-toolkit-read-only/user/super/com/google/gwt/emul/java/lang/Number.java?227

Shortest code snippet which demonstrates issue:

class BlackBerryBug implements EntryPoint {

void onModuleLoad () { try { int one = Integer.parseInt ("1"); // Following line is not reached. Window.alert ("Parsed a one: " + one); } catch (Exception any) { // Exception never caught Window.alert ("Exception thrown: " + any.getMessage ()); } // Code not reached Window.alert ("done"); }

}

Workaround:

Use Long.parseLong("1") instead.

Comment #1

Posted on Mar 31, 2012 by Swift Rhino

See http://stackoverflow.com/questions/8098339/why-is-a-gwt-application-crashing-on-blackberry-os7

This seems to be a bug in Blackberry's JS engine.

Comment #2

Posted on Jun 14, 2012 by Swift Panda

Comment deleted

Comment #3

Posted on Jun 14, 2012 by Swift Panda

RIM stated that they will fix this with an OS update: http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/GWT-and-OS7-don-t-play-well-together/td-p/1448611

I think right now there is not a lot that we can do since we can not easily rebind for BB OS 7.0 (and possibly others).

I can confirm that this is not an issue with BB OS 6.x and that it can be properly avoided by using Long.parseLong with a downcast to Integer.

I think we are best of to leave this as a known quirk since the error is a Javascript Engine error, which will eventually be fixed.

Comment #4

Posted on Jun 18, 2012 by Grumpy Elephant

It seems to me the bug is in the compiler part of the JS-engine.

Snippet 1: var i = 0; if (i < -2147483648) { console.log("less"); } else { console.log("greater"); }

Snippet 2: var i = 0; var j = i < -2147483648; if (j) { console.log("less"); } else { console.log("greater"); }

While snippet 1 displays the bug by logging "less", snippet 2 does not.

As a workaround we have used the attached patch. Luckily, the GWT compiler does not remove the variable during compilation and Integer.parseInt works like a charm again. Don't know if it is feasible to include this in GWT, bug it might help others to create their own working versions of GWT.

Attachments

Comment #5

Posted on May 30, 2013 by Quick Rabbit

This was fixed in r11541 by applying the patch from #4 (thanks for that!) - could someone from the GWT team mark this bug as closed?

Comment #6

Posted on May 30, 2013 by Swift Rhino

(No comment was entered for this change.)

Comment #7

Posted on Feb 5, 2014 by Happy Elephant

Changed status because 2.6 is released.

Status: Fixed

Labels:
Category-JRE Milestone-2_6