7160380: Sync JDK8 with JAXP 1.4.5

Bring JDK8 up to date to what we have in 7u4

Reviewed-by: lancea, mullan
This commit is contained in:
Joe Wang 2012-04-17 11:17:59 -07:00
parent 60663487f6
commit db4db38876
213 changed files with 5006 additions and 15178 deletions

View file

@ -44,6 +44,7 @@ import java.util.Properties;
* Implementation of {@link XPathFactory#newInstance(String)}.
*
* @author <a href="Kohsuke.Kawaguchi@Sun.com">Kohsuke Kawaguchi</a>
* @version $Revision: 1.7 $, $Date: 2010-11-01 04:36:14 $
* @since 1.5
*/
class XPathFactoryFinder {
@ -68,7 +69,7 @@ class XPathFactoryFinder {
/**
* <p>First time requires initialization overhead.</p>
*/
private static boolean firstTime = true;
private volatile static boolean firstTime = true;
/**
* <p>Conditional debug printing.</p>
@ -163,7 +164,7 @@ class XPathFactoryFinder {
String r = ss.getSystemProperty(propertyName);
if(r!=null) {
debugPrintln("The value is '"+r+"'");
xpathFactory = createInstance(r);
xpathFactory = createInstance(r, true);
if(xpathFactory != null) return xpathFactory;
} else
debugPrintln("The property is undefined.");
@ -198,7 +199,7 @@ class XPathFactoryFinder {
debugPrintln("found " + factoryClassName + " in $java.home/jaxp.properties");
if (factoryClassName != null) {
xpathFactory = createInstance(factoryClassName);
xpathFactory = createInstance(factoryClassName, true);
if(xpathFactory != null){
return xpathFactory;
}
@ -231,7 +232,7 @@ class XPathFactoryFinder {
// platform default
if(uri.equals(XPathFactory.DEFAULT_OBJECT_MODEL_URI)) {
debugPrintln("attempting to use the platform default W3C DOM XPath lib");
return createInstance("com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl");
return createInstance("com.sun.org.apache.xpath.internal.jaxp.XPathFactoryImpl", true);
}
debugPrintln("all things were tried, but none was found. bailing out.");
@ -271,6 +272,9 @@ class XPathFactoryFinder {
* if it fails. Error messages will be printed by this method.
*/
XPathFactory createInstance( String className ) {
return createInstance( className, false );
}
XPathFactory createInstance( String className, boolean useServicesMechanism ) {
XPathFactory xPathFactory = null;
debugPrintln("createInstance(" + className + ")");
@ -285,7 +289,12 @@ class XPathFactoryFinder {
// instantiate Class as a XPathFactory
try {
if (!useServicesMechanism) {
xPathFactory = (XPathFactory) newInstanceNoServiceLoader(clazz);
}
if (xPathFactory == null) {
xPathFactory = (XPathFactory) clazz.newInstance();
}
} catch (ClassCastException classCastException) {
debugPrintln("could not instantiate " + clazz.getName());
if (debug) {
@ -308,6 +317,29 @@ class XPathFactoryFinder {
return xPathFactory;
}
/**
* Try to construct using newXPathFactoryNoServiceLoader
* method if available.
*/
private static Object newInstanceNoServiceLoader(
Class<?> providerClass
) {
// Retain maximum compatibility if no security manager.
if (System.getSecurityManager() == null) {
return null;
}
try {
Method creationMethod =
providerClass.getDeclaredMethod(
"newXPathFactoryNoServiceLoader"
);
return creationMethod.invoke(null, null);
} catch (NoSuchMethodException exc) {
return null;
} catch (Exception exc) {
return null;
}
}
/**
* <p>Look up a value in a property file.</p>
@ -432,7 +464,7 @@ class XPathFactoryFinder {
String factoryClassName = props.getProperty(keyName);
if(factoryClassName != null){
debugPrintln("found "+keyName+" = " + factoryClassName);
return createInstance(factoryClassName);
return createInstance(factoryClassName, true);
} else {
debugPrintln(keyName+" is not in the property file");
return null;