Review Request: loading JCE providers using ServiceLoader
Alan Bateman
Alan.Bateman at oracle.com
Tue Aug 14 02:30:55 PDT 2012
On 13/08/2012 20:17, Sean Mullan wrote:
>
> I thought about doing that, just adding them on to the end. But there
> are a few other subtle issues. Right now, if you want to use a JCE
> provider that isn't registered, you instantiate it directly (as I
> showed above). Or you could also instantiate it and use the
> Security.addProvider or insertProviderAt methods to add it to the list
> of registered providers. There are apps doing that today. That code
> may break (addProvider will return -1) if we automatically registered
> all JCE providers that were found by ServiceLoader. So I would rather
> hold off on this and address it later with the ordering of providers.
> We may need to adjust what it actually means for a JCE provider to be
> installed:
I think it would make sense to add them at the end. One could imagine
calling Signature.getInstance(algorithm) and the implementation would
iterate over the configured providers and if none of them support the
algorithm then it will move onto the other installed providers looking
for one that supports this algorithm.
On the dynamic registration via Security.addProvider then I would think
it should be an error for someone to install the provider as a service
provider module and also attempts to register it themselves (and to
register it themselves would require they have some means to instantiate
it, suggesting it exports an API for that). It may be that bundled
providers intended to be dynamically registered just don't declare
themselves as services.
So I think it would be good to re-visit this, not critical for the
initial push of course.
-Alan.
More information about the jigsaw-dev
mailing list