changeset 1489:5adcd54e9d3b

Added eternal java version detection * acinclude.m4: used sophisticated head-cut to determine single number major java version * plugin/icedteanp/IcedTeaNPPlugin.cc: similar * launcher/launchers.in: same
author Jiri Vanek <jvanek@redhat.com>
date Mon, 01 Oct 2018 19:08:34 +0200
parents caad90b359d8
children 2cf2e3479d57
files ChangeLog acinclude.m4 launcher/launchers.in plugin/icedteanp/IcedTeaNPPlugin.cc
diffstat 4 files changed, 32 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Sep 10 17:42:38 2018 +0200
+++ b/ChangeLog	Mon Oct 01 19:08:34 2018 +0200
@@ -1,3 +1,10 @@
+2018-10-01  Fridrich Strba  <fridrich.strba@suse.com>
+
+	Added eternal java version detection
+	* acinclude.m4: used sophisticated head-cut to determine single number major java version
+	* plugin/icedteanp/IcedTeaNPPlugin.cc: similar
+	* launcher/launchers.in: same
+
 2018-09-05  Jiri Vanek <jvanek@redhat.com>
 
 	* launcher/launchers.in: inverted logic to detect modular jdk.
--- a/acinclude.m4	Mon Sep 10 17:42:38 2018 +0200
+++ b/acinclude.m4	Mon Oct 01 19:08:34 2018 +0200
@@ -795,10 +795,16 @@
 [
   AC_REQUIRE([IT_FIND_JAVA])
   AC_MSG_CHECKING([JDK version])
-  JAVA_VERSION=`$JAVA -version 2>&1`
+  JAVA_VERSION=`$JAVA -version 2>&1 | head -n 1 | cut -d'-' -f1 | cut -d'"' -f2 | cut -d'.' -f1`
+  if test "${JAVA_VERSION}" -eq "1"; then
+    JAVA_VERSION=`$JAVA -version 2>&1 | head -n 1 | cut -d'-' -f1 | cut -d'"' -f2 | cut -d'.' -f2`
+  fi
   AC_MSG_RESULT($JAVA_VERSION)
-  HAVE_JAVA8=`if echo $JAVA_VERSION | grep -q -e 1.8.0 ; then echo yes ; fi`
-  HAVE_JAVA9=`if echo $JAVA_VERSION | grep -q -e 1.9.0 -e \"9 -e "build 9" ; then echo yes ; fi `
+  if test "${JAVA_VERSION}" -eq "8"; then
+    HAVE_JAVA8="yes"
+  elif test "$JAVA_VERSION" -ge "9"; then
+    HAVE_JAVA9="yes"
+  fi
   if test -z "$HAVE_JAVA8" -a -z "$HAVE_JAVA9"; then
     AC_MSG_ERROR([JDK8 or newer is required, detected was: $JAVA_VERSION])
   fi
--- a/launcher/launchers.in	Mon Sep 10 17:42:38 2018 +0200
+++ b/launcher/launchers.in	Mon Oct 01 19:08:34 2018 +0200
@@ -37,9 +37,13 @@
   LAUNCHER_BOOTCLASSPATH="$LAUNCHER_BOOTCLASSPATH:@JRE@/$NASHORN"
 fi;
 
-MODULAR_JDK="YES"
-if ${JAVA} -version 2>&1 | grep -q "version \"1.8.0" ; then
-  MODULAR_JDK="NO"
+MODULAR_JDK="NO"
+version=`${JAVA} -version 2>&1 | head -n 1 | cut -d'-' -f1 | cut -d'"' -f2 | cut -d'.' -f1`
+if [ $version -eq "1" ]; then
+  version=`${JAVA} -version 2>&1 | head -n 1 | cut -d'-' -f1 | cut -d'"' -f2 | cut -d'.' -f2`
+fi
+if [ $version -ge "9" ]; then
+  MODULAR_JDK="YES"
 fi
 
 JAVA_ARGS=( )
--- a/plugin/icedteanp/IcedTeaNPPlugin.cc	Mon Sep 10 17:42:38 2018 +0200
+++ b/plugin/icedteanp/IcedTeaNPPlugin.cc	Mon Oct 01 19:08:34 2018 +0200
@@ -1562,11 +1562,15 @@
   command_line[2] = NULL;
 
   if ( standard_error != NULL ){
-    if(strstr(standard_error, "\"9") != NULL) {
-      PLUGIN_DEBUG ("detected 9\n");
-      PLUGIN_DEBUG ("plugin_get_java_version return\n");
-      return 9;
-    }
+    int major = 0;
+    int minor = 0;
+    sscanf(standard_error, "%*s %*s \"%d.%d", &major, &minor);
+    if (major == 1)
+      major = minor;
+
+    PLUGIN_DEBUG ("detected version %d\n", major);
+    PLUGIN_DEBUG ("plugin_get_java_version return\n");
+    return major;
   }
   PLUGIN_DEBUG ("detected 8 (or generally non nine)\n");
   PLUGIN_DEBUG ("plugin_get_java_version return\n");