jaxp/src/javax/xml/xpath/XPathFactoryFinder.java
changeset 16953 a44e04deb948
parent 15545 a19e13e7c521
child 17264 3aff554ad461
--- a/jaxp/src/javax/xml/xpath/XPathFactoryFinder.java	Wed Jul 05 18:46:58 2017 +0200
+++ b/jaxp/src/javax/xml/xpath/XPathFactoryFinder.java	Mon Feb 18 11:33:35 2013 -0800
@@ -48,6 +48,7 @@
  * @since 1.5
  */
 class XPathFactoryFinder  {
+    private static final String DEFAULT_PACKAGE = "com.sun.org.apache.xpath.internal";
 
     private static SecuritySupport ss = new SecuritySupport() ;
     /** debug support code. */
@@ -246,18 +247,25 @@
      */
     private Class createClass(String className) {
             Class clazz;
+        // make sure we have access to restricted packages
+        boolean internal = false;
+        if (System.getSecurityManager() != null) {
+            if (className != null && className.startsWith(DEFAULT_PACKAGE)) {
+                internal = true;
+            }
+        }
 
-            // use approprite ClassLoader
-            try {
-                    if (classLoader != null) {
-                            clazz = classLoader.loadClass(className);
-                    } else {
-                            clazz = Class.forName(className);
-                    }
-            } catch (Throwable t) {
-                if(debug)   t.printStackTrace();
-                    return null;
+        // use approprite ClassLoader
+        try {
+            if (classLoader != null && !internal) {
+                    clazz = classLoader.loadClass(className);
+            } else {
+                    clazz = Class.forName(className);
             }
+        } catch (Throwable t) {
+            if(debug)   t.printStackTrace();
+                return null;
+        }
 
             return clazz;
     }