#ServiceLoaderEnhancements

Alan Bateman Alan.Bateman at oracle.com
Thu Sep 15 15:51:35 UTC 2016


On 15/09/2016 07:54, Peter Levart wrote:

> One thing that is not clear is whether the yyy in "provides xxx with 
> yyy" directive of module declaration must be a concrete class and a 
> subtype of service type when the service is obtained via a static 
> method. For example, is the following a valid configuration: Service 
> type A, implementation class B (a subtype of A), static method 
> declared in C (unrelated to A) with return type B (or A or anything 
> between A and B?).
If yyy defines the static factory method then it does not need to be a 
sub-type of xxx, the return type from the public provider() method just 
needs to be xxx or a sub-type of. So the example is okay, no need for C 
to extend/implement A.

I should note that the implementation isn't aligned with this yet but 
there are updates to both javac and SL coming that will align it with 
the current proposal.

-Alan


More information about the jigsaw-dev mailing list