FreeMarker Blog

The official weblog of the FreeMarker project

Wednesday, December 05, 2007

FreeMarker 2.3.11 released

We're pleased to announce that FreeMarker 2.3.11 is now released. This release contains several important bugfixes, performance improvements (both speed and memory), as well as some major feature improvements. It is almost completely backwards compatible with any other 2.3.x version and as such can be used as a drop-in replacement for them. (The only non-backwards compatible change is that ?c built-in formats numbers differently than it did earlier, but that is actually a bug fix).

Download it from SourceForge

You can look at the full list of changes, but I'll summarize it here by topic:

New features

  • We now have much better JSP 2.0 and JSP 2.1 compliance. Most notably, JSP tags implementing SimpleTag interface will now work.

  • We have better Rhino compliance as well: Rhino objects can be used in templates as scalars, numbers, and booleans, following the JavaScript conversion semantics for these types.

  • We created a new interface, TemplateDirectiveModel that should make writing custom directives in Java much easier than with the previous only choice, TemplateTransformModel.
And then there's the small things, i.e. FileTemplateLoader can now load templates through symlinks pointing out of its root directory (it is disabled by default however).

Performance improvements

We eliminated a bunch of repeated instanceof tests in BeansWrapper whenever a new object was wrapped. They're now performed once per class instead of once per object. Also, the FreeMarker wrapper object created by BeansWrapper when wrapping a POJO now does not create an internal HashMap automatically, but only when really needed (and it is not needed often). Thus, we eliminated one HashMap per wrapped object in lots of use cases, noticeably reducing the runtime memory footprint.

Bug fixes

As mentioned, ?c built-in now prints numbers in the expected format always. Also, there is a serious file handle leak when loading resources from JAR files from local filesystem in Sun JVMs, and we now have a workaround for it. FreeMarker will now correctly find JRE-bundled Xalan when run on Java 5 and Java 6. Also, we corrected the lookup of JSP taglib JAR files to be fully compliant with the JSP specification. And there are some more I won't go into right now - see the full changelog page linked above.


At Wed Dec 05, 11:13:00 PM GMT+1, Blogger AJ said...

Does 2.3.11 contain the fix for the file handle leak or is there a manual workaround?

At Thu Dec 06, 09:37:00 AM GMT+1, Blogger Attila Szegedi said...

The important thing is that with 2.3.11, there will be no file handle leak.

Now, for the hair splitting:
2.3.11 contains a workaround. The bug is in the Sun JRE, therefore we can not fix it, we can just modify our code so that it does not trigger the JRE file handle leak bug ("work around it"). That's why this is really a workaround for a JRE bug.

But you needn't do anything manually, it's in FreeMarker code that's responsible for loading templates from JAR files on the local filesystem (which is what triggers the JRE bug -- handling local JAR files through URL stream handlers)

At Thu Dec 06, 11:44:00 PM GMT+1, Anonymous Anonymous said...

2.3.11 still contains a pretty annoying bug. Freemarker's error reporting abilities are legendary but it still doesn't print out the name of the template that generated the error. Errors like:

freemarker.core.ParseException: Encountered "." at line 16, column 63.

are frustrating as it takes 30 seconds just to figure out which file was being processed. This is a problem for those of us using freemarker to generate large static websites and not doing the usual servlet dynamic site.

At Fri Dec 07, 09:50:00 AM GMT+1, Blogger Attila Szegedi said...

That's not a bug, what you're asking is a feature enhancement :-)

Anyways, for your benefit, here's 2.3.11 + template names in parse exceptions:

At Tue Jan 01, 09:59:00 PM GMT+1, Anonymous Anonymous said...

I'm curious to know more about your licensing policy. I read through the BSD license, and can't figure out IF I can embed the FreeMarker engine in my code (JAR file), or if I have to export my data to a file, and run FreeMarker application separately.

Any help is appreciated. I'm building a corporate "for-profit" engine, that uses FreeMarker to generate output according to a FMP template.

I want to know exactly what to put in the license agreements so that I'm not in violation of using this software.

Dan Linstedt

At Fri Jan 04, 10:56:00 AM GMT+1, Blogger Attila Szegedi said...

The license allows you to embed FreeMarker in your application.

At Fri Feb 01, 05:44:00 AM GMT+1, Blogger Ted said...

Amazing piece of code and excellent documentation!

It took us half a day to realize that this is the template engine we need.

Great work!


Post a Comment

Links to this post:

Create a Link

<< Home