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

[jira] Created: (HARMONY-4892) [classlib][beans]

[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.


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

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4892?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tim Ellison resolved HARMONY-4892.
----------------------------------

    Resolution: Fixed

Thanks for the bug Andrew.  The code in that area has changed a bit, so the fix is a bit different to that you suggested.

Fixed in BEANS module at repo revision r583834.

Please check it fully resolves your issue.


> [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.


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

Posted by "Andrew Cornwall (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4892?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrew Cornwall updated HARMONY-4892:
-------------------------------------

    Summary: [classlib][beans] Bean introspection should not find static methods  (was: [classlib][beans])

> [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
>
> 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.


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

Posted by "Andrew Cornwall (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4892?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrew Cornwall updated HARMONY-4892:
-------------------------------------


Also needs to be fixed in introspectSet()

> [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
>
> 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.


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

Posted by "Mark Hindess (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/HARMONY-4892?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12532223 ] 

Mark Hindess commented on HARMONY-4892:
---------------------------------------

Andrew,

Many thanks for the bug report and fix information.  Could you possibly attach a patch - or two. one with the regression test(s) and one with the fix(es) - as described in the "Guidelines on how to Create and Submit a Patch" section of:

  http://harmony.apache.org/get-involved.html

Specifically, be sure to tick the box saying "Grant license to ASF for inclusion in ASF works" or we can't integrate these changes.

-Mark.


> [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
>
> 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.


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

Posted by "Tim Ellison (JIRA)" <ji...@apache.org>.
     [ 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.


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

Posted by "Andrew Cornwall (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/HARMONY-4892?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Andrew Cornwall updated HARMONY-4892:
-------------------------------------


Whoops, I think that fix is in the wrong place. It should be in introspectGet():

    @SuppressWarnings("unchecked")
    private static void introspectGet(Method theMethod,
            HashMap<String, HashMap> propertyTable) {
        String methodName = theMethod.getName();
        if (methodName == null) {
            return;
        }

        int prefixLength = 0;
        if (methodName.startsWith(PREFIX_GET)) {
            prefixLength = PREFIX_GET.length();
        }

        //  only include public instance methods
        int modifier = theMethod.getModifiers();
        if (Modifier.isStatic(modifier) || Modifier.isAbstract(modifier)
                || !Modifier.isPublic(modifier)) {
            return;
        }
        
        if (methodName.startsWith(PREFIX_IS)) {
            prefixLength = PREFIX_IS.length();
        }



> [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
>
> 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.