IGNITE-6248 - Throw exception on unsupported Java 1.7 releases.

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

Branch: refs/heads/ignite-6748
Commit: e228ce3600332f1873f7250b7ca2919e2f3607bc
Parents: f0500e2
Author: dkarachentsev <[email protected]>
Authored: Fri Oct 27 11:55:04 2017 +0300
Committer: sboikov <[email protected]>
Committed: Fri Oct 27 11:55:48 2017 +0300

----------------------------------------------------------------------
 .../apache/ignite/IgniteSystemProperties.java   |  6 ++++
 .../org/apache/ignite/internal/IgnitionEx.java  | 34 ++++++++++++++++++--
 2 files changed, 38 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ignite/blob/e228ce36/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java 
b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
index d7d4443..4294c71 100644
--- a/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
+++ b/modules/core/src/main/java/org/apache/ignite/IgniteSystemProperties.java
@@ -656,6 +656,12 @@ public final class IgniteSystemProperties {
     /** Ignite page memory concurrency level. */
     public static final String IGNITE_OFFHEAP_LOCK_CONCURRENCY_LEVEL = 
"IGNITE_OFFHEAP_LOCK_CONCURRENCY_LEVEL";
 
+    /**
+     * Start Ignite on versions of JRE 7 older than 1.7.0_71. For proper work 
it may require
+     * disabling JIT in some places.
+     */
+    public static final String IGNITE_FORCE_START_JAVA7 = 
"IGNITE_FORCE_START_JAVA7";
+
     /** Returns true for system properties only avoiding sending sensitive 
information. */
     private static final IgnitePredicate<Map.Entry<String, String>> 
PROPS_FILTER = new IgnitePredicate<Map.Entry<String, String>>() {
         @Override public boolean apply(final Map.Entry<String, String> entry) {

http://git-wip-us.apache.org/repos/asf/ignite/blob/e228ce36/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
----------------------------------------------------------------------
diff --git 
a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java 
b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
index 67c771b..d84f8a9 100644
--- a/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
+++ b/modules/core/src/main/java/org/apache/ignite/internal/IgnitionEx.java
@@ -118,6 +118,7 @@ import static 
org.apache.ignite.IgniteState.STOPPED_ON_SEGMENTATION;
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_CACHE_CLIENT;
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_CONFIG_URL;
 import static 
org.apache.ignite.IgniteSystemProperties.IGNITE_DEP_MODE_OVERRIDE;
+import static 
org.apache.ignite.IgniteSystemProperties.IGNITE_FORCE_START_JAVA7;
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_LOCAL_HOST;
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_NO_SHUTDOWN_HOOK;
 import static org.apache.ignite.IgniteSystemProperties.IGNITE_RESTART_CODE;
@@ -189,9 +190,38 @@ public class IgnitionEx {
     static {
         // Check 1.8 just in case for forward compatibility.
         if (!U.jdkVersion().contains("1.7") &&
-            !U.jdkVersion().contains("1.8"))
-            throw new IllegalStateException("Ignite requires Java 7 or above. 
Current Java version " +
+            !U.jdkVersion().contains("1.8")) {
+            throw new IllegalStateException("Ignite requires Java 1.7.0_71 or 
above. Current Java version " +
                 "is not supported: " + U.jdkVersion());
+        }
+
+        String jreVer = U.jreVersion();
+
+        if (jreVer.startsWith("1.7")) {
+            int upd = jreVer.indexOf('_');
+            int beta = jreVer.indexOf('-');
+
+            if (beta < 0)
+                beta = jreVer.length();
+
+            if (upd > 0 && beta > 0) {
+                try {
+                    int update = Integer.parseInt(jreVer.substring(upd + 1, 
beta));
+
+                    boolean forceJ7 = 
IgniteSystemProperties.getBoolean(IGNITE_FORCE_START_JAVA7, false);
+
+                    if (update < 71 && !forceJ7) {
+                        throw new IllegalStateException("Ignite requires Java 
1.7.0_71 or above. Current Java version " +
+                            "is not supported: " + jreVer);
+                    }
+                    else if (forceJ7)
+                        System.err.println("Ignite requires Java 1.7.0_71 or 
above. Start on your own risk.");
+                }
+                catch (NumberFormatException ignore) {
+                    // No-op
+                }
+            }
+        }
 
         // To avoid nasty race condition in UUID.randomUUID() in JDK prior to 
6u34.
         // For details please see:

Reply via email to