Clarification on META-INF/services from SOTMS
    Alan Bateman 
    Alan.Bateman at oracle.com
       
    Thu Mar 17 19:56:53 UTC 2016
    
    
  
On 17/03/2016 18:49, Paul Benedict wrote:
>  From section 4 on Services:
> "The module system could identify service providers by scanning module
> artifacts for META-INF/services resource entries, as the ServiceLoader
> class does today. That a module provides an implementation of a particular
> service is equally fundamental"
>
> My question regards the use of "could" -- a word that indicates
> possibility, not certainty. It's peculiar wording. If the module system
> still uses META-INF/services, then "could" is misleading. So:
>
> 1) Is META-INF/services being planned to go away in the future?
> 2) What is the relationship between META-INF/services and provides/with
> keywords? Who wins in the presence of both?
>
Just to add to Alex's comment.
If an explicit module on the module path has a META-INF/services 
configuration file then it is ignored. The `provides` clauses in the 
module declaration is the only way to declare the service providers. 
There is wording in ServiceLoader javadoc on this but it needs further 
work, as Alex points out.
It may be that a JAR file has both a module-info.java and service 
configuration files. This might arise for libraries that are capable of 
being deployed as both modules and regular JAR files on the class path 
(say with JDK 8).
For automatic modules then the service configuration files is used to 
derive the list of service providers in the module. There is wording in 
the ModuleFinder javadoc on that.
-Alan
    
    
More information about the jigsaw-dev
mailing list