Skip to main content

ArrayIndexOutOfBounds in DefaultPersistanceDelegate

4 replies [Last post]
Anonymous

I sometimes (but not always) get an index out of bounds exception when
attempting to XMLEncode a JToolBar with JButtons. I have attached the
exception trace.

Below is the code in DefaultPersistanceDelegate where the exception is
being thrown:

// Asssume the listeners are in the same order and that
there are no gaps.
// Eventually, this may need to do true differencing.
String addListenerMethodName =
d.getAddListenerMethod().getName();
for (int i = newL.length; i < oldL.length; i++) {
// System.out.println("Adding listener: " +
addListenerMethodName + oldL[i]);
invokeStatement(oldInstance, addListenerMethodName, new
Object[]{oldL[i]}, out);
}

String removeListenerMethodName =
d.getRemoveListenerMethod().getName();
for (int i = oldL.length; i < newL.length; i++) {
invokeStatement(oldInstance, removeListenerMethodName,
new Object[]{oldL[i]}, out);
}

The ArrayIndexOutOfBounds exception happens inside the second for loop.
Shouldn't that be newL[i] instead of oldL[i]?

What is odd is the inconsistency. I can sometimes XMLEncode the
JToolBar successfully, and then immediately do it again and it throws
the exception.

Bruce

java.lang.Exception: XMLEncoder: discarding statement JToolBar.add(JButton);
at java.beans.XMLEncoder.writeStatement(XMLEncoder.java:341)
at
java.beans.DefaultPersistenceDelegate.invokeStatement(DefaultPersistenceDelegate.java:239)
at
java.beans.java_awt_Container_PersistenceDelegate.initialize(MetaData.java:402)
at
java.beans.PersistenceDelegate.initialize(PersistenceDelegate.java:190)
at
java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java:393)
at
java.beans.PersistenceDelegate.initialize(PersistenceDelegate.java:190)
at
java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java:393)
at
java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:100)
at java.beans.Encoder.writeObject(Encoder.java:54)
at java.beans.XMLEncoder.writeObject(XMLEncoder.java:254)
at java.beans.Encoder.writeExpression(Encoder.java:259)
at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:369)
at
java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:97)
at java.beans.Encoder.writeObject(Encoder.java:54)
at java.beans.XMLEncoder.writeObject(XMLEncoder.java:254)
at java.beans.Encoder.writeExpression(Encoder.java:259)
at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:369)
at
java.beans.DefaultPersistenceDelegate.doProperty(DefaultPersistenceDelegate.java:216)
at
java.beans.DefaultPersistenceDelegate.initBean(DefaultPersistenceDelegate.java:251)
at
java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java:395)
...
Caused by: java.lang.ArrayIndexOutOfBoundsException: 1
at
java.beans.DefaultPersistenceDelegate.initBean(DefaultPersistenceDelegate.java:337)
at
java.beans.DefaultPersistenceDelegate.initialize(DefaultPersistenceDelegate.java:395)
at
java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:100)
at java.beans.Encoder.writeObject(Encoder.java:54)
at java.beans.XMLEncoder.writeObject(XMLEncoder.java:254)
at java.beans.Encoder.writeExpression(Encoder.java:259)
at java.beans.XMLEncoder.writeExpression(XMLEncoder.java:369)
at
java.beans.PersistenceDelegate.writeObject(PersistenceDelegate.java:97)
at java.beans.Encoder.writeObject(Encoder.java:54)
at java.beans.XMLEncoder.writeObject(XMLEncoder.java:254)
at java.beans.Encoder.writeObject1(Encoder.java:186)
at java.beans.Encoder.cloneStatement(Encoder.java:199)
at java.beans.Encoder.writeStatement(Encoder.java:230)
at java.beans.XMLEncoder.writeStatement(XMLEncoder.java:328)
... 49 more

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Kleopatra

Bruce Alspaugh schrieb:
> I sometimes (but not always) get an index out of bounds exception when
> attempting to XMLEncode a JToolBar with JButtons. I have attached the
> exception trace.
>

funny that the stacktrace doesn't show in the forum ... but even here on
the mailinglist, I can't see how it has to do with SwingLabs. You're
better served to post general swing/language stuff in the general
swing/language stuff related groups/forums (as you know )

there is no rule to how long it takes for any particular bug to be fixed
(even those obvious oversights) - yesterday I ran across

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4172022

from 1998. Okay, that one is an RFE (for better sizing api on
TableColumn), so needs some further thinking - nevertheless, it'll hit
its first decade birthday next year

Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

Bruce Alspaugh

There are many Swing-related lists out there. Which one would you recommend
that might get the attention of the people who work on these bugs?

Bruce

On 7/4/07, Kleopatra wrote:
>
> Bruce Alspaugh schrieb:
> > I sometimes (but not always) get an index out of bounds exception when
> > attempting to XMLEncode a JToolBar with JButtons. I have attached the
> > exception trace.
> >
>
> funny that the stacktrace doesn't show in the forum ... but even here on
> the mailinglist, I can't see how it has to do with SwingLabs. You're
> better served to post general swing/language stuff in the general
> swing/language stuff related groups/forums (as you know )
>
> there is no rule to how long it takes for any particular bug to be fixed
> (even those obvious oversights) - yesterday I ran across
>
> http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4172022
>
> from 1998. Okay, that one is an RFE (for better sizing api on
> TableColumn), so needs some further thinking - nevertheless, it'll hit
> its first decade birthday next year
>
> Jeanette
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
> For additional commands, e-mail: jdnc-help@jdnc.dev.java.net
>
>
[att1.html]

Kleopatra

Bruce Alspaugh schrieb:
> There are many Swing-related lists out there. Which one would you
> recommend that might get the attention of the people who work on these bugs?
>

no idea - as I don't know who (not even if anybody) is working on that.
You might consider working on it yourself and contribute in the openjdk
process.

Jeanette

---------------------------------------------------------------------
To unsubscribe, e-mail: jdnc-unsubscribe@jdnc.dev.java.net
For additional commands, e-mail: jdnc-help@jdnc.dev.java.net

Bruce Alspaugh

Upon further investigation, I seem to have stumbled across a known bug in
Swing:

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6570354

How long does it take to get these things fixed? Is there a workaround?

Bruce
[att1.html]