You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Will Glass-Husain (JIRA)" <ji...@apache.org> on 2006/10/09 22:55:20 UTC

[jira] Resolved: (VELOCITY-132) IllegalArgumentException while calling an overloaded method

     [ http://issues.apache.org/jira/browse/VELOCITY-132?page=all ]

Will Glass-Husain resolved VELOCITY-132.
----------------------------------------

    Resolution: Invalid

Hi, thanks for reporting this and commenting. 

 I'm marketing this issue as invalid.  There's two different issues here-- one has been previously fixed and one is "as desired".  

The first issue concerns the IllegalArgumentException when the provided example is included with #parse.   I was unable to reproduce this.  I've added unit tests to verify this is working properly.    I believe it was fixed between 1.4 and 1.5.  Mike comments above that in the nightly source his example returns:

$testobj.foo( $param )
String 

this is the correct response.  Calling $testobj.foo(null) could return either of two possible method calls.  Since it's impossible to tell which to call, Velocity returns neither.  (there's an error message in the log noting the ambiguity).

The second issue is when Llewellyn argues above that this is incorrect behavior, that if a method call is ambiguous, Velocity should pick one.  I disagree.  It's hard to know which one to pick.  There's a clear message in the log listing the method call and stating it's ambiguous.  Thus it's the developer's responsibility to provide a context object with methods that are not ambiguous.

Resolved - marking as invalid, but adding unit tests to confirm.  Thanks again.

> IllegalArgumentException while calling an overloaded method
> -----------------------------------------------------------
>
>                 Key: VELOCITY-132
>                 URL: http://issues.apache.org/jira/browse/VELOCITY-132
>             Project: Velocity
>          Issue Type: Bug
>          Components: Source
>    Affects Versions: 1.3-rc1
>         Environment: Operating System: All
> Platform: All
>            Reporter: MySign
>             Fix For: 1.5
>
>         Attachments: includecall.vm, velocity_patch.patch, velocitybug.vm, VelocityCachingBug.java
>
>
> If there are two methods with the same name and different parameters like:
> public class myClass
> {
>     public String foo ( Integer intObj );
>     public String foo ( String str );
> }
> and a velocity template like this
> $myObj.foo( $someObj.getNull() )
> $myObj.foo( $str )
> while $someObj.getNull() returns null and $str is a java.lang.String object
> with a String like 'test'. Because velocity caches the first method with the 
> Integer argument on calling with the parameter null (which isn't of course of 
> any type/class) the call fails with the String argument, because velocity tries
> to call the foo( Integer intObj )!
> In the velocity log appears a IllegalArgumentException which is right, but 
> velocity should call the right method!
> mike

-- 
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: velocity-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-dev-help@jakarta.apache.org