freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject [freemarker] branch 2.3-gae updated: Increased minimum required Java version from 5 to 7.
Date Sun, 12 Jan 2020 21:43:46 GMT
This is an automated email from the ASF dual-hosted git repository.

ddekany pushed a commit to branch 2.3-gae
in repository https://gitbox.apache.org/repos/asf/freemarker.git


The following commit(s) were added to refs/heads/2.3-gae by this push:
     new 66f1ab1  Increased minimum required Java version from 5 to 7.
66f1ab1 is described below

commit 66f1ab1ed541fe7be120cec436334a2734b0fc09
Author: ddekany <ddekany@apache.org>
AuthorDate: Sun Jan 12 22:41:52 2020 +0100

    Increased minimum required Java version from 5 to 7.
---
 README.md                                          |  8 +--
 build.properties.sample                            |  3 +-
 build.xml                                          | 68 +++++++---------------
 .../core/ExtendedDecimalFormatParser.java          | 15 +----
 src/main/java/freemarker/core/_Java6.java          | 35 -----------
 src/main/java/freemarker/core/_Java6Impl.java      | 47 ---------------
 src/main/java/freemarker/core/_JavaVersions.java   | 43 --------------
 src/manual/en_US/book.xml                          | 10 +++-
 8 files changed, 36 insertions(+), 193 deletions(-)

diff --git a/README.md b/README.md
index dab9870..d8197cb 100644
--- a/README.md
+++ b/README.md
@@ -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.)
 
@@ -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".
@@ -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
diff --git a/build.properties.sample b/build.properties.sample
index 56315b3..d5e31cc 100644
--- a/build.properties.sample
+++ b/build.properties.sample
@@ -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
\ No newline at end of file
diff --git a/build.xml b/build.xml
index 1953b75..5098e11 100644
--- a/build.xml
+++ b/build.xml
@@ -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"/>
@@ -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" 
@@ -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.<!--
@@ -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>
 
@@ -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/**,
@@ -281,15 +266,6 @@
 
     <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"
       includeantruntime="false"
       classpathref="ivy.dep"
@@ -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/**,
@@ -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,
@@ -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,
@@ -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"
     />
diff --git a/src/main/java/freemarker/core/ExtendedDecimalFormatParser.java b/src/main/java/freemarker/core/ExtendedDecimalFormatParser.java
index 03d71eb..af48f07 100644
--- a/src/main/java/freemarker/core/ExtendedDecimalFormatParser.java
+++ b/src/main/java/freemarker/core/ExtendedDecimalFormatParser.java
@@ -87,10 +87,6 @@ class ExtendedDecimalFormatParser {
                             + 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;
             }
         });
@@ -136,11 +132,7 @@ class ExtendedDecimalFormatParser {
         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() {
@@ -241,10 +233,7 @@ class ExtendedDecimalFormatParser {
         }
 
         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) {
diff --git a/src/main/java/freemarker/core/_Java6.java b/src/main/java/freemarker/core/_Java6.java
deleted file mode 100644
index cd03fb2..0000000
--- a/src/main/java/freemarker/core/_Java6.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package freemarker.core;
-
-import java.math.RoundingMode;
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-
-/**
- * Used internally only, might changes without notice!
- * Used for accessing functionality that's only present in Java 6 or later.
- */
-public interface _Java6 {
-
-    void setRoundingMode(DecimalFormat df, RoundingMode roundingMode);
-
-    void setExponentSeparator(DecimalFormatSymbols dfs, String exponentSeparator);
-    
-}
diff --git a/src/main/java/freemarker/core/_Java6Impl.java b/src/main/java/freemarker/core/_Java6Impl.java
deleted file mode 100644
index 090a58d..0000000
--- a/src/main/java/freemarker/core/_Java6Impl.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package freemarker.core;
-
-import java.math.RoundingMode;
-import java.text.DecimalFormat;
-import java.text.DecimalFormatSymbols;
-
-/**
- * Used internally only, might changes without notice!
- * Used for accessing functionality that's only present in Java 6 or later.
- */
-//Compile this against Java 6
-@SuppressWarnings("Since15") // For IntelliJ inspection   
-public final class _Java6Impl implements _Java6 {
-    
-    public static final _Java6 INSTANCE = new _Java6Impl();
-
-    private _Java6Impl() {
-        // Not meant to be instantiated
-    }
-
-    public void setRoundingMode(DecimalFormat df, RoundingMode roundingMode) {
-        df.setRoundingMode(roundingMode);
-    }
-
-    public void setExponentSeparator(DecimalFormatSymbols dfs, String exponentSeparator)
{
-        dfs.setExponentSeparator(exponentSeparator);
-    }
-    
-}
diff --git a/src/main/java/freemarker/core/_JavaVersions.java b/src/main/java/freemarker/core/_JavaVersions.java
index 7e6f1eb..3f07673 100644
--- a/src/main/java/freemarker/core/_JavaVersions.java
+++ b/src/main/java/freemarker/core/_JavaVersions.java
@@ -31,49 +31,6 @@ public final class _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;
diff --git a/src/manual/en_US/book.xml b/src/manual/en_US/book.xml
index 4d3ef5a..cc0bd39 100644
--- a/src/manual/en_US/book.xml
+++ b/src/manual/en_US/book.xml
@@ -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();
@@ -29382,6 +29381,11 @@ TemplateModel x = env.getVariable("x");  // get variable x</programlisting>
 
           <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>:
               In JSP TLD-s, line breaks inside function parameter lists have


Mime
View raw message