PlaceManager error because IndexOutOfBounds thrown instead of ArrayIndexOutOfBounds (GWT 2.3, GWTP 0.6)

28 views
Skip to first unread message

Tom Terrace

unread,
Sep 13, 2011, 4:01:58 PM9/13/11
to GWTP
Using GWT 2.3 & GWTP 0.6, I have an error that's popping up in web
mode only (hosted mode works fine). The problem is that the
getCurrentPlaceRequest method in the PlaceManagerImpl class tries to
access the placeHierarchy list and has a catch block for
ArrayIndexOutOfBoundsException:

public PlaceRequest getCurrentPlaceRequest() {
try {
return placeHierarchy.get(placeHierarchy.size() - 1);
} catch (ArrayIndexOutOfBoundsException e) {
return new PlaceRequest();
}
}

However, in GWT's compiled javascript, ArrayIndexOutOfBoundsException
is never thrown, only IndexOutOfBoundsException. Here's the relevant
line from -style DETAILED javascript:

(index < 0 || index >= size) &&
java_util_AbstractList_indexOutOfBounds__IIV(index, size);

So the catch block misses the exception and causes an error. This is
easily fixed by checking the size of the list instead of trying to
catch the exception (which is probably cleaner anyway), but can anyone
else reproduce this behavior? Would this be a GWT bug since Java's
ArrayList behaves differently than the compiled javascript?

Thanks for the help,
Tom

Philippe Beaudoin

unread,
Sep 14, 2011, 10:06:35 AM9/14/11
to gwt-pl...@googlegroups.com
Rule of thumb: if something happens in web mode but not in dev/hosted mode, then it's a GWT compiler bug. In this case you've found a very nice little unit test for it. I would report it on the GWT mailing list, I'm sure they'll thank you for it.

In the meantime if you want a quick fix, then I can definitely consider doing a manual bound check. Please enter an issue for it.

Best,

   Philippe

Tom Terrace

unread,
Sep 19, 2011, 11:18:49 AM9/19/11
to GWTP
Thanks Philippe, I've reported this on the gwt mailing list:
http://groups.google.com/group/google-web-toolkit/browse_thread/thread/ce87f7024bd4ad62#
. I suppose we can wait and see what the consensus is there. If they
decide to leave it as is I'll open an issue with a patch here.
-Tom
On Sep 14, 10:06 am, Philippe Beaudoin <philippe.beaud...@gmail.com>
wrote:
Reply all
Reply to author
Forward
0 new messages