runtime changes for services

Alan Bateman Alan.Bateman at oracle.com
Thu Feb 9 09:06:08 PST 2012


I'd like to get a first implementation of the runtime changes to support 
services in so that the API and other dependent changes can be worked 
on. The changes are relatively simple:

1. The class analyzer is updated to emit the requires/provides service 
declarations in the generated module-info files (see [1] for the 
output). The generation of module-info sources is of course short term 
as the module-info sources will ultimately be checked in with the source.

2. The resolver synthesizes an optional dependency on all modules that 
that suppliers of services. The dependency is optional to work with 
permits and also cases where a module has several versions installed and 
some, but not all, provide an implementation of the service. The linker 
is updated so that contexts that provide a service become service 
suppliers to modules that require the service. The set of service 
suppliers is separate to the normal set of supplying contexts and so 
requires additional maps in the configuration.

3. The ServiceLoader changes that were pushed a few days work with this 
patch. In module mode then calls to ServiceLoader.load and loadInstalled 
use the caller's module to determine the services to return. For now if 
invoked from a module that doesn't require the service then a 
ServiceLoader with an empty iterator is returned.

4. The jar tool has been updated so that when it is generates a 
module-info for a JAR file that contains META-INF/services then the 
module-info's provides attribute will declare the services.

That's mostly it, there is clearly lots more to do (on the API in 
particular) but this is a first installation. The webrev with the 
changes is here:

   http://cr.openjdk.java.net/~alanb/jigsaw-services/webrev/index.html

Thanks,
Alan.

[1] http://cr.openjdk.java.net/~alanb/jigsaw-services/moduleinfos.txt





More information about the jigsaw-dev mailing list