You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@freemarker.apache.org by dd...@apache.org on 2017/03/07 14:29:59 UTC

[3/3] incubator-freemarker git commit: Fixed Java 8 support placeholder (forward ported from 2.3-gae)

Fixed Java 8 support placeholder (forward ported from 2.3-gae)


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

Branch: refs/heads/3
Commit: 4f723584c4c1ddfd7e48e11b86835e954d50df22
Parents: 80300dd
Author: ddekany <dd...@apache.org>
Authored: Tue Mar 7 15:29:46 2017 +0100
Committer: ddekany <dd...@apache.org>
Committed: Tue Mar 7 15:29:46 2017 +0100

----------------------------------------------------------------------
 README                                          |  4 +-
 build.properties.sample                         |  1 +
 build.xml                                       | 32 +++++++++++++--
 .../java/org/apache/freemarker/core/_Java8.java | 34 ++++++++++++++++
 .../org/apache/freemarker/core/_Java8Impl.java  | 43 ++++++++++++++++++++
 .../org/apache/freemarker/core/util/_Java8.java | 32 ---------------
 .../apache/freemarker/core/util/_Java8Impl.java | 39 ------------------
 .../freemarker/core/util/_JavaVersions.java     |  5 ++-
 8 files changed, 112 insertions(+), 78 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4f723584/README
----------------------------------------------------------------------
diff --git a/README b/README
index c3b68e7..18ab3bf 100644
--- a/README
+++ b/README
@@ -169,7 +169,7 @@ apply it to your development environment:
     Number of imports required for .*: 99
     Number of static imports needed for .*: 1
   - Java -> Installed JRE-s:
-    Ensure that you have JDK 7 installed, and that it was added to Eclipse.
+    Ensure that you have JDK 8 installed, and that it was added to Eclipse.
     Note that it's not JRE, but JDK.
   - Java -> Compiler -> Javadoc:
     "Malformed Javadoc comments": Error
@@ -192,7 +192,7 @@ apply it to your development environment:
         src/test/resources
     - On the "Libraries" tab:
       - Delete everyhing from there, except the "JRE System Library [...]"
-      - Edit "JRE System Library [...]" to "Execution Environment" "JavaSE 1.7"
+      - Edit "JRE System Library [...]" to "Execution Environment" "JavaSE 1.8"
       - Add all jar-s that are directly under the "ide-dependencies" directory
         (use the "Add JARs..." and select all those files).
    - Press "Finish"

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4f723584/build.properties.sample
----------------------------------------------------------------------
diff --git a/build.properties.sample b/build.properties.sample
index fd366cf..51d253a 100644
--- a/build.properties.sample
+++ b/build.properties.sample
@@ -18,5 +18,6 @@
 # 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/jdk1.7.0_25/jre/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.cmd
 gpgCommand=C:/Program Files (x86)/GNU/GnuPG/pub/gpg.exe
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4f723584/build.xml
----------------------------------------------------------------------
diff --git a/build.xml b/build.xml
index 1589758..7f5509c 100644
--- a/build.xml
+++ b/build.xml
@@ -46,9 +46,13 @@
   <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"/>
@@ -56,12 +60,17 @@
   <!-- When boot.classpath.j2se* 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.util.Objects" 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"
+  />
   
   <!-- Set up version/timestamp filters and the version property: -->
   <tstamp>
@@ -192,9 +201,16 @@
       -->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 <!--
+      -->the &lt;projectDir>/build.properties file, or wherever you <!--
+      -->set it.<!--
+    --></fail>
     <echo level="info"><!--
       -->Using boot classpaths:<!--
       -->Java 7: ${boot.classpath.j2se1.7}; <!--
+      -->Java 8: ${boot.classpath.j2se1.8}; <!--
     --></echo>
 
     <!-- Comment out @SuppressFBWarnings, as it causes compilation warnings in dependent Gradle projects -->    
@@ -226,7 +242,8 @@
       classpathref="ivy.dep"
       bootclasspath="${boot.classpath.j2se1.7}"
       excludes="
-    	org/apache/freemarker/servlet/**"
+        org/apache/freemarker/core/_Java?*Impl.java,
+        org/apache/freemarker/servlet/**"
     >
       <src>
         <pathelement location="build/src-main-java-filtered" />
@@ -234,6 +251,15 @@
       </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="org/apache/freemarker/core/_Java8Impl.java"
+    />
+    
     <rmic
       base="build/classes" includes="org/apache/freemarker/core/debug/impl/Rmi*Impl.class"
       classpathref="ivy.dep"
@@ -282,11 +308,11 @@
   
     <ivy:cachepath conf="build.test" pathid="ivy.dep.build.test" />
     <javac srcdir="src/test/java" destdir="build/test-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"
       classpath="build/classes"
       classpathref="ivy.dep.build.test"
-      bootclasspath="${boot.classpath.j2se1.7}"
+      bootclasspath="${boot.classpath.j2se1.8}"
     />
     <copy toDir="build/test-classes">
       <fileset dir="src/test/resources"

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4f723584/src/main/java/org/apache/freemarker/core/_Java8.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/_Java8.java b/src/main/java/org/apache/freemarker/core/_Java8.java
new file mode 100644
index 0000000..037ef9a
--- /dev/null
+++ b/src/main/java/org/apache/freemarker/core/_Java8.java
@@ -0,0 +1,34 @@
+/*
+ * 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;
+
+import java.lang.reflect.Method;
+
+/**
+ * Used internally only, might changes without notice!
+ * Used for accessing functionality that's only present in Java 6 or later.
+ */
+public interface _Java8 {
+
+    /**
+     * Returns if it's a Java 8 "default method".
+     */
+    boolean isDefaultMethod(Method method);
+}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4f723584/src/main/java/org/apache/freemarker/core/_Java8Impl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/_Java8Impl.java b/src/main/java/org/apache/freemarker/core/_Java8Impl.java
new file mode 100644
index 0000000..9fa40c9
--- /dev/null
+++ b/src/main/java/org/apache/freemarker/core/_Java8Impl.java
@@ -0,0 +1,43 @@
+/*
+ * 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;
+
+import java.lang.reflect.Method;
+
+/**
+ * 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
+@SuppressWarnings("Since15") // For IntelliJ inspection
+public final class _Java8Impl implements _Java8 {
+    
+    public static final _Java8 INSTANCE = new _Java8Impl();
+
+    private _Java8Impl() {
+        // Not meant to be instantiated
+    }
+
+    @Override
+    public boolean isDefaultMethod(Method method) {
+        return method.isDefault();
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/incubator-freemarker/blob/4f723584/src/main/java/org/apache/freemarker/core/util/_Java8.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/util/_Java8.java b/src/main/java/org/apache/freemarker/core/util/_Java8.java
deleted file mode 100644
index 42492bd..0000000
--- a/src/main/java/org/apache/freemarker/core/util/_Java8.java
+++ /dev/null
@@ -1,32 +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.util;
-
-/**
- * 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/4f723584/src/main/java/org/apache/freemarker/core/util/_Java8Impl.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/util/_Java8Impl.java b/src/main/java/org/apache/freemarker/core/util/_Java8Impl.java
deleted file mode 100644
index a0c88bd..0000000
--- a/src/main/java/org/apache/freemarker/core/util/_Java8Impl.java
+++ /dev/null
@@ -1,39 +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.util;
-
-/**
- * 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/4f723584/src/main/java/org/apache/freemarker/core/util/_JavaVersions.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/apache/freemarker/core/util/_JavaVersions.java b/src/main/java/org/apache/freemarker/core/util/_JavaVersions.java
index e0665be..10f79fe 100644
--- a/src/main/java/org/apache/freemarker/core/util/_JavaVersions.java
+++ b/src/main/java/org/apache/freemarker/core/util/_JavaVersions.java
@@ -20,6 +20,7 @@ package org.apache.freemarker.core.util;
 
 import org.apache.freemarker.core.Version;
 import org.apache.freemarker.core._CoreLogs;
+import org.apache.freemarker.core._Java8;
 
 /**
  * Used internally only, might changes without notice!
@@ -60,11 +61,11 @@ public final class _JavaVersions {
         _Java8 java8;
         if (IS_AT_LEAST_8) {
             try {
-                java8 = (_Java8) Class.forName("org.apache.freemarker.core.util._Java8Impl")
+                java8 = (_Java8) Class.forName("org.apache.freemarker.core._Java8Impl")
                         .getField("INSTANCE").get(null);
             } catch (Exception e) {
                 try {
-                    _CoreLogs.RUNTIME.error("Failed to access Java 6 functionality", e);
+                    _CoreLogs.RUNTIME.error("Failed to access Java 8 functionality", e);
                 } catch (Exception e2) {
                     // Suppressed
                 }