8182482: Module System spec updates

Alan Bateman Alan.Bateman at oracle.com
Tue Jun 20 11:30:20 UTC 2017


On 20/06/2017 11:39, Remi Forax wrote:
> Hi Alan,
> the doc is clearly better.
>
> Can you change
>    A service is a single type, usually an interface or abstract class. A concrete class can be used, but this is not recommended.
> to
>    A service is a single type, usually an interface. An abstract class or a concrete class can be used, but this is not recommended.
>
> An abstract class has a constructor so you can observe when a service implementation is instantiated by the ServiceLoader, which may make the code dependent of the loading order of the service implementations. So using an abstract class for a service implementation is also a bad idea.
>
There shouldn't be any issue using an abstract class as the service. 
Sure, most developers will choose an interface but we have many examples 
where the service type is an abstract class (and there are corner cases 
with security where enforcement isn't possible when using an interface).

The service provider can be abstract class too but only when it defines 
a public static provider method.

I don't understand your point about an abstract class having a 
constructor. If it doesn't a static provider method then it won't 
compile as a module (it won't run either as it can't be instantiated).

-Alan





More information about the jigsaw-dev mailing list