Return-Path: Delivered-To: apmail-harmony-commits-archive@www.apache.org Received: (qmail 15366 invoked from network); 3 Oct 2007 01:16:42 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Oct 2007 01:16:42 -0000 Received: (qmail 14280 invoked by uid 500); 3 Oct 2007 01:16:31 -0000 Delivered-To: apmail-harmony-commits-archive@harmony.apache.org Received: (qmail 14253 invoked by uid 500); 3 Oct 2007 01:16:30 -0000 Mailing-List: contact commits-help@harmony.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@harmony.apache.org Delivered-To: mailing list commits@harmony.apache.org Received: (qmail 14243 invoked by uid 99); 3 Oct 2007 01:16:30 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 02 Oct 2007 18:16:30 -0700 X-ASF-Spam-Status: No, hits=-100.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO brutus.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Oct 2007 01:16:41 +0000 Received: from brutus (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 98B50714187 for ; Tue, 2 Oct 2007 18:15:50 -0700 (PDT) Message-ID: <31698367.1191374150606.JavaMail.jira@brutus> Date: Tue, 2 Oct 2007 18:15:50 -0700 (PDT) From: "Andrew Cornwall (JIRA)" To: commits@harmony.apache.org Subject: [jira] Updated: (HARMONY-4892) [classlib][beans] Bean introspection should not find static methods In-Reply-To: <22253364.1191371510590.JavaMail.jira@brutus> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on 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 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.