changeset 568:41068d69fe3e

Merge
author kizune
date Fri, 13 Dec 2013 22:13:53 +0400
parents 5be9182ceb48 (current diff) 4045edd35e8b (diff)
children f2c9c0f64280
files
diffstat 5 files changed, 36 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Thu Dec 05 16:37:30 2013 +0400
+++ b/.hgtags	Fri Dec 13 22:13:53 2013 +0400
@@ -241,3 +241,4 @@
 c1d234d4f16472a5163464420fa00b25ffa5298a jdk8-b117
 e4e5069250e717defcb556e2f6be291460988c51 jdk8-b118
 69a930376c70beb9877970128bad0f04cb0c6eb1 jdk8-b119
+64d8b228a72cf9082b1a9a881c81188ccffde234 jdk8-b120
--- a/src/javax/xml/stream/FactoryFinder.java	Thu Dec 05 16:37:30 2013 +0400
+++ b/src/javax/xml/stream/FactoryFinder.java	Fri Dec 13 22:13:53 2013 +0400
@@ -262,9 +262,7 @@
             }
             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 @@
 
             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 @@
 
         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 @@
      *
      * @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();
--- a/src/javax/xml/stream/XMLEventFactory.java	Thu Dec 05 16:37:30 2013 +0400
+++ b/src/javax/xml/stream/XMLEventFactory.java	Fri Dec 13 22:13:53 2013 +0400
@@ -158,9 +158,10 @@
    *   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 @@
    * 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
--- a/src/javax/xml/stream/XMLInputFactory.java	Thu Dec 05 16:37:30 2013 +0400
+++ b/src/javax/xml/stream/XMLInputFactory.java	Fri Dec 13 22:13:53 2013 +0400
@@ -248,9 +248,10 @@
    *   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 @@
    * 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
--- a/src/javax/xml/stream/XMLOutputFactory.java	Thu Dec 05 16:37:30 2013 +0400
+++ b/src/javax/xml/stream/XMLOutputFactory.java	Fri Dec 13 22:13:53 2013 +0400
@@ -222,9 +222,10 @@
    *   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 @@
    * </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)