Finally solved it
...
...
...
Don't you just hate forums where people make such a comment and left it at that (without a description of the solution)?
...
...
...
And since i hate such a forum as well, here's what happened:
First of all, it isn't as random as I thought. My midlet has a main menu. The exception happens when SOME of the currently displayed
Displayable tries to rebuild the main menu (before setting the main menu as the next displayable). Why it happens with some and not others, I still have no idea :(
The code looks something like this:
Code:
class MainMenu extends List {
void clearList() {
try {
for(int i = this.size() - 1; i >= 0; i--) {
this.delete(i); // exception somewhere here
}
} catch (Exception ex) { // debugging only }
}
void rebuildList () {
this.clearList();
try {
...
this.append(...);
this.append(...); // exception somewhere here
this.append(...);
...
} catch (Exception ex) { // debugging only }
}
}
class SomeDisplay extends Canvas /* (or List, or any other displayable) */ {
private class SomeCommandListener implements CommandListener {
public void commandAction(Command cmd, Displayable disp) {
...
mainMenu.rebuildList();
...
}
}
During the delete, for some strange reason, the index becomes out of bounds even though
i is always between zero and
this.size() and no element is ever removed outside of the method.
During the build, its even more strange that an
append() will cause the exception...
Anyways, the code for
clearList() is a little strange and I changed it to
this.deleteAll() which solved all my problems.
But I would still appreciate it if somebody can tell me why this is happening.
As for the %$@%$# network simulator, I don't know why some parts of the HTTP request does not reach my JSP servlet
anybody has any idea?