changeset 848:2b4a2f136208

8132091: Clean up JAXP code that has dependency on Java version string Reviewed-by: lancea
author joehw
date Thu, 03 Dec 2015 11:42:25 -0800
parents 1cefe0c8447c
children 1f3182529f2c a549eb34d37e
files src/java.xml/share/classes/com/sun/org/apache/xalan/internal/XalanConstants.java src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/Constants.java src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java
diffstat 7 files changed, 16 insertions(+), 71 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/XalanConstants.java	Wed Dec 02 09:36:44 2015 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/XalanConstants.java	Thu Dec 03 11:42:25 2015 -0800
@@ -221,27 +221,4 @@
     public static final String FEATURE_TRUE = "true";
     public static final String FEATURE_FALSE = "false";
 
-    /**
-     * Check if we're in jdk8 or above
-     */
-    public static final boolean IS_JDK8_OR_ABOVE = isJavaVersionAtLeast(8);
-
-    /*
-     * Check the major version of the current JDK against that specified
-     * in the parameter
-     *
-     * In JDK9 the java version string was changed to comply with JEP-223
-     * so this method was modified to handle that new format as well
-     *
-     * @param compareTo a JDK major version to be compared to
-     * @return true if the current major version is the same or above
-     * that represented by the parameter
-     */
-    public static boolean isJavaVersionAtLeast(int compareTo) {
-        String javaVersion = SecuritySupport.getSystemProperty("java.version");
-        javaVersion = (javaVersion.matches("[1-9][0-9]*(\\.(0|[1-9][0-9]*))*\\-.*")) ?
-                          javaVersion.split("-|\\.")[0] :
-                          javaVersion.split("\\.", 3)[1];
-        return Integer.parseInt(javaVersion) >= compareTo;
-    }
 } // class Constants
--- a/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java	Wed Dec 02 09:36:44 2015 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java	Thu Dec 03 11:42:25 2015 -0800
@@ -524,7 +524,7 @@
             _xmlSecurityManager.setSecureProcessing(value);
 
             // set external access restriction when FSP is explicitly set
-            if (value && XalanConstants.IS_JDK8_OR_ABOVE) {
+            if (value) {
                 _xmlSecurityPropertyMgr.setValue(Property.ACCESS_EXTERNAL_DTD,
                         State.FSP, XalanConstants.EXTERNAL_ACCESS_DEFAULT_FSP);
                 _xmlSecurityPropertyMgr.setValue(Property.ACCESS_EXTERNAL_STYLESHEET,
@@ -539,7 +539,6 @@
                 _featureManager.setValue(FeatureManager.Feature.ORACLE_ENABLE_EXTENSION_FUNCTION,
                         FeaturePropertyBase.State.FSP, XalanConstants.FEATURE_FALSE);
             }
-            return;
         }
         else if (name.equals(XalanConstants.ORACLE_FEATURE_SERVICE_MECHANISM)) {
             //in secure mode, let _useServicesMechanism be determined by the constructor
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/Constants.java	Wed Dec 02 09:36:44 2015 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/Constants.java	Thu Dec 03 11:42:25 2015 -0800
@@ -203,11 +203,6 @@
      */
     public static final String EXTERNAL_ACCESS_DEFAULT = ACCESS_EXTERNAL_ALL;
 
-    /**
-     * Check if we're in jdk8 or above
-     */
-    public static final boolean IS_JDK8_OR_ABOVE = isJavaVersionAtLeast(8);
-
     //
     // Implementation limits: corresponding System Properties of the above
     // API properties
@@ -856,25 +851,6 @@
         ? new ArrayEnumeration(fgXercesProperties) : fgEmptyEnumeration;
     } // getXercesProperties():Enumeration
 
-    /*
-     * Check the major version of the current JDK against that specified
-     * in the parameter
-     *
-     * In JDK9 the java version string was changed to comply with JEP-223
-     * so this method was modified to handle that new format as well
-     *
-     * @param compareTo a JDK major version to be compared to
-     * @return true if the current major version is the same or above
-     * that represented by the parameter
-     */
-    public static boolean isJavaVersionAtLeast(int compareTo) {
-        String javaVersion = SecuritySupport.getSystemProperty("java.version");
-        javaVersion = (javaVersion.matches("[1-9][0-9]*(\\.(0|[1-9][0-9]*))*\\-.*")) ?
-                          javaVersion.split("-|\\.")[0] :
-                          javaVersion.split("\\.", 3)[1];
-        return Integer.parseInt(javaVersion) >= compareTo;
-    }
-
     //
     // Classes
     //
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java	Wed Dec 02 09:36:44 2015 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/DocumentBuilderImpl.java	Thu Dec 03 11:42:25 2015 -0800
@@ -184,13 +184,11 @@
              */
             if (features != null) {
                 Boolean temp = features.get(XMLConstants.FEATURE_SECURE_PROCESSING);
-                if (temp != null) {
-                    if (temp && Constants.IS_JDK8_OR_ABOVE) {
-                        fSecurityPropertyMgr.setValue(Property.ACCESS_EXTERNAL_DTD,
-                                State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
-                        fSecurityPropertyMgr.setValue(Property.ACCESS_EXTERNAL_SCHEMA,
-                                State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
-                    }
+                if (temp != null && temp) {
+                    fSecurityPropertyMgr.setValue(Property.ACCESS_EXTERNAL_DTD,
+                            State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
+                    fSecurityPropertyMgr.setValue(Property.ACCESS_EXTERNAL_SCHEMA,
+                            State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
                 }
             }
         }
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java	Wed Dec 02 09:36:44 2015 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/SAXParserImpl.java	Thu Dec 03 11:42:25 2015 -0800
@@ -164,14 +164,11 @@
             if (features != null) {
 
                 Boolean temp = features.get(XMLConstants.FEATURE_SECURE_PROCESSING);
-                if (temp != null) {
-                    if (temp && Constants.IS_JDK8_OR_ABOVE) {
-                        fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD,
-                                XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
-                        fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA,
-                                XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
-
-                    }
+                if (temp != null && temp) {
+                    fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD,
+                            XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
+                    fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA,
+                            XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
                 }
             }
         }
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java	Wed Dec 02 09:36:44 2015 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaFactory.java	Thu Dec 03 11:42:25 2015 -0800
@@ -427,12 +427,10 @@
 
             fSecurityManager.setSecureProcessing(value);
             if (value) {
-                if (Constants.IS_JDK8_OR_ABOVE) {
-                    fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD,
-                            XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
-                    fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA,
-                            XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
-                }
+                fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD,
+                        XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
+                fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA,
+                        XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
             }
 
             fXMLSchemaLoader.setProperty(SECURITY_MANAGER, fSecurityManager);
--- a/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java	Wed Dec 02 09:36:44 2015 -0800
+++ b/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/jaxp/validation/XMLSchemaValidatorComponentManager.java	Thu Dec 03 11:42:25 2015 -0800
@@ -364,7 +364,7 @@
             fInitSecurityManager.setSecureProcessing(value);
             setProperty(SECURITY_MANAGER, fInitSecurityManager);
 
-            if (value && Constants.IS_JDK8_OR_ABOVE) {
+            if (value) {
                 fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_DTD,
                         XMLSecurityPropertyManager.State.FSP, Constants.EXTERNAL_ACCESS_DEFAULT_FSP);
                 fSecurityPropertyMgr.setValue(XMLSecurityPropertyManager.Property.ACCESS_EXTERNAL_SCHEMA,