commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Robert Ross (JIRA)" <>
Subject [jira] Commented: (JXPATH-129) MethodLookupUtils#matchType uses TypeUtils#canConvert which causes "Ambiguous method call" exception.
Date Mon, 01 Mar 2010 20:28:05 GMT


Robert Ross commented on JXPATH-129:

Yes, you are forgetting the standard method of invoking static methods:

I was using function call JXpath syntax like this:


Where date is a Calendar instance or date is a Date instance.

This isn't just observational either.  I traced this by stepping all the way into the code
until I could see where the Calendar was converted to a Date and then the error was thrown.
 This is also the same class file where the spelling errors were noticed.  This bug was logged
about a year ago so perhaps it has been fixed already?  I'm not in a position to test it at
this point.

Robert A. Ross
Senior Software Developer
609.509.5139 - Mobile
609.702.8114 - Home

> MethodLookupUtils#matchType uses TypeUtils#canConvert which causes "Ambiguous method
call" exception.
> -----------------------------------------------------------------------------------------------------
>                 Key: JXPATH-129
>                 URL:
>             Project: Commons JXPath
>          Issue Type: Bug
>         Environment: Not relevant.
>            Reporter: Robert Ross
>             Fix For: 1.4
>         Attachments:
> 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
> 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.

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message