This is an automated email from the ASF dual-hosted git repository.

lkishalmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new 5eda3cb  Using java.specification.version to read the version of the 
JDK.
5eda3cb is described below

commit 5eda3cb4da1045b5f9ceaf5f1a5c763cbdcef30a
Author: Jan Lahoda <[email protected]>
AuthorDate: Thu Jan 31 21:37:36 2019 +0100

    Using java.specification.version to read the version of the JDK.
---
 .../modules/gradle/GradleDistributionManager.java       | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git 
a/groovy/gradle/src/org/netbeans/modules/gradle/GradleDistributionManager.java 
b/groovy/gradle/src/org/netbeans/modules/gradle/GradleDistributionManager.java
index 3ad2fba..f21f004 100644
--- 
a/groovy/gradle/src/org/netbeans/modules/gradle/GradleDistributionManager.java
+++ 
b/groovy/gradle/src/org/netbeans/modules/gradle/GradleDistributionManager.java
@@ -55,6 +55,7 @@ import org.json.simple.parser.JSONParser;
 import org.json.simple.parser.ParseException;
 import org.netbeans.api.progress.ProgressHandle;
 import org.netbeans.api.progress.ProgressHandleFactory;
+import org.openide.util.Exceptions;
 import org.openide.util.RequestProcessor;
 
 /**
@@ -78,13 +79,17 @@ public class GradleDistributionManager {
 
     static {
         int ver = 8;
-        String version = System.getProperty("java.version"); //NOI18N
-        int dot = version.indexOf('.');
-        ver = dot > 0 ? Integer.parseInt(version.substring(0,dot)) : 
Integer.parseInt(version);
-        if (ver == 1) {
-            version = version.substring(dot + 1);
-            dot = version.indexOf('.');
+        String version = System.getProperty("java.specification.version", 
System.getProperty("java.version")); //NOI18N
+        try {
+            int dot = version.indexOf('.');
             ver = dot > 0 ? Integer.parseInt(version.substring(0,dot)) : 
Integer.parseInt(version);
+            if (ver == 1) {
+                version = version.substring(dot + 1);
+                dot = version.indexOf('.');
+                ver = dot > 0 ? Integer.parseInt(version.substring(0,dot)) : 
Integer.parseInt(version);
+            }
+        } catch (NumberFormatException ex) {
+            Exceptions.printStackTrace(ex);
         }
         JAVA_VERSION = ver;
     }


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to