freemarker-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ddek...@apache.org
Subject incubator-freemarker git commit: Removed "dynamic" Java 6 linking, as we require Java 7. Added placeholder for dynamic Java 8 linking instead.
Date Fri, 17 Feb 2017 10:08:17 GMT
Repository: incubator-freemarker
Updated Branches:
  refs/heads/3 b0e08ccb8 -> 4e2f45147


Removed "dynamic" Java 6 linking, as we require Java 7. Added placeholder for dynamic Java
8 linking instead.


Project: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/commit/4e2f4514
Tree: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/tree/4e2f4514
Diff: http://git-wip-us.apache.org/repos/asf/incubator-freemarker/diff/4e2f4514

Branch: refs/heads/3
Commit: 4e2f45147176e62077e04f8e03b723d5c2f54162
Parents: b0e08cc
Author: ddekany <ddekany@apache.org>
Authored: Fri Feb 17 11:08:13 2017 +0100
Committer: ddekany <ddekany@apache.org>
Committed: Fri Feb 17 11:08:13 2017 +0100

----------------------------------------------------------------------
 .../core/ast/ExtendedDecimalFormatParser.java   | 28 ++++++------
 .../org/apache/freemarker/core/ast/_Java6.java  | 35 ---------------
 .../apache/freemarker/core/ast/_Java6Impl.java  | 45 --------------------
 .../org/apache/freemarker/core/ast/_Java8.java  | 32 ++++++++++++++
 .../apache/freemarker/core/ast/_Java8Impl.java  | 39 +++++++++++++++++
 .../freemarker/core/ast/_JavaVersions.java      | 29 +++++++------
 6 files changed, 102 insertions(+), 106 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4e2f4514/src/main/java/org/apache/freemarker/core/ast/ExtendedDecimalFormatParser.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/ExtendedDecimalFormatParser.java
b/src/main/java/org/apache/freemarker/core/ast/ExtendedDecimalFormatParser.java
index e795b3f..1c29eb9 100644
--- a/src/main/java/org/apache/freemarker/core/ast/ExtendedDecimalFormatParser.java
+++ b/src/main/java/org/apache/freemarker/core/ast/ExtendedDecimalFormatParser.java
@@ -60,6 +60,7 @@ class ExtendedDecimalFormatParser {
     static {
         HashMap<String, ParameterHandler> m = new HashMap<String, ParameterHandler>();
         m.put(PARAM_ROUNDING_MODE, new ParameterHandler() {
+            @Override
             public void handle(ExtendedDecimalFormatParser parser, String value)
                     throws InvalidParameterValueException {
                 RoundingMode parsedValue;
@@ -83,14 +84,11 @@ class ExtendedDecimalFormatParser {
                     throw new InvalidParameterValueException("Should be one of: u, d, c,
f, hd, he, hu, un");
                 }
 
-                if (_JavaVersions.JAVA_6 == null) {
-                    throw new InvalidParameterValueException("For setting the rounding mode
you need Java 6 or later.");
-                }
-
                 parser.roundingMode = parsedValue;
             }
         });
         m.put(PARAM_MULTIPIER, new ParameterHandler() {
+            @Override
             public void handle(ExtendedDecimalFormatParser parser, String value)
                     throws InvalidParameterValueException {
                 try {
@@ -101,6 +99,7 @@ class ExtendedDecimalFormatParser {
             }
         });
         m.put(PARAM_DECIMAL_SEPARATOR, new ParameterHandler() {
+            @Override
             public void handle(ExtendedDecimalFormatParser parser, String value)
                     throws InvalidParameterValueException {
                 if (value.length() != 1) {
@@ -110,6 +109,7 @@ class ExtendedDecimalFormatParser {
             }
         });
         m.put(PARAM_MONETARY_DECIMAL_SEPARATOR, new ParameterHandler() {
+            @Override
             public void handle(ExtendedDecimalFormatParser parser, String value)
                     throws InvalidParameterValueException {
                 if (value.length() != 1) {
@@ -119,6 +119,7 @@ class ExtendedDecimalFormatParser {
             }
         });
         m.put(PARAM_GROUP_SEPARATOR, new ParameterHandler() {
+            @Override
             public void handle(ExtendedDecimalFormatParser parser, String value)
                     throws InvalidParameterValueException {
                 if (value.length() != 1) {
@@ -128,16 +129,14 @@ class ExtendedDecimalFormatParser {
             }
         });
         m.put(PARAM_EXPONENT_SEPARATOR, new ParameterHandler() {
+            @Override
             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() {
+            @Override
             public void handle(ExtendedDecimalFormatParser parser, String value)
                     throws InvalidParameterValueException {
                 if (value.length() != 1) {
@@ -147,18 +146,21 @@ class ExtendedDecimalFormatParser {
             }
         });
         m.put(PARAM_INFINITY, new ParameterHandler() {
+            @Override
             public void handle(ExtendedDecimalFormatParser parser, String value)
                     throws InvalidParameterValueException {
                 parser.symbols.setInfinity(value);
             }
         });
         m.put(PARAM_NAN, new ParameterHandler() {
+            @Override
             public void handle(ExtendedDecimalFormatParser parser, String value)
                     throws InvalidParameterValueException {
                 parser.symbols.setNaN(value);
             }
         });
         m.put(PARAM_PERCENT, new ParameterHandler() {
+            @Override
             public void handle(ExtendedDecimalFormatParser parser, String value)
                     throws InvalidParameterValueException {
                 if (value.length() != 1) {
@@ -168,6 +170,7 @@ class ExtendedDecimalFormatParser {
             }
         });
         m.put(PARAM_PER_MILL, new ParameterHandler() {
+            @Override
             public void handle(ExtendedDecimalFormatParser parser, String value)
                     throws InvalidParameterValueException {
                 if (value.length() != 1) {
@@ -177,6 +180,7 @@ class ExtendedDecimalFormatParser {
             }
         });
         m.put(PARAM_ZERO_DIGIT, new ParameterHandler() {
+            @Override
             public void handle(ExtendedDecimalFormatParser parser, String value)
                     throws InvalidParameterValueException {
                 if (value.length() != 1) {
@@ -186,6 +190,7 @@ class ExtendedDecimalFormatParser {
             }
         });
         m.put(PARAM_CURRENCY_CODE, new ParameterHandler() {
+            @Override
             public void handle(ExtendedDecimalFormatParser parser, String value)
                     throws InvalidParameterValueException {
                 Currency currency;
@@ -235,10 +240,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 (multipier != null) {

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4e2f4514/src/main/java/org/apache/freemarker/core/ast/_Java6.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/_Java6.java b/src/main/java/org/apache/freemarker/core/ast/_Java6.java
deleted file mode 100644
index d4277bb..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/_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 org.apache.freemarker.core.ast;
-
-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);
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4e2f4514/src/main/java/org/apache/freemarker/core/ast/_Java6Impl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/_Java6Impl.java b/src/main/java/org/apache/freemarker/core/ast/_Java6Impl.java
deleted file mode 100644
index 36a61f2..0000000
--- a/src/main/java/org/apache/freemarker/core/ast/_Java6Impl.java
+++ /dev/null
@@ -1,45 +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 org.apache.freemarker.core.ast;
-
-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 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);
-    }
-    
-}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4e2f4514/src/main/java/org/apache/freemarker/core/ast/_Java8.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/_Java8.java b/src/main/java/org/apache/freemarker/core/ast/_Java8.java
new file mode 100644
index 0000000..81d0daf
--- /dev/null
+++ b/src/main/java/org/apache/freemarker/core/ast/_Java8.java
@@ -0,0 +1,32 @@
+/*
+ * 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 org.apache.freemarker.core.ast;
+
+/**
+ * Used internally only, might changes without notice!
+ * Used for accessing functionality that's only present in Java 6 or later.
+ */
+public interface _Java8 {
+
+    /**
+     * This is just a placeholder. Remove this when we have some real functionality here.
+     */
+    void doSomething();
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4e2f4514/src/main/java/org/apache/freemarker/core/ast/_Java8Impl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/_Java8Impl.java b/src/main/java/org/apache/freemarker/core/ast/_Java8Impl.java
new file mode 100644
index 0000000..eccb0f6
--- /dev/null
+++ b/src/main/java/org/apache/freemarker/core/ast/_Java8Impl.java
@@ -0,0 +1,39 @@
+/*
+ * 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 org.apache.freemarker.core.ast;
+
+/**
+ * Used internally only, might changes without notice!
+ * Used for accessing functionality that's only present in Java 6 or later.
+ */
+// Compile this against Java 8
+public final class _Java8Impl implements _Java8 {
+    
+    public static final _Java8 INSTANCE = new _Java8Impl();
+
+    private _Java8Impl() {
+        // Not meant to be instantiated
+    }
+
+    @Override
+    public void doSomething() {
+        // Do something that requires Java 8 here
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4e2f4514/src/main/java/org/apache/freemarker/core/ast/_JavaVersions.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/ast/_JavaVersions.java b/src/main/java/org/apache/freemarker/core/ast/_JavaVersions.java
index cef65ea..c24c400 100644
--- a/src/main/java/org/apache/freemarker/core/ast/_JavaVersions.java
+++ b/src/main/java/org/apache/freemarker/core/ast/_JavaVersions.java
@@ -31,47 +31,50 @@ public final class _JavaVersions {
         // Not meant to be instantiated
     }
 
-    private static final boolean IS_AT_LEAST_6;
+    private static final boolean IS_AT_LEAST_8;
     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;
+                result = v.getMajor() == 1 && v.getMinor() >= 8 || v.getMajor()
> 1;
             } catch (Exception e) {
                 // Ignore
             }
-        }
-        if (vStr == null) {
+        } else {
             try {
-                Class.forName("java.util.ServiceLoader");
+                Class.forName("java.time.Instant");
                 result = true;
             } catch (Exception e) {
                 // Ignore
             }
         }
-        IS_AT_LEAST_6 = result;
+        IS_AT_LEAST_8 = result;
     }
     
-    static public final _Java6 JAVA_6;
+    /**
+     * {@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 {
-        _Java6 java6;
-        if (IS_AT_LEAST_6) {
+        _Java8 java8;
+        if (IS_AT_LEAST_8) {
             try {
-                java6 = (_Java6) Class.forName("org.apache.freemarker.core.ast._Java6Impl").getField("INSTANCE").get(null);
+                java8 = (_Java8) Class.forName("org.apache.freemarker.core.ast._Java8Impl")
+                        .getField("INSTANCE").get(null);
             } catch (Exception e) {
                 try {
                     _CoreLogs.RUNTIME.error("Failed to access Java 6 functionality", e);
                 } catch (Exception e2) {
                     // Suppressed
                 }
-                java6 = null;
+                java8 = null;
             }
         } else {
-            java6 = null;
+            java8 = null;
         }
-        JAVA_6 = java6;
+        JAVA_8 = java8;
     }
     
 }


Mime
View raw message