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

Wrong method finding in getMethod() of InterfaceExtensionImpl

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: Version 2
    • Fix Version/s: None
    • Component/s: Binding
    • Labels:
      None
    • Environment:
      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

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

              Dates

              • Created:
                Updated:
                Resolved: