8027973: Error in the documentation for newFactory method of the javax.xml.stream factories

Reviewed-by: alanb, dfuchs, lancea, rriggs
This commit is contained in:
Joe Wang 2013-12-04 00:17:12 -08:00
parent 9d65d79487
commit fcc3014ea5
4 changed files with 35 additions and 18 deletions

View File

@ -262,9 +262,7 @@ class FactoryFinder {
}
if (systemProp != null) {
dPrint("found system property, value=" + systemProp);
// There's a bug here - because 'cl' is ignored.
// This will be handled separately.
return newInstance(type, systemProp, null, true);
return newInstance(type, systemProp, cl, true);
}
}
catch (SecurityException se) {
@ -303,9 +301,7 @@ class FactoryFinder {
if (factoryClassName != null) {
dPrint("found in " + configFile + " value=" + factoryClassName);
// There's a bug here - because 'cl' is ignored.
// This will be handled separately.
return newInstance(type, factoryClassName, null, true);
return newInstance(type, factoryClassName, cl, true);
}
}
catch (Exception ex) {
@ -314,7 +310,7 @@ class FactoryFinder {
if (type.getName().equals(factoryId)) {
// Try Jar Service Provider Mechanism
final T provider = findServiceProvider(type);
final T provider = findServiceProvider(type, cl);
if (provider != null) {
return provider;
}
@ -340,12 +336,18 @@ class FactoryFinder {
*
* @return instance of provider class if found or null
*/
private static <T> T findServiceProvider(final Class<T> type) {
private static <T> T findServiceProvider(final Class<T> type, final ClassLoader cl) {
try {
return AccessController.doPrivileged(new PrivilegedAction<T>() {
@Override
public T run() {
final ServiceLoader<T> serviceLoader = ServiceLoader.load(type);
final ServiceLoader<T> serviceLoader;
if (cl == null) {
//the current thread's context class loader
serviceLoader = ServiceLoader.load(type);
} else {
serviceLoader = ServiceLoader.load(type, cl);
}
final Iterator<T> iterator = serviceLoader.iterator();
if (iterator.hasNext()) {
return iterator.next();

View File

@ -158,9 +158,10 @@ public abstract class XMLEventFactory {
* If {@code factoryId} is "javax.xml.stream.XMLEventFactory",
* use the service-provider loading facilities, defined by the
* {@link java.util.ServiceLoader} class, to attempt to locate and load an
* implementation of the service using the {@linkplain
* java.util.ServiceLoader#load(java.lang.Class) default loading mechanism}:
* the service-provider loading facility will use the {@linkplain
* implementation of the service using the specified {@code ClassLoader}.
* If {@code classLoader} is null, the {@linkplain
* java.util.ServiceLoader#load(java.lang.Class) default loading mechanism} will apply:
* That is, the service-provider loading facility will use the {@linkplain
* java.lang.Thread#getContextClassLoader() current thread's context class loader}
* to attempt to load the service. If the context class
* loader is null, the {@linkplain
@ -179,6 +180,10 @@ public abstract class XMLEventFactory {
* to the deprecated method.
* </p>
*
* @apiNote The parameter factoryId defined here is inconsistent with that
* of other JAXP factories where the first parameter is fully qualified
* factory class name that provides implementation of the factory.
*
* @param factoryId Name of the factory to find, same as
* a property name
* @param classLoader classLoader to use

View File

@ -248,9 +248,10 @@ public abstract class XMLInputFactory {
* If {@code factoryId} is "javax.xml.stream.XMLInputFactory",
* use the service-provider loading facilities, defined by the
* {@link java.util.ServiceLoader} class, to attempt to locate and load an
* implementation of the service using the {@linkplain
* java.util.ServiceLoader#load(java.lang.Class) default loading mechanism}:
* the service-provider loading facility will use the {@linkplain
* implementation of the service using the specified {@code ClassLoader}.
* If {@code classLoader} is null, the {@linkplain
* java.util.ServiceLoader#load(java.lang.Class) default loading mechanism} will apply:
* That is, the service-provider loading facility will use the {@linkplain
* java.lang.Thread#getContextClassLoader() current thread's context class loader}
* to attempt to load the service. If the context class
* loader is null, the {@linkplain
@ -269,6 +270,10 @@ public abstract class XMLInputFactory {
* to the deprecated method.
* </p>
*
* @apiNote The parameter factoryId defined here is inconsistent with that
* of other JAXP factories where the first parameter is fully qualified
* factory class name that provides implementation of the factory.
*
* @param factoryId Name of the factory to find, same as
* a property name
* @param classLoader classLoader to use

View File

@ -222,9 +222,10 @@ public abstract class XMLOutputFactory {
* If {@code factoryId} is "javax.xml.stream.XMLOutputFactory",
* use the service-provider loading facilities, defined by the
* {@link java.util.ServiceLoader} class, to attempt to locate and load an
* implementation of the service using the {@linkplain
* java.util.ServiceLoader#load(java.lang.Class) default loading mechanism}:
* the service-provider loading facility will use the {@linkplain
* implementation of the service using the specified {@code ClassLoader}.
* If {@code classLoader} is null, the {@linkplain
* java.util.ServiceLoader#load(java.lang.Class) default loading mechanism} will apply:
* That is, the service-provider loading facility will use the {@linkplain
* java.lang.Thread#getContextClassLoader() current thread's context class loader}
* to attempt to load the service. If the context class
* loader is null, the {@linkplain
@ -235,6 +236,10 @@ public abstract class XMLOutputFactory {
* </li>
* </ul>
*
* @apiNote The parameter factoryId defined here is inconsistent with that
* of other JAXP factories where the first parameter is fully qualified
* factory class name that provides implementation of the factory.
*
* <p>
* Note that this is a new method that replaces the deprecated
* {@link #newInstance(java.lang.String, java.lang.ClassLoader)