Uploaded image for project: 'XMLBeans'
  1. XMLBeans
  2. XMLBEANS-206

Wrong method finding in getMethod() of InterfaceExtensionImpl

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • Version 2
    • None
    • Binding
    • None
    • Doesn't relate to platform.

    Description

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

      Attachments

        Activity

          People

            rbalacha Rajiv Bala
            ads Denis Anisimov
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: