What is the module scope of Service Loader?

mark.reinhold at oracle.com mark.reinhold at oracle.com
Mon Oct 5 18:58:23 UTC 2015

2015/9/28 10:01 -0700, peter.kriens at aqute.biz:
> It is not clear to me from the description how Service Loader finds
> implementation classes. For example DriverManager.getDrivers() returns
> a list of all _installed_ drivers. It is not clear to me from which
> modules these drivers are loaded.
> * Is this system wide? 
> * Just the modules the caller can read? 
> * The modules the java.sql module can read?

No to all three.  Readability does not affect service-provider lookup.

The existing class-loader-based methods in ServiceLoader will continue to
work as before: They will search for providers known to the given (or
implied) class loader, and then its parent, etc., regardless of which
modules they're in.  An existing method such as DriverManager::getDrivers
will work as before, except that it will be able to locate providers on
the application module path as well as on the class path.

- Mark

More information about the jpms-spec-experts mailing list