This commit is contained in:
Iris Clark 2015-06-29 11:27:36 -07:00
commit 9936506d64
2 changed files with 22 additions and 28 deletions

View File

@ -227,24 +227,21 @@ public final class XalanConstants {
public static final boolean IS_JDK8_OR_ABOVE = isJavaVersionAtLeast(8); public static final boolean IS_JDK8_OR_ABOVE = isJavaVersionAtLeast(8);
/* /*
* Check the version of the current JDK against that specified in the * Check the major version of the current JDK against that specified
* parameter * in the parameter
* *
* There is a proposal to change the java version string to: * In JDK9 the java version string was changed to comply with JEP-223
* MAJOR.MINOR.FU.CPU.PSU-BUILDNUMBER_BUGIDNUMBER_OPTIONAL * so this method was modified to handle that new format as well
* This method would work with both the current format and that proposed
* *
* @param compareTo a JDK version to be compared to * @param compareTo a JDK major version to be compared to
* @return true if the current version is the same or above that represented * @return true if the current major version is the same or above
* by the parameter * that represented by the parameter
*/ */
public static boolean isJavaVersionAtLeast(int compareTo) { public static boolean isJavaVersionAtLeast(int compareTo) {
String javaVersion = SecuritySupport.getSystemProperty("java.version"); String javaVersion = SecuritySupport.getSystemProperty("java.version");
String versions[] = javaVersion.split("\\.", 3); javaVersion = (javaVersion.matches("[1-9][0-9]*(\\.(0|[1-9][0-9]*))*\\-.*")) ?
if (Integer.parseInt(versions[0]) >= compareTo || javaVersion.split("-|\\.")[0] :
Integer.parseInt(versions[1]) >= compareTo) { javaVersion.split("\\.", 3)[1];
return true; return Integer.parseInt(javaVersion) >= compareTo;
}
return false;
} }
} // class Constants } // class Constants

View File

@ -857,25 +857,22 @@ public final class Constants {
} // getXercesProperties():Enumeration } // getXercesProperties():Enumeration
/* /*
* Check the version of the current JDK against that specified in the * Check the major version of the current JDK against that specified
* parameter * in the parameter
* *
* There is a proposal to change the java version string to: * In JDK9 the java version string was changed to comply with JEP-223
* MAJOR.MINOR.FU.CPU.PSU-BUILDNUMBER_BUGIDNUMBER_OPTIONAL * so this method was modified to handle that new format as well
* This method would work with both the current format and that proposed
* *
* @param compareTo a JDK version to be compared to * @param compareTo a JDK major version to be compared to
* @return true if the current version is the same or above that represented * @return true if the current major version is the same or above
* by the parameter * that represented by the parameter
*/ */
public static boolean isJavaVersionAtLeast(int compareTo) { public static boolean isJavaVersionAtLeast(int compareTo) {
String javaVersion = SecuritySupport.getSystemProperty("java.version"); String javaVersion = SecuritySupport.getSystemProperty("java.version");
String versions[] = javaVersion.split("\\.", 3); javaVersion = (javaVersion.matches("[1-9][0-9]*(\\.(0|[1-9][0-9]*))*\\-.*")) ?
if (Integer.parseInt(versions[0]) >= compareTo || javaVersion.split("-|\\.")[0] :
Integer.parseInt(versions[1]) >= compareTo) { javaVersion.split("\\.", 3)[1];
return true; return Integer.parseInt(javaVersion) >= compareTo;
}
return false;
} }
// //