equal
deleted
inserted
replaced
40 * |
40 * |
41 * @author Santiago.PericasGeertsen@sun.com |
41 * @author Santiago.PericasGeertsen@sun.com |
42 * @author Huizhe.Wang@oracle.com |
42 * @author Huizhe.Wang@oracle.com |
43 */ |
43 */ |
44 class FactoryFinder { |
44 class FactoryFinder { |
45 |
45 private static final String DEFAULT_PACKAGE = "com.sun.org.apache.xerces.internal"; |
46 /** |
46 /** |
47 * Internal debug flag. |
47 * Internal debug flag. |
48 */ |
48 */ |
49 private static boolean debug = false; |
49 private static boolean debug = false; |
50 |
50 |
164 * is needed since DocumentBuilderFactory/SAXParserFactory defined null as context classLoader. |
164 * is needed since DocumentBuilderFactory/SAXParserFactory defined null as context classLoader. |
165 */ |
165 */ |
166 static Object newInstance(String className, ClassLoader cl, boolean doFallback, boolean useBSClsLoader) |
166 static Object newInstance(String className, ClassLoader cl, boolean doFallback, boolean useBSClsLoader) |
167 throws ConfigurationError |
167 throws ConfigurationError |
168 { |
168 { |
|
169 // make sure we have access to restricted packages |
|
170 if (System.getSecurityManager() != null) { |
|
171 if (className != null && className.startsWith(DEFAULT_PACKAGE)) { |
|
172 cl = null; |
|
173 useBSClsLoader = true; |
|
174 } |
|
175 } |
|
176 |
169 try { |
177 try { |
170 Class providerClass = getProviderClass(className, cl, doFallback, useBSClsLoader); |
178 Class providerClass = getProviderClass(className, cl, doFallback, useBSClsLoader); |
171 Object instance = providerClass.newInstance(); |
179 Object instance = providerClass.newInstance(); |
172 if (debug) { // Extra check to avoid computing cl strings |
180 if (debug) { // Extra check to avoid computing cl strings |
173 dPrint("created new instance of " + providerClass + |
181 dPrint("created new instance of " + providerClass + |