Re: instanceOf and/or isAssignableFrom operator in freemarker

Daniel Dekany <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
Thursday, May 19, 2011, 10:33:44 AM, Timmo Freudl-Gierke wrote:

> <#if youVariable.class.simpleName == "YouType">

So you are replying to a thread from April, 2009. Too bad that thread
has died, because I felt it's an important issue. What it boiled down
to back then is that the root of the problem is that you can just get
classes by name in a template. There could be special variables for
this: .classes[className], .enums[className], .statics[className]. Of
course this has security implications, like ?new has, and we should
create a few new settings of type TemplateClassLoader (like I did it
for ?new in 2.3.17).

Anyway, the solution you show is surely not good. You should at least
check the full-qualified name, and then it will still fail when
there's inheritance involved.

-- 
Best regards,
 Daniel Dekany


------------------------------------------------------------------------------
What Every C/C++ and Fortran developer Should Know!
Read this article and learn how Intel has extended the reach of its 
next-generation tools to help Windows* and Linux* C/C++ and Fortran 
developers boost performance applications - including clusters. 
http://p.sf.net/sfu/intel-dev2devmay
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.