harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Cornwall (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-4892) [classlib][beans]
Date Wed, 03 Oct 2007 00:31:50 GMT
[classlib][beans]
-----------------

                 Key: HARMONY-4892
                 URL: https://issues.apache.org/jira/browse/HARMONY-4892
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
         Environment: All platforms, r571234
            Reporter: Andrew Cornwall


When Harmony introspects on a bean which happens to have a public static method named getXXX,
this public static method will be included in the array of PropertyDescriptors returned by
getPropertyDescriptor(). It should not be returned (and isn't by Sun JDK 1.5.0_04).

Bean code:
package beans;

public class Bugzilla127237Bean {

	public String a1;
	public int a2;
	public static String a3;
	
	public String getA1() {
		return a1;
	}
	public void setA1(String a1) {
		this.a1 = a1;
	}
	public int getA2() {
		return a2;
	}
	public void setA2(int a2) {
		this.a2 = a2;
	}
	//should not be returned by getPropertyDescriptors() 
	public static String getA3() {
		return a3;
	}
}


Test case:
package beans;

import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;

import junit.framework.TestCase;

public class Bugzilla127237 extends TestCase {

	public void testPropertyDescriptors() {
        BeanInfo info = null;
		try {
			info = Introspector.getBeanInfo( Bugzilla127237Bean.class );
		} catch (IntrospectionException e) {
			e.printStackTrace();
		}
		
        for ( PropertyDescriptor pd : info.getPropertyDescriptors() ) {
            System.out.println( pd.getName() );
        	assertFalse(pd.getName().equals("a3"));
        }
	}
}


Fix:

Index: StandardBeanInfo.java
===================================================================
RCS file: /team/jcldesktop/Harmony/src-beans/java/beans/StandardBeanInfo.java,v
retrieving revision 1.1
diff -u -r1.1 StandardBeanInfo.java
--- StandardBeanInfo.java	31 Aug 2007 16:48:00 -0000	1.1
+++ StandardBeanInfo.java	3 Oct 2007 00:27:10 -0000
@@ -510,7 +510,7 @@
         // Loop over the methods found, looking for public methods
         for (int i = 0; i < basicMethods.length; i++) {
             int modifiers = basicMethods[i].getModifiers();
-            if (Modifier.isPublic(modifiers)) {
+            if (Modifier.isPublic(modifiers) && !Modifier.isStatic(modifiers)) {
                 // Allocate a MethodDescriptor for this method
                 MethodDescriptor theDescriptor = new MethodDescriptor(
                         basicMethods[i]);


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message