210 211 /** 212 * Feature enableExtensionFunctions 213 */ 214 public static final String ORACLE_ENABLE_EXTENSION_FUNCTION = 215 ORACLE_JAXP_PROPERTY_PREFIX + "enableExtensionFunctions"; 216 public static final String SP_ORACLE_ENABLE_EXTENSION_FUNCTION = "javax.xml.enableExtensionFunctions"; 217 218 /** 219 * Values for a feature 220 */ 221 public static final String FEATURE_TRUE = "true"; 222 public static final String FEATURE_FALSE = "false"; 223 224 /** 225 * Check if we're in jdk8 or above 226 */ 227 public static final boolean IS_JDK8_OR_ABOVE = isJavaVersionAtLeast(8); 228 229 /* 230 * Check the version of the current JDK against that specified in the 231 * parameter 232 * 233 * There is a proposal to change the java version string to: 234 * MAJOR.MINOR.FU.CPU.PSU-BUILDNUMBER_BUGIDNUMBER_OPTIONAL 235 * This method would work with both the current format and that proposed 236 * 237 * @param compareTo a JDK version to be compared to 238 * @return true if the current version is the same or above that represented 239 * by the parameter 240 */ 241 public static boolean isJavaVersionAtLeast(int compareTo) { 242 String javaVersion = SecuritySupport.getSystemProperty("java.version"); 243 String versions[] = javaVersion.split("\\.", 3); 244 if (Integer.parseInt(versions[0]) >= compareTo || 245 Integer.parseInt(versions[1]) >= compareTo) { 246 return true; 247 } 248 return false; 249 } 250 } // class Constants | 210 211 /** 212 * Feature enableExtensionFunctions 213 */ 214 public static final String ORACLE_ENABLE_EXTENSION_FUNCTION = 215 ORACLE_JAXP_PROPERTY_PREFIX + "enableExtensionFunctions"; 216 public static final String SP_ORACLE_ENABLE_EXTENSION_FUNCTION = "javax.xml.enableExtensionFunctions"; 217 218 /** 219 * Values for a feature 220 */ 221 public static final String FEATURE_TRUE = "true"; 222 public static final String FEATURE_FALSE = "false"; 223 224 /** 225 * Check if we're in jdk8 or above 226 */ 227 public static final boolean IS_JDK8_OR_ABOVE = isJavaVersionAtLeast(8); 228 229 /* 230 * Check the major version of the current JDK against that specified 231 * in the parameter 232 * 233 * In JDK9 the java version string was changed to comply with JEP-223 234 * so this method was modified to handle that new format as well 235 * 236 * @param compareTo a JDK major version to be compared to 237 * @return true if the current major version is the same or above 238 * that represented by the parameter 239 */ 240 public static boolean isJavaVersionAtLeast(int compareTo) { 241 String javaVersion = SecuritySupport.getSystemProperty("java.version"); 242 javaVersion = (javaVersion.matches("[1-9][0-9]*(\\.(0|[1-9][0-9]*))*\\-.*")) ? 243 javaVersion.split("-|\\.")[0] : 244 javaVersion.split("\\.", 3)[1]; 245 return Integer.parseInt(javaVersion) >= compareTo; 246 } 247 } // class Constants |