Skip to content

Commit

Permalink
Dropped support for Java 7, to simplify build. Now minimum is Java 8.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddekany committed Dec 8, 2023
1 parent d630419 commit 35e1664
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 162 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,6 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Set up JDK 7
uses: actions/setup-java@v3
with:
java-version: 7
distribution: zulu

- name: Set up JDK 8
uses: actions/setup-java@v3
with:
Expand All @@ -56,7 +50,6 @@ jobs:
- name: Prepare build.properties
shell: bash
run: >-
echo "boot.classpath.j2se1.7=${JAVA_HOME_7_X64}/jre/lib/rt.jar" >> build.properties;
echo "boot.classpath.j2se1.8=${JAVA_HOME_8_X64}/jre/lib/rt.jar" >> build.properties;
echo "mvnCommand=$(which mvn)" >> build.properties;
echo "gpgCommand=$(which gpg)" >> build.properties;
Expand Down
6 changes: 2 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 7. (The presence
The minimum required Java version is currently Java SE 8. (The presence
of a later version may be detected on runtime and utilized by
FreeMarker.)

Expand Down Expand Up @@ -194,14 +194,12 @@ 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.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".
- You will still have errors on these java files (because different java
files depend on different versions of the same library, and Eclipse can't
handle that). Exclude those java files from the Build Path (in the Package
Explorer, right click on the problematic file -> "Build Path" -> "Exclude"):
Explorer, right-click on the problematic file -> "Build Path" -> "Exclude"):
_Jython20*.java,
_Jython22*.java,
_FreeMarkerPageContext2.java,
Expand Down
2 changes: 0 additions & 2 deletions build.properties.sample
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
# under the License.

# 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.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
50 changes: 13 additions & 37 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,21 @@
<property name="server.ivy.repo.root" value="${basedir}/build/dummy-server-ivy-repo" />

<property file="build.properties"/>
<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"/>
</condition>
<condition property="has.all.explicit.boot.classpaths">
<and>
<isset property="has.explicit.boot.classpath.j2se1.7"/>
<isset property="has.explicit.boot.classpath.j2se1.8"/>
</and>
</condition>
<available property="atLeastJDK8" classname="java.util.function.Predicate"/>

<!-- When boot.classpath.j* is missing, these will be the defaults: -->
<!-- Note: Target "dist" doesn't allow using these. -->
<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.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"
property="boot.classpath.j2se1.8.correct"
Expand Down Expand Up @@ -193,12 +184,6 @@
</target>

<target name="compile" depends="javacc">
<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.<!--
--></fail>
<fail unless="boot.classpath.j2se1.8.correct"><!--
-->The "boot.classpath.j2se1.8" property value (${boot.classpath.j2se1.8}) <!--
-->seems to be an incorrect boot classpath. Please fix it in <!--
Expand All @@ -207,8 +192,8 @@
--></fail>
<echo level="info"><!--
-->Using boot classpaths: <!--
-->Java 7: ${boot.classpath.j2se1.7};<!--
-->Java 8: ${boot.classpath.j2se1.8}<!--
-->Java 16: Current JDK classpath<!--
--></echo>

<!-- Comment out @SuppressFBWarnings, as it causes compilation warnings in dependent Gradle projects -->
Expand All @@ -235,10 +220,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.7" source="1.7" encoding="utf-8"
debug="on" optimize="off" target="1.8" source="1.8" encoding="utf-8"
includeantruntime="false"
classpathref="ivy.dep"
bootclasspath="${boot.classpath.j2se1.7}"
bootclasspath="${boot.classpath.j2se1.8}"
excludes="
freemarker/core/_Java?*Impl.java,
freemarker/ext/jsp/**,
Expand All @@ -255,15 +240,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.8" source="1.8" encoding="utf-8"
includeantruntime="false"
classpathref="ivy.dep"
bootclasspath="${boot.classpath.j2se1.8}"
includes="freemarker/core/_Java8Impl.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" release="16" encoding="utf-8"
Expand All @@ -274,10 +250,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.7" source="1.7" encoding="utf-8"
debug="on" optimize="off" target="1.8" source="1.8" encoding="utf-8"
includeantruntime="false"
classpathref="ivy.dep.jsp2.0"
bootclasspath="${boot.classpath.j2se1.7}"
bootclasspath="${boot.classpath.j2se1.8}"
includes="
freemarker/ext/jsp/**,
freemarker/ext/servlet/**,
Expand All @@ -292,10 +268,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.7" source="1.7" encoding="utf-8"
debug="on" optimize="off" target="1.8" source="1.8" encoding="utf-8"
includeantruntime="false"
classpathref="ivy.dep.jsp2.1"
bootclasspath="${boot.classpath.j2se1.7}"
bootclasspath="${boot.classpath.j2se1.8}"
includes="
freemarker/ext/jsp/_FreeMarkerPageContext21.java,
freemarker/ext/jsp/FreeMarkerJspFactory21.java,
Expand All @@ -304,10 +280,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.7" source="1.7" encoding="utf-8"
debug="on" optimize="off" target="1.8" source="1.8" encoding="utf-8"
includeantruntime="false"
classpathref="ivy.dep.jython2.0"
bootclasspath="${boot.classpath.j2se1.7}"
bootclasspath="${boot.classpath.j2se1.8}"
includes="
freemarker/ext/ant/**,
freemarker/template/utility/JythonRuntime.java,
Expand All @@ -319,20 +295,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.7" source="1.7" encoding="utf-8"
debug="on" optimize="off" target="1.8" source="1.8" encoding="utf-8"
includeantruntime="false"
classpathref="ivy.dep.jython2.2"
bootclasspath="${boot.classpath.j2se1.7}"
bootclasspath="${boot.classpath.j2se1.8}"
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.7" source="1.7" encoding="utf-8"
debug="on" optimize="off" target="1.8" source="1.8" encoding="utf-8"
includeantruntime="false"
classpathref="ivy.dep.jython2.5"
bootclasspath="${boot.classpath.j2se1.7}"
bootclasspath="${boot.classpath.j2se1.8}"
includes="
freemarker/ext/jython/_Jython25VersionAdapter.java"
/>
Expand Down
8 changes: 4 additions & 4 deletions osgi.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ Import-Package: !freemarker.*, *;resolution:="optional"
# This is needed for "a.class.from.another.Bundle"?new() to work.
DynamicImport-Package: *

# The required minimum is 1.7, but we utilize versions up to 16 if available.
# See also: http://wiki.eclipse.org/Execution_Environments, "Compiling
# against more than is required"
Bundle-RequiredExecutionEnvironment: JavaSE-16, JavaSE-1.7
# List whole version range between minimum up to where we use new features
# if available. See also: http://wiki.eclipse.org/Execution_Environments,
# "Compiling against more than is required"
Bundle-RequiredExecutionEnvironment: JavaSE-16, JavaSE-15, JavaSE-14, JavaSE-13, JavaSE-12, JavaSE-11, JavaSE-10, JavaSE-9, JavaSE-1.8

# Non-OSGi meta:
Main-Class: freemarker.core.CommandLine
Expand Down
34 changes: 0 additions & 34 deletions src/main/java/freemarker/core/_Java8.java

This file was deleted.

42 changes: 0 additions & 42 deletions src/main/java/freemarker/core/_Java8Impl.java

This file was deleted.

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

private static final boolean IS_AT_LEAST_8 = isAtLeast(8, "java.time.Instant");

/**
* {@code null} if Java 8 is not available, otherwise the object through with the Java 8 operations are available.
*/
static public final _Java8 JAVA_8;
static {
_Java8 java8;
if (IS_AT_LEAST_8) {
try {
java8 = (_Java8) Class.forName("freemarker.core._Java8Impl").getField("INSTANCE").get(null);
} catch (Exception e) {
try {
Logger.getLogger("freemarker.runtime").error("Failed to access Java 8 functionality", e);
} catch (Exception e2) {
// Suppressed
}
java8 = null;
}
} else {
java8 = null;
}
JAVA_8 = java8;
}

private static final boolean IS_AT_LEAST_16 = isAtLeast(16, "java.net.UnixDomainSocketAddress");

/**
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/freemarker/ext/beans/ClassIntrospector.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import java.util.concurrent.ConcurrentHashMap;

import freemarker.core.BugException;
import freemarker.core._JavaVersions;
import freemarker.ext.beans.BeansWrapper.MethodAppearanceDecision;
import freemarker.ext.beans.BeansWrapper.MethodAppearanceDecisionInput;
import freemarker.ext.util.ModelCache;
Expand Down Expand Up @@ -413,7 +412,7 @@ private List<PropertyDescriptor> getPropertyDescriptors(BeanInfo beanInfo, Class
List<PropertyDescriptor> introspectorPDs = introspectorPDsArray != null ? Arrays.asList(introspectorPDsArray)
: Collections.<PropertyDescriptor>emptyList();

if (!treatDefaultMethodsAsBeanMembers || _JavaVersions.JAVA_8 == null) {
if (!treatDefaultMethodsAsBeanMembers) {
// java.beans.Introspector was good enough then.
return introspectorPDs;
}
Expand All @@ -434,7 +433,7 @@ private List<PropertyDescriptor> getPropertyDescriptors(BeanInfo beanInfo, Class
// (Note that java.beans.Introspector discovers non-accessible public methods, and to emulate that behavior
// here, we don't utilize the accessibleMethods Map, which we might already have at this point.)
for (Method method : clazz.getMethods()) {
if (_JavaVersions.JAVA_8.isDefaultMethod(method) && method.getReturnType() != void.class
if (method.isDefault() && method.getReturnType() != void.class
&& !method.isBridge()) {
Class<?>[] paramTypes = method.getParameterTypes();
if (paramTypes.length == 0
Expand Down Expand Up @@ -607,14 +606,14 @@ private List<MethodDescriptor> getMethodDescriptors(BeanInfo beanInfo, Class<?>
List<MethodDescriptor> introspectionMDs = introspectorMDArray != null && introspectorMDArray.length != 0
? Arrays.asList(introspectorMDArray) : Collections.<MethodDescriptor>emptyList();

if (!treatDefaultMethodsAsBeanMembers || _JavaVersions.JAVA_8 == null) {
if (!treatDefaultMethodsAsBeanMembers) {
// java.beans.Introspector was good enough then.
return introspectionMDs;
}

Map<String, List<Method>> defaultMethodsToAddByName = null;
for (Method method : clazz.getMethods()) {
if (_JavaVersions.JAVA_8.isDefaultMethod(method) && !method.isBridge()) {
if (method.isDefault() && !method.isBridge()) {
if (defaultMethodsToAddByName == null) {
defaultMethodsToAddByName = new HashMap<>();
}
Expand Down
3 changes: 3 additions & 0 deletions src/manual/en_US/book.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30062,6 +30062,9 @@ TemplateModel x = env.getVariable("x"); // get variable x</programlisting>

<para>Release date: [TODO]</para>

<para>Please note that with this version the minimum required Java
version was increased from Java 7 to Java 8.</para>

<section>
<title>Changes on the FTL side</title>

Expand Down
2 changes: 0 additions & 2 deletions src/test/java/freemarker/ext/beans/BeansWrapperMiscTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

import freemarker.core._JavaVersions;
import freemarker.template.Configuration;
import freemarker.template.TemplateBooleanModel;
import freemarker.template.TemplateHashModel;
Expand Down Expand Up @@ -101,7 +100,6 @@ public void java8IndexedMethodIssueTest() throws TemplateModelException {

@Test
public void java8InaccessibleIndexedAccessibleNonIndexedReadMethodTest() throws TemplateModelException {
assertTrue("This test case must be ran on Java 8 or later", _JavaVersions.JAVA_8 != null);
assertFalse(Modifier.isPublic(BeanWithInaccessibleIndexedProperty.class.getModifiers()));

for (Version ici : new Version[] { Configuration.VERSION_2_3_26, Configuration.VERSION_2_3_27 }) {
Expand Down

0 comments on commit 35e1664

Please sign in to comment.