You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Tim Ellison (JIRA)" <ji...@apache.org> on 2007/10/11 16:25:50 UTC

[jira] Assigned: (HARMONY-4892) [classlib][beans] Bean introspection should not find static methods

     [ https://issues.apache.org/jira/browse/HARMONY-4892?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tim Ellison reassigned HARMONY-4892:
------------------------------------

    Assignee: Tim Ellison

> [classlib][beans] Bean introspection should not find static methods
> -------------------------------------------------------------------
>
>                 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
>            Assignee: Tim Ellison
>
> 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.