Skip to content

Commit

Permalink
Increased minimum required Java version from 5 to 7.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddekany committed Jan 12, 2020
1 parent 3f7f2d9 commit 66f1ab1
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 193 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ dependency, as freemarker.ext.dom can't use the XPath support
included in OpenJDK anymore. It's not needed on Oracle Java 9,
or if FreeMarker is configured to use Jaxen for XPath.

The minimum required Java version is currently Java SE 5. (The presence
The minimum required Java version is currently Java SE 7. (The presence
of a later version may be detected on runtime and utilized by
FreeMarker.)

Expand Down Expand Up @@ -201,7 +201,7 @@ Below you find the step-by-step setup for Eclipse (originally done on Mars.1):
- Press "Finish"
- Eclipse will indicate many errors at this point; it's expected, read on.
- Project -> Properties -> Java Compiler
- Set "Compiler Compliance Level" to "1.5" (you will have to uncheck
- Set "Compiler Compliance Level" to "1.7" (you will have to uncheck
"Use compliance from execution environment" for that)
- In Errors/Warnings, check in "Enable project specific settings", then set
"Forbidden reference (access rules)" from "Error" to "Warning".
Expand Down Expand Up @@ -272,8 +272,8 @@ Originally done on IntelliJ IDEA Community 2018.2.4:
- Test Resource Folders:
src/test/resources

- Still inside the "Sources" tab, change the "Language level" to "5". (Yes, we use Java 8 SDK with
language level 5 in the IDE, due to the tricks FreeMarker uses to support different Java versions.)
- Still inside the "Sources" tab, change the "Language level" to "7". (Yes, we use Java 8 SDK with
language level 7 in the IDE, due to the tricks FreeMarker uses to support different Java versions.)

- Switch over to the "Dependencies" tab (still inside "Project Structure" / "Modules"), and add
all the jar-s inside the `ide-dependencies` directory as dependency. (How: Click the "+" icon
Expand Down
3 changes: 1 addition & 2 deletions build.properties.sample
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@

# Copy this file to "build.properties" before editing!
# These propeties should point to the rt.jar-s of the respective J2SE versions:
boot.classpath.j2se1.5=C:/Program Files (x86)/Java/jdk1.5.0_16/jre/lib/rt.jar
boot.classpath.j2se1.6=C:/Program Files/Java/jdk1.6.0_24/jre/lib/rt.jar
boot.classpath.j2se1.7=c:/Program Files/Java/jre7/lib/rt.jar
boot.classpath.j2se1.8=C:/Program Files/Java/jdk1.8.0_66/jre/lib/rt.jar
mvnCommand=C:/Program Files (x86)/maven3/bin/mvn.bat
gpgCommand=C:/Program Files (x86)/GNU/GnuPG/pub/gpg.exe
68 changes: 22 additions & 46 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,8 @@
<property name="server.ivy.repo.root" value="${basedir}/build/dummy-server-ivy-repo" />

<property file="build.properties"/>
<condition property="has.explicit.boot.classpath.j2se1.5">
<isset property="boot.classpath.j2se1.5"/>
</condition>
<condition property="has.explicit.boot.classpath.j2se1.6">
<isset property="boot.classpath.j2se1.6"/>
<condition property="has.explicit.boot.classpath.j2se1.7">
<isset property="boot.classpath.j2se1.7"/>
</condition>
<condition property="has.explicit.boot.classpath.j2se1.8">
<isset property="boot.classpath.j2se1.8"/>
Expand All @@ -61,18 +58,13 @@

<!-- When boot.classpath.j2se* is missing, these will be the defaults: -->
<!-- Note: Target "dist" doesn't allow using these. -->
<property name="boot.classpath.j2se1.5" value="${sun.boot.class.path}" />
<property name="boot.classpath.j2se1.6" value="${sun.boot.class.path}" />
<property name="boot.classpath.j2se1.7" value="${sun.boot.class.path}" />
<property name="boot.classpath.j2se1.8" value="${sun.boot.class.path}" />

<!-- For checking the correctness of the boot.classpath.j2se* -->
<available classpath="${boot.classpath.j2se1.5}"
classname="java.util.concurrent.ConcurrentHashMap" ignoresystemclasses="true"
property="boot.classpath.j2se1.5.correct"
/>
<available classpath="${boot.classpath.j2se1.6}"
classname="java.util.ServiceLoader" ignoresystemclasses="true"
property="boot.classpath.j2se1.6.correct"
<available classpath="${boot.classpath.j2se1.7}"
classname="java.nio.file.Path" ignoresystemclasses="true"
property="boot.classpath.j2se1.7.correct"
/>
<available classpath="${boot.classpath.j2se1.8}"
classname="java.time.Instant" ignoresystemclasses="true"
Expand Down Expand Up @@ -210,14 +202,8 @@
</target>

<target name="compile" depends="javacc">
<fail unless="boot.classpath.j2se1.5.correct"><!--
-->The "boot.classpath.j2se1.5" property value (${boot.classpath.j2se1.5}) <!--
-->seems to be an incorrect boot classpath. Please fix it in <!--
-->the &lt;projectDir>/build.properties file, or wherever you <!--
-->set it.<!--
--></fail>
<fail unless="boot.classpath.j2se1.6.correct"><!--
-->The "boot.classpath.j2se1.6" property value (${boot.classpath.j2se1.6}) <!--
<fail unless="boot.classpath.j2se1.7.correct"><!--
-->The "boot.classpath.j2se1.7" property value (${boot.classpath.j2se1.7}) <!--
-->seems to be an incorrect boot classpath. Please fix it in <!--
-->the &lt;projectDir>/build.properties file, or wherever you <!--
-->set it.<!--
Expand All @@ -229,9 +215,8 @@
-->set it.<!--
--></fail>
<echo level="info"><!--
-->Using boot classpaths:<!--
-->Java 5: ${boot.classpath.j2se1.5}; <!--
-->Java 6: ${boot.classpath.j2se1.6}<!--
-->Using boot classpaths: <!--
-->Java 7: ${boot.classpath.j2se1.7};<!--
-->Java 8: ${boot.classpath.j2se1.8}<!--
--></echo>

Expand Down Expand Up @@ -259,10 +244,10 @@
<!-- Note: the "build.base" conf doesn't include optional FreeMarker dependencies. -->
<ivy:cachepath conf="build.base" pathid="ivy.dep" />
<javac destdir="build/classes" deprecation="off"
debug="on" optimize="off" target="1.5" source="1.5" encoding="utf-8"
debug="on" optimize="off" target="1.7" source="1.7" encoding="utf-8"
includeantruntime="false"
classpathref="ivy.dep"
bootclasspath="${boot.classpath.j2se1.5}"
bootclasspath="${boot.classpath.j2se1.7}"
excludes="
freemarker/core/_Java?*Impl.java,
freemarker/ext/jsp/**,
Expand All @@ -279,15 +264,6 @@
</src>
</javac>

<ivy:cachepath conf="build.base" pathid="ivy.dep" />
<javac srcdir="build/src-main-java-filtered" destdir="build/classes" deprecation="off"
debug="on" optimize="off" target="1.6" source="1.6" encoding="utf-8"
includeantruntime="false"
classpathref="ivy.dep"
bootclasspath="${boot.classpath.j2se1.6}"
includes="freemarker/core/_Java6Impl.java"
/>

<ivy:cachepath conf="build.base" pathid="ivy.dep" />
<javac srcdir="build/src-main-java-filtered" destdir="build/classes" deprecation="off"
debug="on" optimize="off" target="1.8" source="1.8" encoding="utf-8"
Expand All @@ -305,10 +281,10 @@

<ivy:cachepath conf="build.jsp2.0" pathid="ivy.dep.jsp2.0" />
<javac srcdir="build/src-main-java-filtered" destdir="build/classes" deprecation="off"
debug="on" optimize="off" target="1.5" source="1.5" encoding="utf-8"
debug="on" optimize="off" target="1.7" source="1.7" encoding="utf-8"
includeantruntime="false"
classpathref="ivy.dep.jsp2.0"
bootclasspath="${boot.classpath.j2se1.5}"
bootclasspath="${boot.classpath.j2se1.7}"
includes="
freemarker/ext/jsp/**,
freemarker/ext/servlet/**,
Expand All @@ -323,10 +299,10 @@

<ivy:cachepath conf="build.jsp2.1" pathid="ivy.dep.jsp2.1" />
<javac srcdir="build/src-main-java-filtered" destdir="build/classes" deprecation="off"
debug="on" optimize="off" target="1.5" source="1.5" encoding="utf-8"
debug="on" optimize="off" target="1.7" source="1.7" encoding="utf-8"
includeantruntime="false"
classpathref="ivy.dep.jsp2.1"
bootclasspath="${boot.classpath.j2se1.5}"
bootclasspath="${boot.classpath.j2se1.7}"
includes="
freemarker/ext/jsp/_FreeMarkerPageContext21.java,
freemarker/ext/jsp/FreeMarkerJspFactory21.java,
Expand All @@ -335,10 +311,10 @@

<ivy:cachepath conf="build.jython2.0" pathid="ivy.dep.jython2.0" />
<javac srcdir="build/src-main-java-filtered" destdir="build/classes" deprecation="off"
debug="on" optimize="off" target="1.5" source="1.5" encoding="utf-8"
debug="on" optimize="off" target="1.7" source="1.7" encoding="utf-8"
includeantruntime="false"
classpathref="ivy.dep.jython2.0"
bootclasspath="${boot.classpath.j2se1.5}"
bootclasspath="${boot.classpath.j2se1.7}"
includes="
freemarker/ext/ant/**,
freemarker/template/utility/JythonRuntime.java,
Expand All @@ -350,20 +326,20 @@

<ivy:cachepath conf="build.jython2.2" pathid="ivy.dep.jython2.2" />
<javac srcdir="build/src-main-java-filtered" destdir="build/classes" deprecation="off"
debug="on" optimize="off" target="1.5" source="1.5" encoding="utf-8"
debug="on" optimize="off" target="1.7" source="1.7" encoding="utf-8"
includeantruntime="false"
classpathref="ivy.dep.jython2.2"
bootclasspath="${boot.classpath.j2se1.5}"
bootclasspath="${boot.classpath.j2se1.7}"
includes="
freemarker/ext/jython/_Jython22VersionAdapter.java"
/>

<ivy:cachepath conf="build.jython2.5" pathid="ivy.dep.jython2.5" />
<javac srcdir="build/src-main-java-filtered" destdir="build/classes" deprecation="off"
debug="on" optimize="off" target="1.5" source="1.5" encoding="utf-8"
debug="on" optimize="off" target="1.7" source="1.7" encoding="utf-8"
includeantruntime="false"
classpathref="ivy.dep.jython2.5"
bootclasspath="${boot.classpath.j2se1.5}"
bootclasspath="${boot.classpath.j2se1.7}"
includes="
freemarker/ext/jython/_Jython25VersionAdapter.java"
/>
Expand Down
15 changes: 2 additions & 13 deletions src/main/java/freemarker/core/ExtendedDecimalFormatParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ public void handle(ExtendedDecimalFormatParser parser, String value)
+ PARAM_VALUE_RND_HALF_EVEN + ", " + PARAM_VALUE_RND_UNNECESSARY);
}

if (_JavaVersions.JAVA_6 == null) {
throw new InvalidParameterValueException("For setting the rounding mode you need Java 6 or later.");
}

parser.roundingMode = parsedValue;
}
});
Expand Down Expand Up @@ -136,11 +132,7 @@ public void handle(ExtendedDecimalFormatParser parser, String value)
m.put(PARAM_EXPONENT_SEPARATOR, new ParameterHandler() {
public void handle(ExtendedDecimalFormatParser parser, String value)
throws InvalidParameterValueException {
if (_JavaVersions.JAVA_6 == null) {
throw new InvalidParameterValueException(
"For setting the exponent separator you need Java 6 or later.");
}
_JavaVersions.JAVA_6.setExponentSeparator(parser.symbols, value);
parser.symbols.setExponentSeparator(value);
}
});
m.put(PARAM_MINUS_SIGN, new ParameterHandler() {
Expand Down Expand Up @@ -241,10 +233,7 @@ private DecimalFormat parse() throws ParseException {
}

if (roundingMode != null) {
if (_JavaVersions.JAVA_6 == null) {
throw new ParseException("Setting rounding mode needs Java 6 or later", 0);
}
_JavaVersions.JAVA_6.setRoundingMode(decimalFormat, roundingMode);
decimalFormat.setRoundingMode(roundingMode);
}

if (multiplier != null) {
Expand Down
35 changes: 0 additions & 35 deletions src/main/java/freemarker/core/_Java6.java

This file was deleted.

47 changes: 0 additions & 47 deletions src/main/java/freemarker/core/_Java6Impl.java

This file was deleted.

43 changes: 0 additions & 43 deletions src/main/java/freemarker/core/_JavaVersions.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,49 +31,6 @@ private _JavaVersions() {
// Not meant to be instantiated
}

private static final boolean IS_AT_LEAST_6;
static {
boolean result = false;
String vStr = SecurityUtilities.getSystemProperty("java.version", null);
if (vStr != null) {
try {
Version v = new Version(vStr);
result = v.getMajor() == 1 && v.getMinor() >= 6 || v.getMajor() > 1;
} catch (Exception e) {
// Ignore
}
}
if (vStr == null) {
try {
Class.forName("java.util.ServiceLoader");
result = true;
} catch (Exception e) {
// Ignore
}
}
IS_AT_LEAST_6 = result;
}

static public final _Java6 JAVA_6;
static {
_Java6 java6;
if (IS_AT_LEAST_6) {
try {
java6 = (_Java6) Class.forName("freemarker.core._Java6Impl").getField("INSTANCE").get(null);
} catch (Exception e) {
try {
Logger.getLogger("freemarker.runtime").error("Failed to access Java 6 functionality", e);
} catch (Exception e2) {
// Suppressed
}
java6 = null;
}
} else {
java6 = null;
}
JAVA_6 = java6;
}

private static final boolean IS_AT_LEAST_8;
static {
boolean result = false;
Expand Down
10 changes: 7 additions & 3 deletions src/manual/en_US/book.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11191,9 +11191,8 @@ TemplateHashModel fileStatics =

<para>The <literal>TemplateHashModel</literal> returned from
<literal>BeansWrapper.getEnumModels()</literal> can be used to
create hash models for accessing values of enums on JRE 1.5 or
later. (An attempt to invoke this method on an earlier JRE will
result in an
create hash models for accessing values of enums. (An attempt to
invoke this method on an earlier JRE will result in an
<literal>UnsupportedOperationException</literal>.)</para>

<programlisting role="unspecified">BeansWrapper wrapper = BeansWrapper.getDefaultInstance();
Expand Down Expand Up @@ -29381,6 +29380,11 @@ TemplateModel x = env.getVariable("x"); // get variable x</programlisting>
<title>Changes on the Java side</title>

<itemizedlist>
<listitem>
<para>The minimum required Java version was increased from Java
5 to Java 7.</para>
</listitem>

<listitem>
<para><link
xlink:href="https://issues.apache.org/jira/browse/FREEMARKER-109">FREEMARKER-109</link>:
Expand Down

0 comments on commit 66f1ab1

Please sign in to comment.