You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Nathan Bubna (JIRA)" <de...@velocity.apache.org> on 2007/08/31 21:31:18 UTC

[jira] Commented: (VELOCITY-534) Support varargs in method calls

    [ https://issues.apache.org/jira/browse/VELOCITY-534?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12524168 ] 

Nathan Bubna commented on VELOCITY-534:
---------------------------------------

The problem is that varargs are a compile-time trick pulled off by the jdk.  So, at runtime, a vararg (e.g. String... foo) is seen as an array of that type (e.g. String[] foo).

This means we can call vararg methods by passing an array, but it would be nice to pull off some uberspect magic to allow vararg methods to be called with a variable number of arguments, rather than a varying sized array.  Much simpler that way, especially as Velocity's so-called "array" syntax actually creates an ArrayList, making the workaround for this that much trickier.

At first glance, this may be doable via some tweaks to MethodMap's isApplicable() and moreSpecific() methods.

> Support varargs in method calls
> -------------------------------
>
>                 Key: VELOCITY-534
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-534
>             Project: Velocity
>          Issue Type: Improvement
>    Affects Versions: 1.5
>            Reporter: Nathan Bubna
>             Fix For: 1.6, 2.0
>
>
> If possible and as much as possible without breaking JDK 1.3/JDK 1.4 runtime support, i would like to see us support varargs for method calls.  So,
> public class MyTool {
>     public List combine(List... lists) {
>         ...
>     }
> }
> #set( $twoLists = $myTool.combine($list1, $list2) )
> #set( $threeLists = $myTool.combine($list1, $list2, $list3) )
> will work out of the box, without need for the user to rebuild Velocity themselves.

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


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org