Order of Services was: Still driving off the cliff
Jaroslav Tulach
jaroslav.tulach at oracle.com
Thu Feb 23 07:38:35 PST 2012
>## Alan wrote on 23. 2. 2012 13:16:14 ##<
> service. Clearly if someone installs another module that also provides a
> SelectorProvider implementation then it's like installing into the
> extensions directory in the current world; one will be chosen and
> there's a way to override it. In the implementation then the order is
> stable and doesn't change between runs.
NetBeans solves problem this by positioning. The
http://bits.netbeans.org/dev/javadoc/org-openide-util-
lookup/org/openide/util/lookup/ServiceProvider.html
annotation (that generates the META-INF/services/xyz file) has attribute
position.
ServiceLoader could be honor such position indicator and sort services
accordingly.
> As I said, I think ServiceLoader has to change.
> The load(Class) method is specified to use the
> threadContextClassLoader but what if that has been set to null or
> ClassLoader.getSystemClassLoader
NetBeans solves[1] this problem by registering special Thread.cCL that can see
classes from all enabled modules in the running VM. Thus by default using
ServiceLoader.load finds all services provided by all enabled modules.
> On the thread context class loader then my view is that it was a
> mistake. It's been a continuous source of problems, security issues
> included.
-jt
[1] Sure, unless somebody calls Thread.setCCL.
More information about the jigsaw-dev
mailing list