Skip to main content
GameDev.net gamedev.net
🔒 Locked

[java] java internal java.lang.ArrayIndexOutOfBoundsException

Started by Kaze Jul 19, 2011 at 6:08 PM 8 replies 3k views
Original Post
Kaze
Kaze
How do I find the cause of a exception that was created and caught entirely within the java libraries.


Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0
at javax.swing.text.BoxView.getOffset(Unknown Source)
at javax.swing.text.BoxView.childAllocation(Unknown Source)
at javax.swing.text.CompositeView.getChildAllocation(Unknown Source)
at javax.swing.text.BoxView.getChildAllocation(Unknown Source)
at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.calculateViewPosition(Unknown Source)
at javax.swing.plaf.basic.BasicTextUI$UpdateHandler.layoutContainer(Unknown Source)
at java.awt.Container.layout(Unknown Source)
at java.awt.Container.doLayout(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validateTree(Unknown Source)
at java.awt.Container.validate(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
VildNinja
VildNinja
Most likely it's because you're manipulating some text, while an other thread is trying to reach it. Is your program multithreaded?

The stack says "EventDispatchThread" so it's most likely caused by some event being thrown.


Otherwise try with a few System.out.println this is generally considered ugly code, but it can be quite useful, if you got the tiniest idea of where the bug is located.


But generally it's difficult to say any more, with this few informations.
Kaze
Kaze

Most likely it's because you're manipulating some text, while an other thread is trying to reach it. Is your program multithreaded?

I'm not using any multithreading unless swing is doing it in the background.


The stack says "EventDispatchThread" so it's most likely caused by some event being thrown.
Otherwise try with a few System.out.println this is generally considered ugly code, but it can be quite useful, if you got the tiniest idea of where the bug is located.

I already have a logger and put try catches on events I suspected might be the problem but haven't got anything yet.


But generally it's difficult to say any more, with this few informations.

I don't have much more information, this bug seems to happen randomly.
VildNinja
VildNinja
Yes swing does it behind your back.. does it happen at random, when you click some thing, or does it just happen at random?


Do your program use any kind of text verification?
Do you have a game loop, that repeats some code?
Do you do any thing in the thread that opens the window (calls setVisible) after you've opened the window?

Edit: if yes, please post the code
Kaze
Kaze
I don't think my project has any of that though I think you are right about it being a multithreading issue due to how randomly it happens.
Kaze
Kaze

What does your program do?


At the moment very little, I'm just working on a user interface for editing some files that will eventually be a game maker like program.
VildNinja
VildNinja
Ok, the error should be where you are entering some text.

I think I need to see the code for every where the user can give any input, and the code where you create the window..

Also what swing components are you using?
Kaze
Kaze
Since this is a commercial project I can't post large sections of the code. Entering text doesn't seem to correlate with the error occurring since it often happens at start up. I am using most of the basic swing components.
j-locke
j-locke
In absence of code, maybe an approach could be to remove one or a group of the swing controls at a time. You could delete them then undo the change after a test run assuming your ide has undo (and hopefully for a commercial venture you have some source control going on to further protect from any crazily bad outcomes).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.