1111# #
1212# @author Tobias Fischer #
1313# @url https://github.com/tofi86/universalJavaApplicationStub #
14- # @date 2017-11-01 #
14+ # @date 2018-01-07 #
1515# @version 2.1.0 #
1616# #
1717# #################################################################################
@@ -405,8 +405,10 @@ function get_comparable_java_version() {
405405# ###############################################################################
406406function is_valid_requirement_pattern() {
407407 local java_req=$1
408- # first test matches old Java versioning scheme (up to 1.8), second test matches new scheme (starting with 9)
409- if [[ ${java_req} =~ ^1\. [4-8](\. 0)? (\. 0_[0-9]+)? [* +]? $ ]] || [[ ${java_req} =~ ^(9| 1[0-9])(-ea| [* +]| (\. [0-9]+){1,2}[* +]? )? $ ]]; then
408+ java8pattern=' 1\.[4-8](\.0)?(\.0_[0-9]+)?[*+]?'
409+ java9pattern=' (9|1[0-9])(-ea|[*+]|(\.[0-9]+){1,2}[*+]?)?'
410+ # test matches either old Java versioning scheme (up to 1.8) or new scheme (starting with 9)
411+ if [[ ${java_req} =~ ^(${java8pattern} | ${java9pattern} )$ ]]; then
410412 return 0
411413 else
412414 return 1
@@ -463,7 +465,7 @@ function does_java_version_satisfy_requirement() {
463465 return 1
464466 fi
465467
466- # requirement ends with * modifier
468+ # requirement ends with + modifier
467469 # e.g. 1.8+, 9+, 9.1+, 9.2.4+, 10+, 10.1+, 10.1.35+
468470 elif [[ ${java_req} == * + ]] ; then
469471 local java_req_num=$( get_comparable_java_version ${java_req} )
@@ -539,7 +541,7 @@ elif [ ! -z ${JVMVersion} ] ; then
539541
540542 # then additionally check the Oracle JRE plugin whether it's a higher/newer compatible version
541543 if [ -x " ${oracle_jre_plugin} " ] && does_java_version_satisfy_requirement ${oracle_jre_version} ${JVMVersion} ; then
542- this_java_ver=$( get_comparable_java_version $( get_java_version_from_cmd " ${oracle_jre_plugin} " ) )
544+ this_java_ver=$( get_comparable_java_version ${oracle_jre_version} )
543545 # use this compatible version only if the above returned empty or if the version number is higher
544546 if [ -z " ${JAVACMD} " ] || [ ${this_java_ver} -ge ${JAVACMD_version} ] ; then
545547 JAVACMD=" ${oracle_jre_plugin} "
@@ -549,7 +551,7 @@ elif [ ! -z ${JVMVersion} ] ; then
549551
550552 # then additionally check the Apple JRE plugin whether it's a higher/newer compatible version
551553 if [ -x " ${apple_jre_plugin} " ] && does_java_version_satisfy_requirement ${apple_jre_version} ${JVMVersion} ; then
552- this_java_ver=$( get_comparable_java_version $( get_java_version_from_cmd " ${apple_jre_plugin} " ) )
554+ this_java_ver=$( get_comparable_java_version ${apple_jre_version} )
553555 # use this compatible version only if the above returned empty or if the version number is higher
554556 if [ -z " ${JAVACMD} " ] || [ ${this_java_ver} -ge ${JAVACMD_version} ] ; then
555557 JAVACMD=" ${apple_jre_plugin} "
0 commit comments