Paul,
On 3/10/2012 10:50 PM, Paul Sandoz wrote:
For the benefit of others; for some context see this recent thread:
http://markmail.org/search/?q=openjdk#query:openjdk%20list%3Anet.java.openjdk.core-libs-dev%20order%3Adate-backward+page:2+mid:inod424lqbey5fms+state:results
Basically ServiceLoader is treating a null CL parameter as the system CL for
loading the META-INF/services resources file and as the bootstrap CL for
loading the classes of class names declared in those resource files.
Which also means that calls to:
ServiceLoader.load(serviceInterface)
ServiceLoader.load(serviceInterface,
Thread.currentThread().getContextClassLoader());
Will behave oddly if the TCCL is null, from the JavaDoc of
Thread.getContextClassLoader():
http://docs.oracle.com/javase/7/docs/api/java/lang/Thread.html#getContextClassLoader()
Returns:
the context ClassLoader for this Thread, or null indicating the system class
loader (or, failing that, the bootstrap class loader)
The @return doc for getContextClassLoader is wrong, or at best
mis-leading. A null return does NOT indicate the system class loader
(which is never null) - it simply means there is no CCL for that thread.
If anything null would represent the bootstrap loader.
David
-----
Paul.