Sometimes, in the first screen of my app, appears the following error.
java.lang.ArrayIndexOutOfBoundsException: 5 >= 5
at java.util.Vector.elementAt(Vector.java:427)
at com.sun.lwuit.Container.getComponentAt(Container.java:844)
at com.sun.lwuit.layouts.BoxLayout.getPreferredSize(BoxLayout.java:133)
at com.sun.lwuit.Container.calcPreferredSize(Container.java:1097)
at com.sun.lwuit.Component.preferredSize(Component.java:1431)
at com.sun.lwuit.Component.getPreferredSize(Component.java:473)
at com.sun.lwuit.Component.getPreferredH(Component.java:553)
at com.sun.lwuit.layouts.BoxLayout.layoutContainer(BoxLayout.java:84)
at com.sun.lwuit.Container.doLayout(Container.java:813)
at com.sun.lwuit.Container.layoutContainer(Container.java:805)
at com.sun.lwuit.Container.doLayout(Container.java:818)
at com.sun.lwuit.Form.sizeChangedInternal(+93)
at com.sun.lwuit.Display.handleEvent(Display.java:1654)
at com.sun.lwuit.Display.edtLoopImpl(Display.java:886)
at com.sun.lwuit.Display.mainEDTLoop(Display.java:831)
at com.sun.lwuit.RunnableWrapper.run(RunnableWrapper.java:119)
It has no effect on the rest of the app, but when this happens, it appears a Dialog with the error inside, and I don't want it to show.
How can I avoid this?
This is a LWUIT4S40 bug, the stack is pretty clear. I can't tell you what the bug is because I'm unfamiliar with their code but venturing a guess I would say they are probably messing with things like the title component or command components and mutating the layout from their native thread.
Since none of your code is in the stack and the stack is on the EDT you should be in the clear UNLESS you are modifying the UI from a separate thread (e.g. the start method). In Codename One this is pretty easy to detect with the builtin EDT violation detector but here you would just have to inspect all your code or get Nokia's help.