Sign in to follow this  
Kaze

[java] java internal java.lang.ArrayIndexOutOfBoundsException

Recommended Posts

How do I find the cause of a exception that was created and caught entirely within the java libraries.

[code]
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)
[/code]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[quote name='VildNinja' timestamp='1311105593' post='4837590']
Most likely it's because you're manipulating some text, while an other thread is trying to reach it. Is your program multithreaded?
[/quote]
I'm not using any multithreading unless swing is doing it in the background.

[quote name='VildNinja' timestamp='1311105593' post='4837590']
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.
[/quote]
I already have a logger and put try catches on events I suspected might be the problem but haven't got anything yet.

[quote name='VildNinja' timestamp='1311105593' post='4837590']
But generally it's difficult to say any more, with this few informations.
[/quote]
I don't have much more information, this bug seems to happen randomly.

Share this post


Link to post
Share on other sites
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 :)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[quote name='VildNinja' timestamp='1311110568' post='4837631']
What does your program do?
[/quote]

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this