java.lang.IndexOutOfBoundsException: Index: 3, Size: 3

38 views
Skip to first unread message

Gareth Murfin

unread,
Apr 6, 2018, 8:29:20 AM4/6/18
to CodenameOne Discussions
I get this occasionally and I cannot track it down, stacktrace doesnt point to my code. any thoughts?

[EDT] 0:0:19,504 - Codename One revisions: d4219a1b829854d15136d1fa3166990e01f1b197

[EDT] 0:0:19,512 - Exception: java.lang.IndexOutOfBoundsException - Index: 3, Size: 3
java.lang.IndexOutOfBoundsException: Index: 3, Size: 3
at java.util.ArrayList.rangeCheck(ArrayList.java:653)
at java.util.ArrayList.get(ArrayList.java:429)
at com.codename1.ui.Container.initComponentImpl(Container.java:1001)
at com.codename1.ui.Container.initComponentImpl(Container.java:1002)
at com.codename1.ui.Container.initComponentImpl(Container.java:1002)
at com.codename1.ui.Container.initComponentImpl(Container.java:1002)
at com.codename1.ui.Container.initComponentImpl(Container.java:1002)
at com.codename1.ui.Form.initComponentImpl(Form.java:1876)
at com.codename1.ui.Display.setCurrent(Display.java:1313)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:78)
at com.codename1.ui.Display.processSerialCalls(Display.java:1129)
at com.codename1.ui.Display.edtLoopImpl(Display.java:1073)
at com.codename1.ui.Display.mainEDTLoop(Display.java:961)
at com.codename1.ui.RunnableWrapper.run(RunnableWrapper.java:120)
at com.codename1.impl.CodenameOneThread.run(CodenameOneThread.java:176)

Shai Almog

unread,
Apr 7, 2018, 12:18:14 AM4/7/18
to CodenameOne Discussions
This looks like an EDT violation.

Gareth Murfin

unread,
Jul 1, 2018, 11:55:17 PM7/1/18
to CodenameOne Discussions
is there any way to track down what the issue is then ? I have the simulator set to full debug edt, but still I cant locate this issue. It happens now and again still and is getting annoying.

Dave Dyer

unread,
Jul 2, 2018, 2:04:20 PM7/2/18
to CodenameOne Discussions
This kind of problem occurs when you change the window structure not in the edt thread.
Just don't do it, and the problem will be solved.  Changing the windows structure includes
anything that triggers a layout change too, such as changing a window title or making
a window visible.  There's no magic bullet to trap all cases where you accidentally violate
the edt rule - lots of things violate the rule but never cause a problem.

Gareth Murfin

unread,
Jul 10, 2018, 5:09:36 AM7/10/18
to CodenameOne Discussions
Thanks, though its easy to say "dont do it" I dont know where I am doing it!.. cant cn1 provide a trace to a line that caused it???,. Its very hard to pin point what line calls it, I dont see any UI stuff going on. it seemsl ike at some point cn1 stopped giving errors that lead to our own code.

Shai Almog

unread,
Jul 11, 2018, 12:06:57 AM7/11/18
to CodenameOne Discussions
The best we can do is the EDT monitor but it sends false positives and sometimes misses actual violations because these things are very hard to detect.

Gareth Murfin

unread,
Jul 19, 2018, 7:44:28 AM7/19/18
to CodenameOne Discussions
Yes, I shuffled some code around and it seems to have gone away, i think somehow it was related to me removing a button on the first screen that comes up in postMain, worked better in beforeMain

Gareth Murfin

unread,
Aug 1, 2018, 7:00:43 PM8/1/18
to CodenameOne Discussions
definitely fixed this, just by putting in beforeMethod, interesting, I dont know why my brain tells me to do things in post, when before is much more ideal. Still I am confused at some of these edt things, even after a decade I resort to code shuffling or callSerially, uitimer i thought would be answer but it is not.
Reply all
Reply to author
Forward
0 new messages