blob: 2099d9e48a85155a01e6f2a13ceff59f7e14f70c [file] [log] [blame]
<!doctype html>
<!-- Generated by FreeMarker/Docgen from DocBook -->
<html lang="en" class="page-type-section">
<head prefix="og: http://ogp.me/ns#">
<meta charset="utf-8">
<title>The &quot;incompatible improvements&quot; setting - Apache FreeMarker Manual</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="format-detection" content="telephone=no">
<meta property="og:site_name" content="Apache FreeMarker Manual">
<meta property="og:title" content="The &quot;incompatible improvements&quot; setting">
<meta property="og:locale" content="en_US">
<meta property="og:url" content="https://freemarker.apache.org/docs/pgui_config_incompatible_improvements.html">
<link rel="canonical" href="https://freemarker.apache.org/docs/pgui_config_incompatible_improvements.html">
<link rel="icon" href="favicon.png" type="image/png">
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto:500,700,400,300|Droid+Sans+Mono">
<link rel="stylesheet" type="text/css" href="docgen-resources/docgen.min.css?1707770044859">
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/cookie-bar/cookiebar-latest.min.js"></script>
</head>
<body itemscope itemtype="https://schema.org/Code">
<meta itemprop="url" content="https://freemarker.apache.org/docs/">
<meta itemprop="name" content="Apache FreeMarker Manual">
<!--[if lte IE 9]>
<div class="oldBrowserWarning" style="display: block">
Unsupported web browser - Use a modern browser to view this website!
</div>
<![endif]--> <div class="oldBrowserWarning">
Unsupported web browser - Use a modern browser to view this website!
</div>
<div class="header-top-bg"><div class="site-width header-top"><div id="hamburger-menu" role="button"></div> <div class="logo">
<a href="https://freemarker.apache.org" role="banner"><img itemprop="image" src="logo.png" alt="FreeMarker"></a> </div>
<ul class="tabs"><li><a href="https://freemarker.apache.org/">Home</a></li><li class="current"><a href="index.html">Manual</a></li><li><a class="external" href="api/index.html">Java API</a></li></ul><ul class="secondary-tabs"><li><a class="tab icon-heart" href="https://freemarker.apache.org/contribute.html" title="Contribute"><span>Contribute</span></a></li><li><a class="tab icon-bug" href="https://issues.apache.org/jira/projects/FREEMARKER" title="Report a Bug"><span>Report a Bug</span></a></li><li><a class="tab icon-download" href="https://freemarker.apache.org/freemarkerdownload.html" title="Download"><span>Download</span></a></li></ul></div></div><div class="header-bottom-bg"><div class="site-width search-row"><a href="index.html" class="navigation-header">Manual</a><div class="navigation-header"></div><form method="get" class="search-form" action="search-results.html"><fieldset><legend class="sr-only">Search form</legend><label for="search-field" class="sr-only">Search query</label><input id="search-field" name="q" type="search" class="search-input" placeholder="Search" spellcheck="false" autocorrect="off" autocomplete="off"><button type="submit" class="search-btn"><span class="sr-only">Search</span></button></fieldset></form></div><div class="site-width breadcrumb-row"> <div class="breadcrumbs">
<ul class="breadcrumb" itemscope itemtype="http://schema.org/BreadcrumbList"><li class="step-0" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="index.html"><span itemprop="name">Apache FreeMarker Manual</span></a></li><li class="step-1" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="pgui.html"><span itemprop="name">Programmer&#39;s Guide</span></a></li><li class="step-2" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="pgui_config.html"><span itemprop="name">The Configuration</span></a></li><li class="step-3" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem"><a class="label" itemprop="item" href="pgui_config_incompatible_improvements.html"><span itemprop="name">The &quot;incompatible improvements&quot; setting</span></a></li></ul> </div>
<div class="bookmarks" title="Bookmarks"><span class="sr-only">Bookmarks:</span><ul><li><a href="alphaidx.html">Alpha. index</a></li><li><a href="gloss.html">Glossary</a></li><li><a href="dgui_template_exp.html#exp_cheatsheet">Expressions</a></li><li><a href="ref_builtins_alphaidx.html">?builtins</a></li><li><a href="ref_directive_alphaidx.html">#directives</a></li><li><a href="ref_specvar.html">.spec_vars</a></li><li><a href="app_faq.html">FAQ</a></li></ul></div></div></div> <div class="main-content site-width">
<div class="content-wrapper">
<div id="table-of-contents-wrapper" class="col-left">
<script>var breadcrumb = ["Apache FreeMarker Manual","Programmer\'s Guide","The Configuration","The \"incompatible improvements\" setting"];</script>
<script src="toc.js?1707770044859"></script>
<script src="docgen-resources/main.min.js?1707770044859"></script>
</div>
<div class="col-right"><div class="page-content"><div class="page-title"><div class="pagers top"><a class="paging-arrow previous" href="pgui_config_custom_formats.html"><span>Previous</span></a><a class="paging-arrow next" href="pgui_misc.html"><span>Next</span></a></div><div class="title-wrapper">
<h1 class="content-header header-section1" id="pgui_config_incompatible_improvements" itemprop="headline">The &quot;incompatible improvements&quot; setting</h1>
</div></div><div class="page-menu">
<div class="page-menu-title">Page Contents</div>
<ul><li><a class="page-menu-link" href="#autoid_51" data-menu-target="autoid_51">What does it do</a></li><li><a class="page-menu-link" href="#pgui_config_incompatible_improvements_how_to_set" data-menu-target="pgui_config_incompatible_improvements_how_to_set">How to set it</a></li></ul> </div>
<h2 class="content-header header-section2" id="autoid_51">What does it do</h2>
<p>This setting specifies the FreeMarker version number where the
not 100% backward compatible bug fixes and improvements
<em>that you want to enable</em> were already
implemented. Usually, it&#39;s a bad idea to left it on its default,
which is 2.3.0 (maximum backward compatibility).</p>
<p>In new projects you should set this to the fixed FreeMarker
version (like <code class="inline-code">Configuration.VERSION_2_3_28</code>) that
you are actually using when starting the project. In older projects
it&#39;s also usually better to keep this high , however you should
check the changes activated (find them in <a href="https://freemarker.apache.org/docs/api/freemarker/template/Configuration.html#Configuration-freemarker.template.Version-">the
API JavaDoc of the <code>Configuration(Version)</code>
constructor</a>), especially if not only the 3rd version number
(the micro version) of "incompatible improvements"
setting is increased. Generally, as far as you only increase the
last (3rd) version number of this setting, the changes are low risk,
and whether you can afford that risk depends on the concrete
application. Never use a dynamic value like
<code class="inline-code">Configuration.getVersion()</code> though, as that way
upgrading FreeMarker can break your application!</p>
<p>Bug fixes and improvements that are fully backward compatible,
also those that are important security fixes, are enabled regardless
of the "incompatible improvements" setting.</p>
<p>An important consequence of setting this setting is that now
your application will check if the stated minimum FreeMarker version
requirement is met. Like if you set this setting to 2.3.22, but
accidentally the application is deployed with FreeMarker 2.3.21,
then FreeMarker will fail, telling that a higher version is
required. After all, the fixes/improvements you have requested
aren&#39;t available on a lower version.</p>
<h2 class="content-header header-section2" id="pgui_config_incompatible_improvements_how_to_set">How to set it</h2>
<p>The incompatible improvements setting exists on the
<code class="inline-code">Configuration</code> level. It can be set on multiple
ways:</p>
<ul>
<li>
<p>Create the
<code class="inline-code">freemarker.template.Configuration</code> object
like:</p>
<div class="code-block role-unspecified">
<pre class="code-block-body">... = new Configuration(Configuration.VERSION_2_3_28)</pre> </div>
</li>
<li>
<p>Or, alter the <code class="inline-code">Configuration</code> singleton
where you initialize its other settings like:</p>
<div class="code-block role-unspecified">
<pre class="code-block-body">cfg.setIncompatibleImprovements(Configuration.VERSION_2_3_28)</pre> </div>
</li>
<li>
<p>Or, if you are configuring FreeMarker with properties
(<code class="inline-code">*.properties</code> file or
<code class="inline-code">java.util.Properties</code> object), add:</p>
<div class="code-block role-unspecified">
<pre class="code-block-body">incompatible_improvements=2.3.28</pre> </div>
</li>
<li>
<p>Or, if you are configuring FreeMarker through
<code class="inline-code">FreemarkerServlet</code>, add this
<code class="inline-code">init-param</code> to it in the
<code class="inline-code">web.xml</code>:</p>
<div class="code-block role-unspecified">
<pre class="code-block-body">&lt;init-param&gt;
&lt;param-name&gt;incompatible_improvements&lt;/param-name&gt;
&lt;param-value&gt;2.3.28&lt;/param-value&gt;
&lt;/init-param&gt;</pre> </div>
</li>
</ul>
<p>But, <em>if you set the
<code class="inline-code">object_wrapper</code> setting</em> (same as
<code class="inline-code">Configuration.setObjectWrapper(ObjectWrapper)</code>) of
your configuration, then it&#39;s important to know that
<code class="inline-code">BeansWrapper</code> and its subclasses (most
importantly, <code class="inline-code">DefaultObjectWrapper</code>) has its own
independent <code class="inline-code">incompatibleImprovements</code> property,
and some fixes/improvements are activated by that, not by
<code class="inline-code">Configuration</code>&#39;s similar setting. You don&#39;t have
to be aware of this complication if you aren&#39;t setting the
<code class="inline-code">object_wrapper</code> configuration setting anywhere,
because the default <code class="inline-code">object_wrapper</code> has the same
"incompatible improvements" as of the
<code class="inline-code">Configuration</code>. But if you are setting the
<code class="inline-code">object_wrapper</code>, then you must not forget to set
the <code class="inline-code">incompatibleImprovements</code> property of the
<code class="inline-code">ObjectWrapper</code> itself, in additionally to that of
the <code class="inline-code">Configuration</code>. (Note that it&#39;s fine to have
different "incompatible improvements" for the
<code class="inline-code">Configuration</code> and for the
<code class="inline-code">ObjectWrapper</code>, only it should be a conscious
decision.) <a href="pgui_datamodel_objectWrapper.html#topic.setDefaultObjectWrapperIcIIndividually">See here how
to set it</a> in the case of
<code class="inline-code">DefaultObjectWrapper</code> (for
<code class="inline-code">BeansWrapper</code> it&#39;s the same, only with different
class name of course).</p>
<div class="callout warning">
<strong class="callout-label">Warning!</strong>
<p>Do not ever use
<code class="inline-code">Configuration.getVersion()</code> to set the
"incompatible improvements" setting. Always use a
fixed value, like <code class="inline-code">Configuration.VERSION_2_3_28</code>.
Otherwise your application can break as you upgrade FreeMarker.
The whole point of "incompatible improvements" is to
protect you from that, while you still always get the
fixes/improvements that are backward compatible.</p>
</div>
<div class="bottom-pagers-wrapper"><div class="pagers bottom"><a class="paging-arrow previous" href="pgui_config_custom_formats.html"><span>Previous</span></a><a class="paging-arrow next" href="pgui_misc.html"><span>Next</span></a></div></div></div></div> </div>
</div>
<div class="site-footer"><div class="site-width"><div class="footer-top"><div class="col-left sitemap"><div class="column"><h3 class="column-header">Overview</h3><ul><li><a href="https://freemarker.apache.org/">What is FreeMarker?</a></li><li><a href="https://freemarker.apache.org/freemarkerdownload.html">Download</a></li><li><a href="app_versions.html">Version history</a></li><li><a href="app_faq.html">FAQ</a></li><li><a itemprop="license" href="app_license.html">License</a></li><li><a href="https://privacy.apache.org/policies/privacy-policy-public.html">Privacy policy</a></li></ul></div><div class="column"><h3 class="column-header">Often used / Reference</h3><ul><li><a href="https://try.freemarker.apache.org/">Try template online</a></li><li><a href="dgui_template_exp.html#exp_cheatsheet">Expressions cheatsheet</a></li><li><a href="ref_directive_alphaidx.html">#directives</a></li><li><a href="ref_builtins_alphaidx.html">?built_ins</a></li><li><a href="ref_specvar.html">.special_vars</a></li><li><a href="api/freemarker/core/Configurable.html#setSetting-java.lang.String-java.lang.String-">Configuration settings</a></li></ul></div><div class="column"><h3 class="column-header">Community</h3><ul><li><a href="https://github.com/apache/freemarker">Github project page</a></li><li><a href="https://issues.apache.org/jira/projects/FREEMARKER">Report a bug</a></li><li><a href="https://freemarker.apache.org/report-security-vulnerabilities.html">Report security vulnerability</a></li><li><a href="https://stackoverflow.com/questions/ask?tags=freemarker">Get help on StackOverflow</a></li><li><a href="https://twitter.com/freemarker">Announcements on Twitter</a></li><li><a href="https://freemarker.apache.org/mailing-lists.html">Discuss on mailing lists</a></li></ul></div></div><div class="col-right"><ul class="social-icons"><li><a class="github" href="https://github.com/apache/freemarker">Github</a></li><li><a class="twitter" href="https://twitter.com/freemarker">Twitter</a></li><li><a class="stack-overflow" href="https://stackoverflow.com/questions/ask?tags=freemarker">Stack Overflow</a></li></ul><a class="xxe" href="http://www.xmlmind.com/xmleditor/" rel="nofollow" title="Edited with XMLMind XML Editor"><span>Edited with XMLMind XML Editor</span></a></div></div><div class="footer-bottom"> <p class="last-generated">
Last generated:
<time itemprop="dateModified" datetime="2024-02-12T20:34:04Z" title="Monday, February 12, 2024 at 8:34:04 PM Greenwich Mean Time">2024-02-12 20:34:04 GMT</time>, for Freemarker 2.3.32 </p>
<p class="copyright">
© <span itemprop="copyrightYear">1999</span>–2024
<a itemtype="http://schema.org/Organization" itemprop="copyrightHolder" href="https://apache.org/">The Apache Software Foundation</a>. Apache FreeMarker, FreeMarker, Apache Incubator, Apache, the Apache FreeMarker logo are trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners. </p>
</div></div></div></body>
</html>