Trusted service?

Wang Weijun at
Fri Aug 22 08:09:53 UTC 2014

On Aug 13, 2014, at 23:31, mark.reinhold at wrote:

> 2014/8/13 7:20 -0700, alan.bateman at
>> The usual thing is to just have a default implementation that is used 
>> when ServiceLoader doesn't locate a useful provider. You'll find many 
>> examples of this in the JDK. In those cases then the default is not 
>> listed in a services configuration file. From what you describe then 
>> this may be what you want too.
>> ServiceLoader does not have a way to configure a preferred provider so 
>> this is one reason why you'll see places where a system property can be 
>> used to configured the preferred implementation.
> Another alternative is to use the ServiceLoader::loadInstalled method,
> which will ignore providers on the application class path.

Great, this works for me.

But why does it need to be called in a doPrivileged() block? Isn't it only about JDK-internal classes/resources?


> - Mark

More information about the core-libs-dev mailing list