Re: Varargs

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Friday, August 5, 2011, 1:24:13 AM, Brian Pontarelli wrote:

> Unfortunately not for this. It is used in our Clean Speak product
> that goes out to numerous customers. I'd be willing to test it on
> other projects. We have replaced everything with FM at this point.
>
> It is interesting that you don't use it any longer.

There's nothing strange in that actually. I'm afraid many starts to
believe that FM is my child, but it's not so. I'm a glorified
contributor whose main contribution was writing the FreeMarker Manual.
But I see the authors around less and less (and BTW they were also
ended up doing this without any business interest behind). Luckily for
FreeMarker I keep doing some maintenance work... but I haven't even
used Java in the recent years much, let alone FreeMarker. It's rather
just that I have some emotional attachment and I don't want to see it
to become totally abandoned.

> Perhaps I should start getting into the code more to help out.

Contributors (of sufficient quality) are highly welcome! The most
important would be contributors with some persistence. People who
don't just jump in for a patch then jump out. Also, in general it
would be good if companies who depend on FM invest into it.

> I know there are a lot of companies switching to FM from JSPs and
> other technologies, so I would expect that having a committer that
> has select FM for everything and uses it all day every day would be
> helpful.

Yeah, it's very important to use your own product. (It's not my
product as I said, but you see the point.) Whenever I used FreeMarker,
even if for a week, I ended up adding some new features, or fix some
annoyances that otherwise I would probably never hear about.

-- 
Best regards,
 Daniel Dekany


> -bp
>
>
> On Aug 4, 2011, at 4:43 PM, Daniel Dekany wrote:
>
>> Is using unreleased version is a problem for you? Because I'm not sure
>> if when Attila will be available if he will be at all, so I can go
>> ahead and fix this, then you can start using it, see if it breaks
>> something. The more people field-tests something the better. (I don't
>> even use FM nowadays...)
>> 
>> 
>> Thursday, August 4, 2011, 6:25:29 PM, Brian Pontarelli wrote:
>> 
>>> Thanks for the reply. I'll let you guys take it from here ;)
>>> 
>>> -bp
>>> 
>>> On Aug 4, 2011, at 3:46 AM, Daniel Dekany wrote:
>>> 
>>>> OK, I have looked into this, and it seems that this feature (varargs)
>>>> has never worked in 2.3. FM 2.3.12 has just made things worse, as not
>>>> even explicitly passing an array (like hasRoles(['foo', 'bar'])) works
>>>> starting from there, while before 2.3.12 it certainly did. How nobody
>>>> ran into this and reported for 4.5 years is beyond be. Also, varags
>>>> has no test coverage in 2.3/2.4...
>>>> 
>>>> And now I will mostly talk to Attila (the author of BeansWrapper). The
>>>> problem is this: BeansWrapper.populateClassMapWithBeanInfo(Class) in
>>>> FM 3.0 calls componentizeLastArg(publicMethod.getParameterTypes(),
>>>> publicMethod.isVarArgs())) to calculate SimpleMemberModel.argTypes,
>>>> while 2.3/2.4 just calls publicMethod.getParameterTypes(). The
>>>> componentizeLastArg method changes the vararg's type from array<T> to
>>>> T. Thus in 2.3/2.4 the type of the vararg argument, according to
>>>> SimpleMemberModel.argTypes[theIndexOfTheVarArg], will be array<T>,
>>>> while in 3.0 it will be T. But all the other parts of the algorithm is
>>>> the same as in 3.0, so the method call will fail both with
>>>> hasRoles(["foo", "bar"]) and hasRoles("foo", "bar").
>>>> 
>>>> Would adding componentizeLastArg to 2.3/2.4 and calling it at the same
>>>> two places as in 3.0 be a sufficient fix? Would it be backward
>>>> compatible? I guess it would be, but you are still the one who knows
>>>> this stuff inside out...
>>>> 
>>>> -- 
>>>> Best regards,
>>>> Daniel Dekany
>>>> 
>>>> 
>>>> Wednesday, August 3, 2011, 6:19:59 PM, Brian Pontarelli wrote:
>>>> 
>>>>> On Aug 3, 2011, at 2:07 AM, Daniel Dekany wrote:
>>>>> 
>>>>>> Tuesday, August 2, 2011, 9:20:43 PM, Brian Pontarelli wrote:
>>>>>> 
>>>>>>> I've read that vararg method calls were added to 2.4.12 but I can't
>>>>>>> find any good docs on how to use them and if there are any special
>>>>>>> requirements. I have a varargs method that I'm trying to invoke from
>>>>>>> a template and I'm getting an argument type mismatch exception:
>>>>>>> 
>>>>>>> public boolean hasRoles(String... roles) {
>>>>>>>  ...
>>>>>>> }
>>>>>>> 
>>>>>>> 
>>>>>>> [#if user.hasRoles(["foo", "bar"])]
>>>>>>>  …
>>>>>>> [/#if]
>>>>>>> 
>>>>>>> Anyone know how to fix this?
>>>>>> 
>>>>>> AFAR it's supposed to Just Work (assuming you are using some
>>>>>> BeansWrapper subclass as the object_wrapper setting, and it's 99% that
>>>>>> you do). Have you tried user.hasRoles("foo", "bar"), without the []?
>>>>> 
>>>>> Yeah, tried that. It then complains about trying to convert String
>>>>> to String[]. I do have a BeansWrapper sub-class, but all it does is set these two options:
>>>>> 
>>>>>       setExposeFields(true);
>>>>>       setSimpleMapWrapper(true);
>>>>> 
>>>>> Not sure how to fix it, but I changed the method to take an
>>>>> Iterable<String> and it is working.
>>>>> 
>>>>> -bp
>>>>> 
>>>>> 
>>>>> ------------------------------------------------------------------------------
>>>>> BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
>>>>> The must-attend event for mobile developers. Connect with experts. 
>>>>> Get tools for creating Super Apps. See the latest technologies.
>>>>> Sessions, hands-on labs, demos & much more. Register early & save!
>>>>> http://p.sf.net/sfu/rim-blackberry-1
>>>>> _______________________________________________
>>>>> FreeMarker-user mailing list
>>>>> [email protected]
>>>>> https://lists.sourceforge.net/lists/listinfo/freemarker-user
>>>>> 
>>>> 
>>> 
>>> 
>> 
>> -- 
>> Best regards,
>> Daniel Dekany
>> 
>
>


------------------------------------------------------------------------------
BlackBerry&reg; DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts. 
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.