You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2018/05/18 10:01:01 UTC

groovy git commit: prepare for additional JDK9+ work

Repository: groovy
Updated Branches:
  refs/heads/master a92a2f96a -> c2cea059f


prepare for additional JDK9+ work


Project: http://git-wip-us.apache.org/repos/asf/groovy/repo
Commit: http://git-wip-us.apache.org/repos/asf/groovy/commit/c2cea059
Tree: http://git-wip-us.apache.org/repos/asf/groovy/tree/c2cea059
Diff: http://git-wip-us.apache.org/repos/asf/groovy/diff/c2cea059

Branch: refs/heads/master
Commit: c2cea059fecc3bc4a2c01adc6a30d2a1508bd64b
Parents: a92a2f9
Author: Daniel Sun <re...@hotmail.com>
Authored: Fri May 18 20:00:56 2018 +1000
Committer: Paul King <pa...@asert.com.au>
Committed: Fri May 18 20:00:56 2018 +1000

----------------------------------------------------------------------
 .../groovy/control/CompilerConfiguration.java   | 24 ++++++++++++++++++--
 ...StaticMethodOverloadCompileStaticTest.groovy |  6 +++--
 2 files changed, 26 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/groovy/blob/c2cea059/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java
----------------------------------------------------------------------
diff --git a/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java b/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java
index 545cc49..1b0e220 100644
--- a/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java
+++ b/src/main/java/org/codehaus/groovy/control/CompilerConfiguration.java
@@ -368,7 +368,7 @@ public class CompilerConfiguration {
     /**
      * Checks if the specified bytecode version string represents a JDK 1.5+ compatible
      * bytecode version.
-     * @param bytecodeVersion the bytecode version string (1.4, 1.5, 1.6, 1.7 or 1.8)
+     * @param bytecodeVersion The parameter can take one of the values in {@link #ALLOWED_JDKS}.
      * @return true if the bytecode version is JDK 1.5+
      */
     public static boolean isPostJDK5(String bytecodeVersion) {
@@ -378,7 +378,7 @@ public class CompilerConfiguration {
     /**
      * Checks if the specified bytecode version string represents a JDK 1.7+ compatible
      * bytecode version.
-     * @param bytecodeVersion the bytecode version string (1.4, 1.5, 1.6, 1.7 or 1.8)
+     * @param bytecodeVersion The parameter can take one of the values in {@link #ALLOWED_JDKS}.
      * @return true if the bytecode version is JDK 1.7+
      */
     public static boolean isPostJDK7(String bytecodeVersion) {
@@ -386,6 +386,26 @@ public class CompilerConfiguration {
     }
 
     /**
+     * Checks if the specified bytecode version string represents a JDK 1.8+ compatible
+     * bytecode version.
+     * @param bytecodeVersion The parameter can take one of the values in {@link #ALLOWED_JDKS}.
+     * @return true if the bytecode version is JDK 1.87+
+     */
+    public static boolean isPostJDK8(String bytecodeVersion) {
+        return new BigDecimal(bytecodeVersion).compareTo(new BigDecimal(JDK8)) >= 0;
+    }
+
+    /**
+     * Checks if the specified bytecode version string represents a JDK 1.8+ compatible
+     * bytecode version.
+     * @param bytecodeVersion The parameter can take one of the values in {@link #ALLOWED_JDKS}.
+     * @return true if the bytecode version is JDK 9.0+
+     */
+    public static boolean isPostJDK9(String bytecodeVersion) {
+        return new BigDecimal(bytecodeVersion).compareTo(new BigDecimal(JDK9)) >= 0;
+    }
+
+    /**
      * Method to configure a CompilerConfiguration by using Properties.
      * For a list of available properties look at {@link #CompilerConfiguration(Properties)}.
      * @param configuration The properties to get flag values from.

http://git-wip-us.apache.org/repos/asf/groovy/blob/c2cea059/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/StaticMethodOverloadCompileStaticTest.groovy
----------------------------------------------------------------------
diff --git a/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/StaticMethodOverloadCompileStaticTest.groovy b/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/StaticMethodOverloadCompileStaticTest.groovy
index c523d15..9cc6d7a 100644
--- a/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/StaticMethodOverloadCompileStaticTest.groovy
+++ b/src/test/org/codehaus/groovy/runtime/methoddispatching/vm8/StaticMethodOverloadCompileStaticTest.groovy
@@ -20,6 +20,8 @@ package org.codehaus.groovy.runtime.methoddispatching.vm8
 
 import groovy.transform.CompileStatic
 
+import static org.codehaus.groovy.control.CompilerConfiguration.isPostJDK9
+
 @CompileStatic
 class StaticMethodOverloadCompileStaticTest extends GroovyTestCase {
     void testOneStaticMethod() {
@@ -46,9 +48,9 @@ class StaticMethodOverloadCompileStaticTest extends GroovyTestCase {
         assert BarThree.foo(0, 1) == "BarThree.foo(0, 1)"
     }
 
-    // FIX_JDK9 JDK9 doesn't like the way we do static methods in interfaces - remove this version
+    // FIX_JDK9 JDK9 (and presumably 10+) doesn't like the way we do static methods in interfaces - remove this version
     // check once we fix the problem
     boolean isJdk9() {
-        new BigDecimal(System.getProperty("java.specification.version")).compareTo(new BigDecimal("9.0")) >= 0
+        isPostJDK9(System.getProperty("java.specification.version"))
     }
 }