RFR [JDK8]: 7169894: JAXP Plugability Layer: using service loader

Joe Wang huizhe.wang at oracle.com
Wed Aug 29 23:08:13 UTC 2012

I actually updated the webrev yesterday with your suggestion.

Recall our discussions back in June, the suggestion was to delegate to 
the ServiceLoader, e.g. ServiceLoader.load(serviceClass). The rational 
was that the ServiceLoader uses context and then bootstrap class loader.

The spec for public static <S> ServiceLoader<S> load(Class<S> service, 
ClassLoader loader) states:
loader - The class loader to be used to load provider-configuration 
files and provider classes, or null if the system class loader (or, 
failing that, the bootstrap class loader) is to be used

This is different. In JAXP, null is recognized as bootstrap classloader, 
but the ServiceLoader actually assumes it as system class loader.  This 
will be a problem, whether or now a classloader is passed to the load 


On 8/29/2012 1:56 AM, Paul Sandoz wrote:
> For the SchemaFactoryFinder there is now a potentially subtle difference in what CL is used to load a class by SL and by SchemaFactoryFinder.createInstance. Previously the same CL was always used whatever the mechanism was used to identify the class name. Errors related to class loaders can be extremely hard to track down hence the conservative position.
> --
> I will say no more on the above:-)
> Paul.
> [*] If a developer can declare a service provider then such linkage errors can potentially occur.

More information about the core-libs-dev mailing list