bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug classpath/22784] java.beans.ExplicitBeanInfo bad array index


From: gcc-bugzilla at gcc dot gnu dot org
Subject: [Bug classpath/22784] java.beans.ExplicitBeanInfo bad array index
Date: 16 Oct 2005 01:27:11 -0000

The getIcon() method of ExplicitBeanInfo indexes its icons array using the icon
type values.  The icon types (defined in BeanInfo) range from 1 to 4, not from
0 to 3.  Either the wrong icon is retrieved, or in the case of 4, an
ArrayIndexOutOfBoundsException is thrown.

Test Snippet:
public void testShouldNotHaveIcon() throws Exception
{
    BeanInfo simpleBeanInfo = Introspector.getBeanInfo(Object.class);
    assertEquals(null,
simpleBeanInfo.getIcon(java.beans.BeanInfo.ICON_MONO_32x32));
}

Original:
public java.awt.Image getIcon(int iconType) {
    return icons != null ? icons[iconType] : null;
}

Recommended Fix:
public java.awt.Image getIcon(int iconType) {
    return icons != null ? icons[iconType-1] : null;
}


------- Comment #1 from from-classpath at savannah dot gnu dot org  2004-10-13 
13:25 -------
I just commited a patch to GNU classpath CVS to fix little
bug. Thanks for reporting.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22784





reply via email to

[Prev in Thread] Current Thread [Next in Thread]