Module system and services directory in META-INF

Jochen Theodorou blackdrag at gmx.org
Wed Dec 27 13:21:30 UTC 2017


On 27.12.2017 13:55, Alan Bateman wrote:
> On 27/12/2017 12:22, Cédric Champeau wrote:
>> :
>>
>> 1. is the spec saying somewhere that no-one should ever use
>> `META-INF/services` for something else than a service for 
>> `ServiceLoader`?
>> If not, then ModuleFinder should probably be patched to recognize that
>> sometimes it's not the case.
> The META-INF/services directory has been used for service configuration 
> files for a long time (I think originally specified in Java SE 1.3). 
> Adding properties files or other resources in that location may cause 
> problems for tools and libraries that scan that location.

At least in the last 4 years nobody bothered reporting a problem with this.

> I haven't read the thread that you linked to but I assume it's about JAR 
> files on the module path that are treated as automatic modules. In that 
> case, the relevant part of the ModuleFinder spec is:
> 
> "The contents of entries starting with META-INF/services/ are assumed to 
> be service configuration files (see ServiceLoader). If the name of a 
> file (that follows META-INF/services/) is a legal class name then it is 
> assumed to be the fully-qualified class name of a service type. The 
> entries in the file are assumed to be the fully-qualified class names of 
> provider classes."

spec by javadoc... takes time getting used to it. At least now I know 
where this is mentioned

>> 2. the 2d aspect of the question is what Jochen described as "would the
>> service loader infrastructure let us unload services".
>>
> Jochen's mail mentions loading modules dynamically so I assume this 
> means module layers. If so then unloading is possible and it works well 
> with services.

If not keeping a reference to layer, class and loader is enough, then I 
am happy ;)

bye Jochen


More information about the jigsaw-dev mailing list