Uploaded image for project: 'Commons JXPath'
  1. Commons JXPath
  2. JXPATH-129

MethodLookupUtils#matchType uses TypeUtils#canConvert which causes "Ambiguous method call" exception.

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Cannot Reproduce
    • None
    • 1.4
    • None
    • Not relevant.

    Description

      MethodLookupUtils#matchParameterTypes calls MethodUtils#matchType.

      MethodLookupUtils#matchType includes this:

      if (TypeUtils.canConvert(object, expected))

      { return APPROXIMATE_MATCH; }

      This goes through a whole process of attempting to convert types using JXPath-specific conversion routines. However, this is not valid logic when attempting to find matching Methods since overloaded functions with "convertable" parameters would still have different function signatures.

      An example:

      abstract class ExampleClass
      {
      static final String formatISO(Calendar calendar)

      { return ""};
      static final String formatISO(Date date) { return ""}

      ;
      }

      If referenced from JXPath with "ExampleClass.formatISO(pathToDateObject)", these two functions would trigger JXPathException("lookupMethod() Ambiguous method call: " + name) because apparently TypeUtils is able to convert a Calendar to a Date and vice-versa.

      When attempting to retrieve a function via signature, is it not irrelevant whether JXPath is able to convert a parameter's type or not? Is there a way to change this behavior or provide a way to toggle this behavior similar to the setLenient() method.

      Also, the word "Ambiguous" is spelled incorrectly as "Ambigous" three times in MethodLookupUtils.

      Attachments

        1. MethodLookupTest.java
          2 kB
          Matthew Jason Benson

        Activity

          People

            Unassigned Unassigned
            robross0606 Robert Ross
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: