[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xmlbeans-dev
Subject:    [jira] Closed: (XMLBEANS-206) Wrong method finding in getMethod() of InterfaceExtensionImpl
From:       "Rajiv Bala (JIRA)" <xmlbeans-dev () xml ! apache ! org>
Date:       2005-10-27 18:51:04
Message-ID: 1717444428.1130439064068.JavaMail.jira () ajax ! apache ! org
[Download RAW message or body]

     [ http://issues.apache.org/jira/browse/XMLBEANS-206?page=all ]
     
Rajiv Bala closed XMLBEANS-206:
-------------------------------

    Resolution: Fixed

Added test to verify fix (rev 328804)

> Wrong method finding in getMethod() of InterfaceExtensionImpl
> -------------------------------------------------------------
> 
> Key: XMLBEANS-206
> URL: http://issues.apache.org/jira/browse/XMLBEANS-206
> Project: XMLBeans
> Type: Bug
> Components: Binding
> Versions: Version 2
> Environment: Doesn't relate to platform.
> Reporter: Denis Anisimov
> Assignee: Rajiv Bala

> 
> Wrong implementation of getMethod() in InterfaceExtensionImpl class could lead to  \
> ArrayIndexOutOfBoundsException. Old implementation :
> static JMethod getMethod(JClass cls, String name, JClass[] paramTypes)
> {
> JMethod[] methods = cls.getMethods();
> for (int i = 0; i < methods.length; i++)
> {
> JMethod method = methods[i];
> if (!name.equals(method.getSimpleName()))
> continue;
> JParameter[] mParams = method.getParameters();           
> for (int j = 0; j < mParams.length; j++)
> {
> JParameter mParam = mParams[j];
> if (!mParam.getType().equals(paramTypes[j]))
> continue;
> }
> return method;
> }
> return null;
> }
> Correct impl-tion :
> static JMethod getMethod(JClass cls, String name, JClass[] paramTypes)
> {
> JMethod[] methods = cls.getMethods();
> for (int i = 0; i < methods.length; i++)
> {
> JMethod method = methods[i];
> if (!name.equals(method.getSimpleName()))
> continue;
> JParameter[] mParams = method.getParameters();
> // here was bug in possibe ArrayIndexOutOfBoundsException.
> // because methods could have same names but different
> // number of parameters
> if ( mParams.length != paramTypes.length ){
> 	continue;
> }
> 
> for (int j = 0; j < mParams.length; j++)
> {
> JParameter mParam = mParams[j];
> if (!mParam.getType().equals(paramTypes[j]))
> continue;
> }
> return method;
> }
> return null;
> }

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: dev-help@xmlbeans.apache.org


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic