Mercurial > hg > release > icedtea7-forest-2.5 > jaxp
changeset 887:5592b0c44617 jdk7u55-b05 jdk7u65-b00
8031330: Refactor ObjectFactory
Reviewed-by: joehw
author | aefimov |
---|---|
date | Thu, 16 Jan 2014 12:56:28 +0400 |
parents | 269625fabc9f |
children | c59d71409008 de9e813dadfc |
files | src/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java src/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java |
diffstat | 2 files changed, 12 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/src/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java Mon Jan 13 16:14:48 2014 -0800 +++ b/src/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java Thu Jan 16 12:56:28 2014 +0400 @@ -54,8 +54,8 @@ // // Constants // - private static final String XALAN_INTERNAL = "com.sun.org.apache.xalan.internal"; - private static final String XERCES_INTERNAL = "com.sun.org.apache.xerces.internal"; + private static final String JAXP_INTERNAL = "com.sun.org.apache"; + private static final String STAX_INTERNAL = "com.sun.xml.internal"; // name of default properties file to look for in JDK's jre/lib directory private static final String DEFAULT_PROPERTIES_FILENAME = @@ -497,12 +497,8 @@ public static Class findProviderClass(String className, boolean doFallback) throws ClassNotFoundException, ConfigurationError { - if (System.getSecurityManager()!=null) { - return Class.forName(className); - } else { - return findProviderClass (className, + return findProviderClass (className, findClassLoader (), doFallback); - } } /** @@ -517,8 +513,8 @@ SecurityManager security = System.getSecurityManager(); try{ if (security != null){ - if (className.startsWith(XALAN_INTERNAL) || - className.startsWith(XERCES_INTERNAL)) { + if (className.startsWith(JAXP_INTERNAL) || + className.startsWith(STAX_INTERNAL)) { cl = null; } else { final int lastDot = className.lastIndexOf("."); @@ -533,16 +529,7 @@ Class providerClass; if (cl == null) { - // XXX Use the bootstrap ClassLoader. There is no way to - // load a class using the bootstrap ClassLoader that works - // in both JDK 1.1 and Java 2. However, this should still - // work b/c the following should be true: - // - // (cl == null) iff current ClassLoader == null - // - // Thus Class.forName(String) will use the current - // ClassLoader which will be the bootstrap ClassLoader. - providerClass = Class.forName(className); + providerClass = Class.forName(className, false, ObjectFactory.class.getClassLoader()); } else { try { providerClass = cl.loadClass(className);
--- a/src/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java Mon Jan 13 16:14:48 2014 -0800 +++ b/src/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java Thu Jan 16 12:56:28 2014 +0400 @@ -48,7 +48,8 @@ // // Constants // - private static final String DEFAULT_INTERNAL_CLASSES = "com.sun.org.apache."; + private static final String JAXP_INTERNAL = "com.sun.org.apache"; + private static final String STAX_INTERNAL = "com.sun.xml.internal"; // name of default properties file to look for in JDK's jre/lib directory private static final String DEFAULT_PROPERTIES_FILENAME = "xerces.properties"; @@ -288,12 +289,8 @@ public static Class findProviderClass(String className, boolean doFallback) throws ClassNotFoundException, ConfigurationError { - if (System.getSecurityManager()!=null) { - return Class.forName(className); - } else { - return findProviderClass (className, + return findProviderClass (className, findClassLoader (), doFallback); - } } /** * Find a Class using the specified ClassLoader @@ -306,7 +303,8 @@ //restrict the access to package as speicified in java.security policy SecurityManager security = System.getSecurityManager(); if (security != null) { - if (className.startsWith(DEFAULT_INTERNAL_CLASSES)) { + if (className.startsWith(JAXP_INTERNAL) || + className.startsWith(STAX_INTERNAL)) { cl = null; } else { final int lastDot = className.lastIndexOf("."); @@ -318,7 +316,7 @@ Class providerClass; if (cl == null) { //use the bootstrap ClassLoader. - providerClass = Class.forName(className); + providerClass = Class.forName(className, false, ObjectFactory.class.getClassLoader()); } else { try { providerClass = cl.loadClass(className);