jaxp/src/java.xml/share/classes/jdk/xml/internal/SecuritySupport.java
changeset 42247 52fafb950d5a
parent 39907 db51759e3695
child 46174 5611d2529b49
--- a/jaxp/src/java.xml/share/classes/jdk/xml/internal/SecuritySupport.java	Fri Nov 18 10:34:56 2016 +0800
+++ b/jaxp/src/java.xml/share/classes/jdk/xml/internal/SecuritySupport.java	Thu Nov 17 21:49:07 2016 -0800
@@ -83,19 +83,26 @@
     }
 
     /**
-     * Reads boolean type system property.
+     * Reads a system property.
      *
+     * @param <T> the type of the property value
+     * @param type the type of the property value
      * @param propName the name of the property
      * @param defValue the default value
      * @return the value of the property, or the default value of no system
      * property is found
      */
-    public static boolean getJAXPSystemProperty(String propName, boolean defValue) {
+    public static <T> T getJAXPSystemProperty(Class<T> type, String propName, String defValue) {
         String value = getJAXPSystemProperty(propName);
         if (value == null) {
-            return defValue;
+            value = defValue;
         }
-        return Boolean.parseBoolean(value);
+        if (Integer.class.isAssignableFrom(type)) {
+            return type.cast(Integer.parseInt(value));
+        } else if (Boolean.class.isAssignableFrom(type)) {
+            return type.cast(Boolean.parseBoolean(value));
+        }
+        return type.cast(value);
     }
 
     /**