Reviewer and committer request for 7198496

Paul Sandoz paul.sandoz at
Wed Oct 3 12:50:54 UTC 2012

On Oct 3, 2012, at 2:41 PM, Peter Levart <peter.levart at> wrote:

> I think that in the LazyIterator.hasNext() you still have to check for null loader:
> 337                     if (loader == null)
> 338                         configs = ClassLoader.getSystemResources(fullName);
> 339                     else
> 340                         configs = loader.getResources(fullName);
> Because the ClassLoader.getSystemClassLoader() can return null. In that case, ClassLoader.getSystemResources() delegates just to .getBootstrapResources() which is in sync with later:
> 359                 S p = service.cast(Class.forName(cn, true, loader)
> 360                                    .newInstance());
> when loader is null - i.e. it loads just bootstrap classes.

Yes, thanks, i just caught that silly mistake just before i received your email :-) , the webrev is updated.


For the benefit of others; for some context see this recent thread:

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, Thread.currentThread().getContextClassLoader());

Will behave oddly if the TCCL is null, from the JavaDoc of Thread.getContextClassLoader():
  the context ClassLoader for this Thread, or null indicating the system class loader (or, failing that, the bootstrap class loader)


More information about the core-libs-dev mailing list