From dev-return-35573-apmail-harmony-dev-archive=harmony.apache.org@harmony.apache.org Tue Dec 09 14:52:45 2008 Return-Path: Delivered-To: apmail-harmony-dev-archive@www.apache.org Received: (qmail 62813 invoked from network); 9 Dec 2008 14:52:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 9 Dec 2008 14:52:44 -0000 Received: (qmail 23031 invoked by uid 500); 9 Dec 2008 14:52:54 -0000 Delivered-To: apmail-harmony-dev-archive@harmony.apache.org Received: (qmail 23002 invoked by uid 500); 9 Dec 2008 14:52:54 -0000 Mailing-List: contact dev-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 dev@harmony.apache.org Received: (qmail 22991 invoked by uid 99); 9 Dec 2008 14:52:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Dec 2008 06:52:54 -0800 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of zhoukevin83@gmail.com designates 64.233.182.189 as permitted sender) Received: from [64.233.182.189] (HELO nf-out-0910.google.com) (64.233.182.189) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 09 Dec 2008 14:51:22 +0000 Received: by nf-out-0910.google.com with SMTP id c7so933925nfi.40 for ; Tue, 09 Dec 2008 06:52:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type:references; bh=AmugpZ3AM3Opv3qFC7XpeCGXanG3eKb3L5oM+D1r540=; b=Wn0mOz+Foy+VldGA1GW/jQGuekNf5FO3oNj7d5/GJknGzTcw0QanPDRCTNWyjkfgp+ ORykHD5ZHczacV26lP+6gAwp/EeJgnbNcblbsfn1m8XrdhxdgPUt9rVuVhImWVtq6Dni q3gFeJvx64ZH80/x98tMyDxydUKUmPlxPlGDU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:references; b=VtH87eTOINGBzL0MnDN39FssEL9SZs+qEPWgy6NsSdAikWRp6QvzOY0VbC69q+HqGB TKQ4FGn8KVZ0npN4C8lg/p5okI0VDHTp9ZBZz42KAulDIvutMj4Jnw7DEBNDxkgm2xZJ zR2Ki3rYQjK4evUidk/ZAWyyjRB7wryKGLRk8= Received: by 10.210.109.10 with SMTP id h10mr218570ebc.154.1228834328606; Tue, 09 Dec 2008 06:52:08 -0800 (PST) Received: by 10.210.72.11 with HTTP; Tue, 9 Dec 2008 06:52:08 -0800 (PST) Message-ID: <70c713190812090652m23605a8dy184ad3ad761d3660@mail.gmail.com> Date: Tue, 9 Dec 2008 22:52:08 +0800 From: "Kevin Zhou" To: dev@harmony.apache.org Subject: Re: struts test suite is breaking In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_91584_25821842.1228834328582" References: <70c713190812082253v59f2bf63pa646e238ac060ec9@mail.gmail.com> <70c713190812082259p4d3e70e1i96eda6df3880f3d3@mail.gmail.com> <70c713190812090103n30117da3qf3b1f70cc464a51f@mail.gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_91584_25821842.1228834328582 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Has raised a Harmony JIRA [1]. [1] https://issues.apache.org/jira/browse/HARMONY-6038 On Tue, Dec 9, 2008 at 5:16 PM, chunrong lai wrote: > Great to see that. > I have still one small confusion that why r647904 will pass the test if > superType is null, since what r647921 did for the part is as below. > @@ -276,7 +292,8 @@ > // Sub is PropertyDescriptor > if (subIndexedType =3D=3D null) { > // Same property type > - if (subType.getName().equals(superType.getName())) { > + if (subType !=3D null && > + subType.getName().equals(superType.getName()= )) > { > if ((subGet =3D=3D null) && (superGet !=3D null))= { > subDesc.setReadMethod(superGet); > } > > Anyway I am happy to see the issue will be fixed. > On Tue, Dec 9, 2008 at 5:03 PM, Kevin Zhou wrote: > > > Has successfully recreate this defect. > > I think the null value of superType is the root cause for this defect. > > > > > > On Tue, Dec 9, 2008 at 2:59 PM, Kevin Zhou > wrote: > > > > > Thereinto, StandBeanInfo.mergeProps method is used to merge the > > > PropertyDescriptor with superclass. > > > The "superType" is the type of one of its super classes's propreties. > > > > > > > > > On Tue, Dec 9, 2008 at 2:53 PM, Kevin Zhou > > wrote: > > > > > >> From the trace, the NPE is thrown from StandBeanInfo.mergeProps() > (line > > >> 295): > > >> if (subType !=3D null &&subType.getName().equals(superType.getName()= )) { > > >> //295 > > >> ... > > >> } > > >> where "superType" may be null. > > >> Next Action: Will Construct test framework for this, and check wheth= er > > >> this is the root cause for this defect. > > >> > > >> > > >> On Tue, Dec 9, 2008 at 2:17 PM, chunrong lai > >wrote: > > >> > > >>> > > >>> hi, colleagues: > > >>> Sorry for the late report. But I see that the struts test suite > is > > >>> breaking due to r647921 with below stackTrace: > > >>> > > >>> Caused by: java.lang.NullPointerException > > >>> at > > >>> java.beans.StandardBeanInfo.mergeProps(StandardBeanInfo.java:295) > > >>> at > > >>> java.beans.StandardBeanInfo.mergeBeanInfo(StandardBeanInfo.java:209= ) > > >>> at > > java.beans.Introspector.getBeanInfoImpl(Introspector.java:282) > > >>> at > > >>> java.beans.Introspector.getBeanInfoImplAndInit(Introspector.java:34= 7) > > >>> at java.beans.Introspector.getBeanInfo(Introspector.java:16= 2) > > >>> at > > >>> freemarker.ext.beans.BeansWrapper.populateClassMapWithBeanInfo(Bean= sW > > >>> rapper.java:844) > > >>> ... 52 more > > >>> > > >>> To reproduce the error one needs to (reproducible in windows a= nd > > >>> Linux platforms) > > >>> (1) Start a webserver > > >>> (1.1) Extract apache-tomcat-6.0.18.tar.gz from ( > > >>> http://tomcat.apache.org/download-60.cgi) and cd the extracted > > directory > > >>> "apache-tomcat-6.0.18". > > >>> (1.2) Create apache-tomcat-6.0.18/my_base, > > >>> apache-tomcat-6.0.18/struts_test, > > apache-tomcat-6.0.18/struts_test/logs, > > >>> apache-tomcat-6.0.18/struts_test/temp, > > >>> apache-tomcat-6.0.18/struts_test/webapps/, > > >>> apache-tomcat-6.0.18/struts_test/work, > > >>> (1.3) Copy struts2-showcase-2.0.6.war (in > > >>> struts-2.0.6-all/apps/ extracted from > > >>> http://archive.apache.org/dist/struts/binaries/struts-2.0.6-all.zip= ) > > to > > >>> apache-tomcat-6.0.18/struts_test, copy apache-tomcat-6.0.18/conf to > > >>> apache-tomcat-6.0.18/struts_test > > >>> (1.4) set > > >>> CATALINA_BASE=3D=85./apache-tomcat-6.0.18/my_base/struts_test, set > > >>> JRE_HOME=3D...... > > >>> (1.5) cd =85./apache-tomcat-6.0.18/, $bin/catalina.sh run (or > > >>> catalina.bat for windows platform) > > >>> > > >>> (2) Run the attached test case seperatedly > > >>> (2.1) Unzip the htmlunit-2.3.zip from > > >>> http://sourceforge.net/project/showfiles.php?group_id=3D47038 and > > include > > >>> the jar files from "htmlunit-2.3/lib into CLASSPATH > > >>> (2.2) Compile and run the attached test case (also listed > below), > > >>> check the content of the result named debug.html to see the reporte= d > > >>> exception > > >>> > > >>> import java.io.*; > > >>> import java.net.URL; > > >>> import java.lang.Thread; > > >>> import java.util.*; > > >>> import java.io.FileOutputStream; > > >>> import com.gargoylesoftware.htmlunit.WebClient; > > >>> import com.gargoylesoftware.htmlunit.html.HtmlPage; > > >>> > > >>> public class struts_test_debug{ > > >>> public static void test_1(){ > > >>> try{ > > >>> URL baseurl=3Dnew URL("http://localhost:8080"); > > >>> String p =3D "/struts2-showcase-2.0.6/tags/non-ui/debug.jsp"= ; > > >>> final WebClient webClient =3D new WebClient(); > > >>> final HtmlPage page =3D (HtmlPage)webClient.getPage(new > > >>> URL(baseurl,p)); > > >>> //get the source code of webpage > > >>> String pHtml =3D page.getWebResponse().getContentAsString(); > > >>> writeFile(pHtml); > > >>> System.out.println("Generated file: 'Debug.html' in local"= ); > > >>> }catch(Exception e){} > > >>> } > > >>> > > >>> public static void main(String args[]){ > > >>> System.out.println("test start!"); > > >>> System.out.println("Reading remote file ..."); > > >>> test_1(); > > >>> System.out.println("test finished!"); > > >>> } > > >>> public static void writeFile(String pHtml){ > > >>> try{ > > >>> FileOutputStream out =3D new > FileOutputStream("Debug.html",false); > > >>> out.write(pHtml.getBytes()); > > >>> }catch(Exception e){} > > >>> } > > >>> } > > >>> > > >>> > > >>> From a...@apache.org Subject svn commit: r647921 - in > > >>> /harmony/enhanced/classlib/trunk/modules/beans/src: > > >>> main/java/java/beans/StandardBeanInfo.java > > >>> > > test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.ja= va > > >>> Date Mon, 14 Apr 2008 18:00:13 GMT > > >>> > > >>> Author: ayza > > >>> Date: Mon Apr 14 11:00:08 2008 > > >>> New Revision: 647921 > > >>> > > >>> URL: http://svn.apache.org/viewvc?rev=3D647921&view=3Drev > > >>> Log: > > >>> Applying patches from HARMONY-5675 ([classlib][beans] Introspector > > unable to determine set > > >>> method correctly) > > >>> > > >>> Modified: > > >>> > > > harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/St= andardBeanInfo.java > > >>> > > > harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/ha= rmony/beans/tests/java/beans/IntrospectorTest.java > > >>> > > >>> Modified: > > > harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/St= andardBeanInfo.java > > >>> URL: > > > http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/bean= s/src/main/java/java/beans/StandardBeanInfo.java?rev=3D647921&r1=3D647920&r= 2=3D647921&view=3Ddiff > > >>> > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > > >>> --- > > > harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/St= andardBeanInfo.java > > >>> (original) > > >>> +++ > > > harmony/enhanced/classlib/trunk/modules/beans/src/main/java/java/beans/St= andardBeanInfo.java > > >>> Mon Apr 14 11:00:08 2008 > > >>> @@ -47,6 +47,22 @@ > > >>> > > >>> private static final String SUFFIX_LISTEN =3D "Listener"; > > //$NON-NLS-1$ > > >>> > > >>> + private static final String STR_NORMAL =3D "normal"; //$NON-NL= S-1$ > > >>> + > > >>> + private static final String STR_INDEXED =3D "indexed"; > //$NON-NLS-1$ > > >>> + > > >>> + private static final String STR_VALID =3D "valid"; //$NON-NLS-= 1$ > > >>> + > > >>> + private static final String STR_INVALID =3D "invalid"; > //$NON-NLS-1$ > > >>> + > > >>> + private static final String STR_PROPERTY_TYPE =3D "PropertyTyp= e"; > > //$NON-NLS-1$ > > >>> + > > >>> + private static final String STR_IS_CONSTRAINED =3D > "isConstrained"; > > //$NON-NLS-1$ > > >>> + > > >>> + private static final String STR_SETTERS =3D "setters"; > //$NON-NLS-1$ > > >>> + > > >>> + private static final String STR_GETTERS =3D "getters"; > //$NON-NLS-1$ > > >>> + > > >>> private boolean explicitMethods =3D false; > > >>> > > >>> private boolean explicitProperties =3D false; > > >>> @@ -276,7 +292,8 @@ > > >>> // Sub is PropertyDescriptor > > >>> if (subIndexedType =3D=3D null) { > > >>> // Same property type > > >>> - if > (subType.getName().equals(superType.getName())) > > { > > >>> + if (subType !=3D null && > > >>> + > > subType.getName().equals(superType.getName())) { > > >>> if ((subGet =3D=3D null) && (superGet !=3D= null)) > { > > >>> subDesc.setReadMethod(superGet); > > >>> } > > >>> @@ -481,8 +498,6 @@ > > >>> * Introspects the supplied class and returns a list of the > public > > methods > > >>> * of the class > > >>> * > > >>> - * @param beanClass - > > >>> - * the class > > >>> * @return An array of MethodDescriptors with the public > methods. > > null if > > >>> * there are no public methods > > >>> */ > > >>> @@ -533,8 +548,8 @@ > > >>> * Introspects the supplied class and returns a list of the > > Properties of > > >>> * the class > > >>> * > > >>> - * @param beanClass - > > >>> - * the Class > > >>> + * @param stopClass - > > >>> + * the to introspecting at > > >>> * @return The list of Properties as an array of > > PropertyDescriptors > > >>> * @throws IntrospectionException > > >>> */ > > >>> @@ -557,6 +572,9 @@ > > >>> introspectSet(theMethods[i].getMethod(), propertyTable= ); > > >>> } > > >>> > > >>> + // fix possible getter & setter collisions > > >>> + fixGetSet(propertyTable); > > >>> + > > >>> // If there are listener methods, should be bound. > > >>> MethodDescriptor[] allMethods =3D introspectMethods(true); > > >>> if (stopClass !=3D null) { > > >>> @@ -586,17 +604,17 @@ > > >>> if (table =3D=3D null) { > > >>> continue; > > >>> } > > >>> - String normalTag =3D (String) table.get("normal"); > > //$NON-NLS-1$ > > >>> - String indexedTag =3D (String) table.get("indexed"); > > //$NON-NLS-1$ > > >>> + String normalTag =3D (String) table.get(STR_NORMAL); > > >>> + String indexedTag =3D (String) table.get(STR_INDEXED); > > >>> > > >>> if ((normalTag =3D=3D null) && (indexedTag =3D=3D null= )) { > > >>> continue; > > >>> } > > >>> > > >>> - Method get =3D (Method) table.get("normalget"); > > //$NON-NLS-1$ > > >>> - Method set =3D (Method) table.get("normalset"); > > //$NON-NLS-1$ > > >>> - Method indexedGet =3D (Method) table.get("indexedget")= ; > > //$NON-NLS-1$ > > >>> - Method indexedSet =3D (Method) table.get("indexedset")= ; > > //$NON-NLS-1$ > > >>> + Method get =3D (Method) table.get(STR_NORMAL + > PREFIX_GET); > > >>> + Method set =3D (Method) table.get(STR_NORMAL + > PREFIX_SET); > > >>> + Method indexedGet =3D (Method) table.get(STR_INDEXED + > > PREFIX_GET); > > >>> + Method indexedSet =3D (Method) table.get(STR_INDEXED + > > PREFIX_SET); > > >>> > > >>> PropertyDescriptor propertyDesc =3D null; > > >>> if (indexedTag =3D=3D null) { > > >>> @@ -619,7 +637,7 @@ > > >>> } else { > > >>> propertyDesc.setBound(false); > > >>> } > > >>> - if (table.get("isConstrained") =3D=3D Boolean.TRUE) { > > //$NON-NLS-1$ > > >>> + if (table.get(STR_IS_CONSTRAINED) =3D=3D Boolean.TRUE)= { > > //$NON-NLS-1$ > > >>> propertyDesc.setConstrained(true); > > >>> } > > >>> propertyList.add(propertyDesc); > > >>> @@ -659,13 +677,20 @@ > > >>> @SuppressWarnings("unchecked") > > >>> private static void introspectGet(Method theMethod, > > >>> HashMap propertyTable) { > > >>> - String methodName =3D theMethod.getName(); > > >>> - if (methodName =3D=3D null) { > > >>> + > > >>> + String methodName =3D theMethod.getName(); > > >>> + int prefixLength =3D 0; > > >>> + String propertyName; > > >>> + Class propertyType; > > >>> + Class[] paramTypes; > > >>> + HashMap table; > > >>> + ArrayList getters; > > >>> + > > >>> + if (methodName =3D=3D null) { > > >>> return; > > >>> } > > >>> > > >>> - int prefixLength =3D 0; > > >>> - if (methodName.startsWith(PREFIX_GET)) { > > >>> + if (methodName.startsWith(PREFIX_GET)) { > > >>> prefixLength =3D PREFIX_GET.length(); > > >>> } > > >>> > > >>> @@ -677,153 +702,325 @@ > > >>> return; > > >>> } > > >>> > > >>> - String propertyName =3D > > decapitalize(methodName.substring(prefixLength)); > > >>> - // validate property name > > >>> + propertyName =3D > > decapitalize(methodName.substring(prefixLength)); > > >>> + > > >>> + // validate property name > > >>> if (!isValidProperty(propertyName)) { > > >>> return; > > >>> } > > >>> > > >>> - Class propertyType =3D theMethod.getReturnType(); > > >>> + // validate return type > > >>> + propertyType =3D theMethod.getReturnType(); > > >>> > > >>> - // check return type getMethod > > >>> - if (propertyType.getName().equals(Void.TYPE.getName()))= { > > >>> - return; > > >>> - } > > >>> + if (propertyType =3D=3D null || propertyType =3D=3D void.c= lass) { > > >>> + return; > > >>> + } > > >>> > > >>> // isXXX return boolean > > >>> if (prefixLength =3D=3D 2) { > > >>> - if > > (!propertyType.getName().equals(Boolean.TYPE.getName())) { > > >>> + if (!(propertyType =3D=3D boolean.class)) { > > >>> return; > > >>> } > > >>> } > > >>> > > >>> - // indexed get method > > >>> - Class[] paramTypes =3D theMethod.getParameterTypes(); > > >>> - > > >>> - if (paramTypes.length > 1) { > > >>> + // validate parameter types > > >>> + paramTypes =3D theMethod.getParameterTypes(); > > >>> + if (paramTypes.length > 1 || > > >>> + (paramTypes.length =3D=3D 1 && paramTypes[0] !=3D > > int.class)) { > > >>> return; > > >>> } > > >>> > > >>> - String tag =3D "normal"; //$NON-NLS-1$ > > >>> - > > >>> - if (paramTypes.length =3D=3D 1) { > > >>> - if > > (paramTypes[0].getName().equals(Integer.TYPE.getName())) { > > >>> - tag =3D "indexed"; //$NON-NLS-1$ > > >>> - } else { > > >>> - return; > > >>> - } > > >>> + // > > >>> > > >>> - } > > >>> - > > >>> - HashMap table =3D propertyTable.get(propertyName); > > >>> + table =3D propertyTable.get(propertyName); > > >>> if (table =3D=3D null) { > > >>> table =3D new HashMap(); > > >>> propertyTable.put(propertyName, table); > > >>> } > > >>> > > >>> - // the "get" propertyType is conflict with "set" > > propertyType > > >>> - Class oldPropertyType =3D (Class) table.get(tag + > > "PropertyType"); //$NON-NLS-1$ > > >>> - if ((oldPropertyType !=3D null) > > >>> - && > > (!oldPropertyType.getName().equals(propertyType.getName()))) { > > >>> - table.put(tag, "invalid"); //$NON-NLS-1$ > > >>> - table.remove(tag + "set"); //$NON-NLS-1$ > > >>> - } else { > > >>> - table.put(tag, "valid"); //$NON-NLS-1$ > > >>> - } > > >>> - > > >>> - table.put(tag + "PropertyType", propertyType); > > //$NON-NLS-1$ > > >>> + getters =3D (ArrayList) table.get(STR_GETTERS); > > >>> + if (getters =3D=3D null) { > > >>> + getters =3D new ArrayList(); > > >>> + table.put(STR_GETTERS, getters); > > >>> + } > > >>> > > >>> - // According to the spec "is" method should be used pri= or > > to "get" > > >>> - if (prefixLength =3D=3D 3) { > > >>> - if (!table.containsKey(tag + "get")) { > > //$NON-NLS-1$ > > >>> - table.put(tag + "get", theMethod); > > //$NON-NLS-1$ > > >>> - } > > >>> - } else { > > >>> - table.put(tag + "get", theMethod); //$NON-NLS-1= $ > > >>> - } > > >>> - } > > >>> + // add current method as a valid getter > > >>> + getters.add(theMethod); > > >>> + } > > >>> > > >>> @SuppressWarnings("unchecked") > > >>> private static void introspectSet(Method theMethod, > > >>> HashMap propertyTable) { > > >>> - String methodName =3D theMethod.getName(); > > >>> - if (methodName =3D=3D null) { > > >>> - return; > > >>> - } > > >>> > > >>> - int prefixLength =3D 0; > > >>> - if (methodName.startsWith(PREFIX_SET)) { > > >>> - prefixLength =3D PREFIX_GET.length(); > > >>> - } > > >>> + String methodName =3D theMethod.getName(); > > >>> + String propertyName; > > >>> + Class returnType; > > >>> + Class[] paramTypes; > > >>> > > >>> - if (prefixLength =3D=3D 0) { > > >>> + if (methodName =3D=3D null || > !methodName.startsWith(PREFIX_SET)) > > { > > >>> return; > > >>> } > > >>> > > >>> - String propertyName =3D > > decapitalize(methodName.substring(prefixLength)); > > >>> + propertyName =3D decapitalize(methodName.substring( > > >>> + PREFIX_SET.length())); > > >>> > > >>> // validate property name > > >>> if (!isValidProperty(propertyName)) { > > >>> return; > > >>> } > > >>> > > >>> - Class returnType =3D theMethod.getReturnType(); > > >>> + // validate return type > > >>> + returnType =3D theMethod.getReturnType(); > > >>> > > >>> - if (!returnType.getName().equals(Void.TYPE.getName())) { > > >>> +// if (!returnType.getName().equals(Void.TYPE.getName())) { > > >>> + if (!(returnType =3D=3D void.class)) { > > >>> return; > > >>> } > > >>> > > >>> - // indexed get method > > >>> - Class[] paramTypes =3D theMethod.getParameterTypes(); > > >>> + // validate param types > > >>> + paramTypes =3D theMethod.getParameterTypes(); > > >>> > > >>> - if ((paramTypes.length =3D=3D 0) || (paramTypes.length > 2= )) { > > >>> + if (paramTypes.length =3D=3D 0 || paramTypes.length > 2 || > > >>> + (paramTypes.length =3D=3D 2 && paramTypes[0] !=3D > > int.class)) { > > >>> return; > > >>> } > > >>> > > >>> - String tag =3D "normal"; //$NON-NLS-1$ > > >>> - > > >>> - Class propertyType =3D paramTypes[0]; > > >>> - > > >>> - if (paramTypes.length =3D=3D 2) { > > >>> - if > > (paramTypes[0].getName().equals(Integer.TYPE.getName())) { > > >>> - tag =3D "indexed"; //$NON-NLS-1$ > > >>> - propertyType =3D paramTypes[1]; > > >>> - } else { > > >>> - return; > > >>> - } > > >>> - } > > >>> + // > > >>> > > >>> HashMap table =3D propertyTable.get(propertyName); > > >>> if (table =3D=3D null) { > > >>> table =3D new HashMap(); > > >>> + propertyTable.put(propertyName, table); > > >>> } > > >>> > > >>> - Class oldPropertyType =3D (Class) table.get(tag + > > "PropertyType"); //$NON-NLS-1$ > > >>> - if ((oldPropertyType !=3D null) > > >>> - && > > (!oldPropertyType.getName().equals(propertyType.getName()))) { > > >>> - table.put(tag, "invalid"); //$NON-NLS-1$ > > >>> - return; > > >>> + ArrayList setters =3D (ArrayList) > > table.get(STR_SETTERS); > > >>> + if (setters =3D=3D null) { > > >>> + setters =3D new ArrayList(); > > >>> + table.put(STR_SETTERS, setters); > > >>> } > > >>> > > >>> - table.put(tag, "valid"); //$NON-NLS-1$ > > >>> - table.put(tag + "set", theMethod); //$NON-NLS-1$ > > >>> - table.put(tag + "PropertyType", propertyType); //$NON-NLS-= 1$ > > >>> - > > >>> // handle constrained > > >>> Class[] exceptions =3D theMethod.getExceptionTypes(); > > >>> for (Class e : exceptions) { > > >>> if (e.equals(PropertyVetoException.class)) { > > >>> - table.put("isConstrained", Boolean.TRUE); > > //$NON-NLS-1$ > > >>> + table.put(STR_IS_CONSTRAINED, Boolean.TRUE); > > //$NON-NLS-1$ > > >>> + } > > >>> + } > > >>> + > > >>> + // add new setter > > >>> + setters.add(theMethod); > > >>> + } > > >>> + > > >>> + /** > > >>> + * Checks and fixs all cases when several incompatible checker= s > / > > >>> + * getters were specified for single property. > > >>> + * @param propertyTable > > >>> + * @throws IntrospectionException > > >>> + */ > > >>> + private void fixGetSet(HashMap propertyTable) > > >>> + throws IntrospectionException { > > >>> + > > >>> + if (propertyTable =3D=3D null) { > > >>> + return; > > >>> + } > > >>> + > > >>> + for (String key : propertyTable.keySet()) { > > >>> + HashMap table =3D propertyTable.get(ke= y); > > >>> + ArrayList getters =3D (ArrayList) > > table.get(STR_GETTERS); > > >>> + ArrayList setters =3D (ArrayList) > > table.get(STR_SETTERS); > > >>> + > > >>> + Method normalGetter =3D null; > > >>> + Method indexedGetter =3D null; > > >>> + Method normalSetter =3D null; > > >>> + Method indexedSetter =3D null; > > >>> + > > >>> + Class normalPropType =3D null; > > >>> + Class indexedPropType =3D null; > > >>> + > > >>> + if (getters =3D=3D null) { > > >>> + getters =3D new ArrayList(); > > >>> + } > > >>> + > > >>> + if (setters =3D=3D null) { > > >>> + setters =3D new ArrayList(); > > >>> + } > > >>> + > > >>> + // retrieve getters > > >>> + for (Method getter: getters) { > > >>> + // checks if it's a normal getter > > >>> + if (getter.getParameterTypes() =3D=3D null || > > >>> + getter.getParameterTypes().length =3D=3D 0= ) { > > >>> + // normal getter found > > >>> + if (normalGetter =3D=3D null || > > >>> + getter.getName().startsWith(PREFIX_IS)= ) > { > > >>> + normalGetter =3D getter; > > >>> + } > > >>> + } > > >>> + > > >>> + // checks if it's an indexed getter > > >>> + if (getter.getParameterTypes() !=3D null && > > >>> + getter.getParameterTypes().length =3D=3D 1= && > > >>> + getter.getParameterTypes()[0] =3D=3D int.c= lass) > { > > >>> + // indexed getter found > > >>> + if (indexedGetter =3D=3D null || > > >>> + getter.getName().startsWith(PREFIX_IS)= ) > { > > >>> + indexedGetter =3D getter; > > >>> + } > > >>> + } > > >>> + } > > >>> + > > >>> + // retrieve normal setter > > >>> + if (normalGetter !=3D null) { > > >>> + // Now we will try to look for normal setter of th= e > > same type. > > >>> + Class propertyType =3D normalGetter.getReturnType(= ); > > >>> + > > >>> + for (Method setter: setters) { > > >>> + if (setter.getParameterTypes().length =3D=3D 1= && > > >>> + > > propertyType.equals(setter.getParameterTypes()[0])) > > >>> + { > > >>> + normalSetter =3D setter; > > >>> + break; > > >>> + } > > >>> + } > > >>> + } else { > > >>> + // Normal getter wasn't defined. Let's look for th= e > > last > > >>> + // defined setter > > >>> + > > >>> + for (Method setter: setters) { > > >>> + if (setter.getParameterTypes().length =3D=3D 1= ) { > > >>> + normalSetter =3D setter; > > >>> + } > > >>> + } > > >>> } > > >>> + > > >>> + // retrieve indexed setter > > >>> + if (indexedGetter !=3D null) { > > >>> + // Now we will try to look for indexed setter of t= he > > same type. > > >>> + Class propertyType =3D indexedGetter.getReturnType= (); > > >>> + > > >>> + for (Method setter: setters) { > > >>> + if (setter.getParameterTypes().length =3D=3D 2= && > > >>> + setter.getParameterTypes()[0] =3D=3D > int.class > > && > > >>> + > > propertyType.equals(setter.getParameterTypes()[1])) > > >>> + { > > >>> + indexedSetter =3D setter; > > >>> + break; > > >>> + } > > >>> + } > > >>> + } else { > > >>> + // Indexed getter wasn't defined. Let's look for t= he > > last > > >>> + // defined indexed setter > > >>> + > > >>> + for (Method setter: setters) { > > >>> + if (setter.getParameterTypes().length =3D=3D 2= && > > >>> + setter.getParameterTypes()[0] =3D=3D > > int.class) { > > >>> + indexedSetter =3D setter; > > >>> + } > > >>> + } > > >>> + } > > >>> + > > >>> + // determine property type > > >>> + if (normalGetter !=3D null) { > > >>> + normalPropType =3D normalGetter.getReturnType(); > > >>> + } else if (normalSetter !=3D null) { > > >>> + normalPropType =3D > normalSetter.getParameterTypes()[0]; > > >>> + } > > >>> + > > >>> + // determine indexed getter/setter type > > >>> + if (indexedGetter !=3D null) { > > >>> + indexedPropType =3D indexedGetter.getReturnType(); > > >>> + } else if (indexedSetter !=3D null) { > > >>> + indexedPropType =3D > > indexedSetter.getParameterTypes()[1]; > > >>> + } > > >>> + > > >>> + // convert array-typed normal getters to indexed gette= rs > > >>> + if (normalGetter !=3D null && > > normalGetter.getReturnType().isArray()) > > >>> + { > > >>> + > > >>> + } > > >>> + > > >>> + // RULES > > >>> + // These rules were created after performing extensive > > black-box > > >>> + // testing of RI > > >>> + > > >>> + // RULE1 > > >>> + // Both normal getter and setter of the same type were > > defined; > > >>> + // no indexed getter/setter *PAIR* of the other type > > defined > > >>> + if (normalGetter !=3D null && normalSetter !=3D null &= & > > >>> + (indexedGetter =3D=3D null || indexedSetter = =3D=3D null) > > && > > >>> + normalPropType !=3D indexedPropType) { > > >>> +// String tag =3D normalPropType.isArray() ? > > >>> +// STR_INDEXED : STR_NORMAL; > > >>> + String tag =3D STR_NORMAL; > > >>> + > > >>> + table.put(tag, STR_VALID); > > >>> + table.put(tag + PREFIX_GET, normalGetter); > > >>> + table.put(tag + PREFIX_SET, normalSetter); > > >>> + table.put(tag + STR_PROPERTY_TYPE, normalPropType)= ; > > >>> + continue; > > >>> + } > > >>> + > > >>> + // RULE2 > > >>> + // normal getter and/or setter was defined; no indexed > > >>> + // getters & setters defined > > >>> + if ((normalGetter !=3D null || normalSetter !=3D null)= && > > >>> + indexedGetter =3D=3D null && indexedSetter =3D= =3D null) > { > > >>> +// String tag =3D normalPropType.isArray() ? > > >>> +// STR_INDEXED : STR_NORMAL; > > >>> + String tag =3D STR_NORMAL; > > >>> + > > >>> + table.put(tag, STR_VALID); > > >>> + table.put(tag + PREFIX_GET, normalGetter); > > >>> + table.put(tag + PREFIX_SET, normalSetter); > > >>> + table.put(tag + STR_PROPERTY_TYPE, normalPropType)= ; > > >>> + continue; > > >>> + } > > >>> + > > >>> + // RULE3 > > >>> + // mix of normal / indexed getters and setters are > > defined. Types > > >>> + // are compatible > > >>> + if ((normalGetter !=3D null || normalSetter !=3D null)= && > > >>> + (indexedGetter !=3D null || indexedSetter !=3D= null) > > && > > >>> + normalPropType.isArray() && > > >>> + normalPropType.getComponentType() =3D=3D > > indexedPropType) { > > >>> + table.put(STR_NORMAL, STR_VALID); > > >>> + table.put(STR_NORMAL + PREFIX_GET, normalGetter); > > >>> + table.put(STR_NORMAL + PREFIX_SET, normalSetter); > > >>> + table.put(STR_NORMAL + STR_PROPERTY_TYPE, > > normalPropType); > > >>> + > > >>> + table.put(STR_INDEXED, STR_VALID); > > >>> + table.put(STR_INDEXED + PREFIX_GET, indexedGetter)= ; > > >>> + table.put(STR_INDEXED + PREFIX_SET, indexedSetter)= ; > > >>> + table.put(STR_INDEXED + STR_PROPERTY_TYPE, > > indexedPropType); > > >>> + > > >>> + continue; > > >>> + } > > >>> + > > >>> + // RULE4 > > >>> + // no normal normal getter / setter. > > >>> + // Only indexed getter and/or setter is given > > >>> + // no normal setters / getters defined > > >>> + if (normalSetter =3D=3D null && normalGetter =3D=3D nu= ll && > > >>> + (indexedGetter !=3D null || indexedSetter !=3D > null)) > > { > > >>> + table.put(STR_INDEXED, STR_VALID); > > >>> + table.put(STR_INDEXED + PREFIX_GET, indexedGetter)= ; > > >>> + table.put(STR_INDEXED + PREFIX_SET, indexedSetter)= ; > > >>> + table.put(STR_INDEXED + STR_PROPERTY_TYPE, > > >>> + indexedPropType); > > >>> + continue; > > >>> + } > > >>> + > > >>> + // default rule - invalid property > > >>> + table.put(STR_NORMAL, STR_INVALID); > > >>> + table.put(STR_INDEXED, STR_INVALID); > > >>> } > > >>> - propertyTable.put(propertyName, table); > > >>> + > > >>> } > > >>> > > >>> /** > > >>> * Introspects the supplied Bean class and returns a list of t= he > > Events of > > >>> * the class > > >>> * > > >>> - * @param beanClass > > >>> * @return the events > > >>> * @throws IntrospectionException > > >>> */ > > >>> > > >>> Modified: > > > harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/ha= rmony/beans/tests/java/beans/IntrospectorTest.java > > >>> URL: > > > http://svn.apache.org/viewvc/harmony/enhanced/classlib/trunk/modules/bean= s/src/test/java/org/apache/harmony/beans/tests/java/beans/IntrospectorTest.= java?rev=3D647921&r1=3D647920&r2=3D647921&view=3Ddiff > > >>> > > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > > >>> --- > > > harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/ha= rmony/beans/tests/java/beans/IntrospectorTest.java > > >>> (original) > > >>> +++ > > > harmony/enhanced/classlib/trunk/modules/beans/src/test/java/org/apache/ha= rmony/beans/tests/java/beans/IntrospectorTest.java > > >>> Mon Apr 14 11:00:08 2008 > > >>> @@ -2331,4 +2331,254 @@ > > >>> assertFalse(pd.getName().equals("invisible")); > > >>> } > > >>> } > > >>> + > > >>> + /** > > >>> + * Tests tricky cases when several conflicting set/get methods > are > > defined. > > >>> + * All these tests pass on RI. > > >>> + * This is a regression test for HARMONY-5675 > > >>> + * @throws IntrospectionException > > >>> + */ > > >>> + public void test5675() throws IntrospectionException { > > >>> + BeanInfo bInfo; > > >>> + > > >>> + for (Class clz: new Class[] {TstBean5675.class, > > TstBean5675_2.class}) { > > >>> + > > >>> + bInfo =3D Introspector.getBeanInfo(clz); > > >>> + > > >>> + for (PropertyDescriptor desc: > > bInfo.getPropertyDescriptors()) { > > >>> + > > >>> + if (desc.getName().equals("prop1")) { > > >>> + assertNotNull("invalid get method", > > desc.getReadMethod()); > > >>> + assertEquals("get method has invalid return > type", > > >>> + Integer.class, > > desc.getReadMethod().getReturnType()); > > >>> + assertNotNull("invalid set method", > > desc.getWriteMethod()); > > >>> + assertEquals("invalid set method", > > >>> + "setProp1", > > desc.getWriteMethod().getName()); > > >>> + assertNotNull("set method don't have any > > parameters", > > >>> + > > desc.getWriteMethod().getParameterTypes()); > > >>> + assertEquals("set method has invalid > parameters", > > >>> + Integer.class, > > >>> + > > desc.getWriteMethod().getParameterTypes()[0]); > > >>> + } > > >>> + } > > >>> + } > > >>> + > > >>> + for (Class clz : new Class[] {TstBean5675_3.class, > > TstBean5675_5.class, > > >>> + TstBean5675_6.class}) { > > >>> + > > >>> + bInfo =3D Introspector.getBeanInfo(clz); > > >>> + > > >>> + for (PropertyDescriptor desc: > > bInfo.getPropertyDescriptors()) { > > >>> + > > >>> + if (desc.getName().equals("prop1")) { > > >>> + assertNull("Non-null get method", > > desc.getReadMethod()); > > >>> + assertNull("Non-null set method", > > desc.getWriteMethod()); > > >>> + } > > >>> + } > > >>> + } > > >>> + > > >>> + bInfo =3D Introspector.getBeanInfo(TstBean5675_4.class); > > >>> + for (PropertyDescriptor desc: > bInfo.getPropertyDescriptors()) > > { > > >>> + > > >>> + if (desc.getName().equals("prop1")) { > > >>> + assertNotNull("invalid get method", > > desc.getReadMethod()); > > >>> + assertEquals("get method has invalid return type", > > >>> + Integer.class, > > desc.getReadMethod().getReturnType()); > > >>> + assertNull("Non-null set method", > > desc.getWriteMethod()); > > >>> + } > > >>> + } > > >>> + > > >>> + bInfo =3D Introspector.getBeanInfo(TstBean5675_7.class); > > >>> + for (PropertyDescriptor desc: > bInfo.getPropertyDescriptors()) > > { > > >>> + > > >>> + if (desc.getName().equals("prop1")) { > > >>> + assertNull("Non-null get method", > > desc.getReadMethod()); > > >>> + assertEquals("invalid set method", > > >>> + "setProp1", > desc.getWriteMethod().getName()); > > >>> + assertNotNull("set method don't have any > parameters", > > >>> + desc.getWriteMethod().getParameterTypes())= ; > > >>> + assertEquals("set method has invalid parameters", > > >>> + Integer.class, > > >>> + > desc.getWriteMethod().getParameterTypes()[0]); > > >>> + } > > >>> + } > > >>> + > > >>> + bInfo =3D Introspector.getBeanInfo(TstBean5675_8.class); > > >>> + for (PropertyDescriptor desc: > bInfo.getPropertyDescriptors()) > > { > > >>> + > > >>> + if (desc.getName().equals("prop1")) { > > >>> + assertNotNull("invalid get method", > > desc.getReadMethod()); > > >>> + assertEquals("get method has invalid return type", > > >>> + Integer[].class, > > desc.getReadMethod().getReturnType()); > > >>> + assertNull("Non-null set method", > > desc.getWriteMethod()); > > >>> + } > > >>> + } > > >>> + > > >>> + bInfo =3D Introspector.getBeanInfo(TstBean5675_9.class); > > >>> + for (PropertyDescriptor desc: > bInfo.getPropertyDescriptors()) > > { > > >>> + > > >>> + if (desc.getName().equals("prop1")) { > > >>> + assertNull("Non-null get method", > > desc.getReadMethod()); > > >>> + assertNotNull("invalid set method", > > desc.getWriteMethod()); > > >>> + assertEquals("invalid set method", > > >>> + "setProp1", > desc.getWriteMethod().getName()); > > >>> + assertNotNull("set method don't have any > parameters", > > >>> + desc.getWriteMethod().getParameterTypes())= ; > > >>> + assertEquals("set method has invalid parameters", > > >>> + Integer[].class, > > >>> + > desc.getWriteMethod().getParameterTypes()[0]); > > >>> + } > > >>> + } > > >>> + > > >>> + bInfo =3D Introspector.getBeanInfo(TstBean5675_10.class); > > >>> + for (PropertyDescriptor desc: > bInfo.getPropertyDescriptors()) > > { > > >>> + > > >>> + if (desc.getName().equals("prop1")) { > > >>> + assertNotNull("invalid get method", > > desc.getReadMethod()); > > >>> + assertEquals("get method has invalid return type", > > >>> + Integer[].class, > > desc.getReadMethod().getReturnType()); > > >>> + assertNotNull("invalid set method", > > desc.getWriteMethod()); > > >>> + assertEquals("invalid set method", > > >>> + "setProp1", > desc.getWriteMethod().getName()); > > >>> + assertNotNull("set method don't have any > parameters", > > >>> + desc.getWriteMethod().getParameterTypes())= ; > > >>> + assertEquals("set method has invalid parameters", > > >>> + Integer[].class, > > >>> + > desc.getWriteMethod().getParameterTypes()[0]); > > >>> + } > > >>> + } > > >>> + > > >>> + } > > >>> + > > >>> + class TstBean5675 { > > >>> + > > >>> + public void setProp1(String uri) {} > > >>> + > > >>> + public void setProp1(Integer i) {} > > >>> + > > >>> + > > >>> + public Integer getProp1() { > > >>> + return null; > > >>> + } > > >>> + > > >>> + } > > >>> + > > >>> + > > >>> + class TstBean5675_2 { > > >>> + > > >>> + public Integer getProp1() { > > >>> + return null; > > >>> + } > > >>> + > > >>> + public String getProp1(int n) { > > >>> + return null; > > >>> + } > > >>> + > > >>> + public void setProp1(Integer val) {} > > >>> + > > >>> + > > >>> + } > > >>> + > > >>> + class TstBean5675_3 { > > >>> + > > >>> + public String getProp1(int n) { > > >>> + return null; > > >>> + } > > >>> + > > >>> + public void setProp1(int n, String uri) {} > > >>> + > > >>> + public void setProp1(Integer i) {} > > >>> + > > >>> + public Integer getProp1() { > > >>> + return null; > > >>> + } > > >>> + > > >>> + } > > >>> + > > >>> + class TstBean5675_4 { > > >>> + > > >>> + public void setProp1(String val) {} > > >>> + > > >>> + public Integer getProp1() { > > >>> + return null; > > >>> + } > > >>> + > > >>> + } > > >>> + > > >>> + class TstBean5675_5 { > > >>> + > > >>> + public Integer getProp1() { > > >>> + return null; > > >>> + } > > >>> + > > >>> +// public void setProp1(Integer val) {} > > >>> + > > >>> + public String getProp1(int n) { > > >>> + return null; > > >>> + } > > >>> + > > >>> + public void setProp1(int n, String uri) {} > > >>> + > > >>> + > > >>> + } > > >>> + > > >>> + class TstBean5675_6 { > > >>> + > > >>> + public Integer getProp1() { > > >>> + return null; > > >>> + } > > >>> + > > >>> +// public void setProp1(Integer val) {} > > >>> +// > > >>> +// public String getProp1(int n) { > > >>> +// return null; > > >>> +// } > > >>> + > > >>> + public void setProp1(int n, String uri) {} > > >>> + > > >>> + > > >>> + } > > >>> + > > >>> + class TstBean5675_7 { > > >>> + public void setProp1(String val) {} > > >>> + public void setProp1(Integer val) {} > > >>> + } > > >>> + > > >>> + class TstBean5675_8 { > > >>> + public Integer[] getProp1() { > > >>> + return null; > > >>> + } > > >>> + > > >>> + //public void setProp1(Integer[] val) {} > > >>> + > > >>> + public Integer getProp1(int n) { > > >>> + return null; > > >>> + } > > >>> + > > >>> + public void setProp1(int n, Integer val) {} > > >>> + } > > >>> + > > >>> + class TstBean5675_9 { > > >>> + public void setProp1(Integer[] val) {} > > >>> + > > >>> + public Integer getProp1(int n) { > > >>> + return null; > > >>> + } > > >>> + > > >>> + } > > >>> + > > >>> + class TstBean5675_10 { > > >>> + public Integer[] getProp1() { > > >>> + return null; > > >>> + } > > >>> + > > >>> + public void setProp1(Integer[] val) {} > > >>> + > > >>> + public Integer getProp1(int n) { > > >>> + return null; > > >>> + } > > >>> + > > >>> + public void setProp1(int n, Integer val) {} > > >>> + } > > >>> + > > >>> } > > >>> > > >>> > > >>> > > >> > > > > > > ------=_Part_91584_25821842.1228834328582--