You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@xmlbeans.apache.org by "Denis Anisimov (JIRA)" <xm...@xml.apache.org> on 2005/09/26 15:07:50 UTC

[jira] Created: (XMLBEANS-206) Wrong method finding in getMethod() of InterfaceExtensionImpl

Wrong method finding in getMethod() of InterfaceExtensionImpl
-------------------------------------------------------------

         Key: XMLBEANS-206
         URL: http://issues.apache.org/jira/browse/XMLBEANS-206
     Project: XMLBeans
        Type: Bug
    Versions: Version 2    
 Environment: Doesn't relate to platform.
    Reporter: Denis Anisimov


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


[jira] Commented: (XMLBEANS-206) Wrong method finding in getMethod() of InterfaceExtensionImpl

Posted by "Lawrence Jones (JIRA)" <xm...@xml.apache.org>.
    [ http://issues.apache.org/jira/browse/XMLBEANS-206?page=comments#action_12332653 ] 

Lawrence Jones commented on XMLBEANS-206:
-----------------------------------------

Am attaching the stack trace you see for this error (with an interface with 2 same-named methods - one takes String, other takes String & int)

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 2
        at org.apache.xmlbeans.impl.config.InterfaceExtensionImpl.getMethod(InterfaceExtensionImpl.java:194)
        at org.apache.xmlbeans.impl.config.InterfaceExtensionImpl.validateMethod(InterfaceExtensionImpl.java:138)
        at org.apache.xmlbeans.impl.config.InterfaceExtensionImpl.validateMethods(InterfaceExtensionImpl.java:113)
        at org.apache.xmlbeans.impl.config.InterfaceExtensionImpl.newInstance(InterfaceExtensionImpl.java:58)
        at org.apache.xmlbeans.impl.config.BindingConfigImpl.recordExtensionSetting(BindingConfigImpl.java:236)
        at org.apache.xmlbeans.impl.config.BindingConfigImpl.<init>(BindingConfigImpl.java:107)
        at org.apache.xmlbeans.impl.config.BindingConfigImpl.forConfigDocuments(BindingConfigImpl.java:69)
        at org.apache.xmlbeans.impl.tool.SchemaCompiler.loadTypeSystem(SchemaCompiler.java:944)
        at org.apache.xmlbeans.impl.tool.SchemaCompiler.compile(SchemaCompiler.java:1072)
        at org.apache.xmlbeans.impl.tool.SchemaCompiler.main(SchemaCompiler.java:368)

> 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

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


[jira] Closed: (XMLBEANS-206) Wrong method finding in getMethod() of InterfaceExtensionImpl

Posted by "Rajiv Bala (JIRA)" <xm...@xml.apache.org>.
     [ 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


[jira] Updated: (XMLBEANS-206) Wrong method finding in getMethod() of InterfaceExtensionImpl

Posted by "Denis Anisimov (JIRA)" <xm...@xml.apache.org>.
     [ http://issues.apache.org/jira/browse/XMLBEANS-206?page=all ]

Denis Anisimov updated XMLBEANS-206:
------------------------------------

    Component: Binding

> 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

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


[jira] Assigned: (XMLBEANS-206) Wrong method finding in getMethod() of InterfaceExtensionImpl

Posted by "Lawrence Jones (JIRA)" <xm...@xml.apache.org>.
     [ http://issues.apache.org/jira/browse/XMLBEANS-206?page=all ]

Lawrence Jones reassigned XMLBEANS-206:
---------------------------------------

    Assign To: Rajiv Bala

Fixed with checkin 327209. Thanks for the fix Dennis. Assigning to Rajiv for test.

> 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