8019622: (sl) ServiceLoadet.next incorrect when creation and usages are in different contexts

Remi Forax forax at univ-mlv.fr
Wed Jul 3 16:24:51 UTC 2013


On 07/03/2013 06:15 PM, Alan Bateman wrote:
>
> When running with a security manager, ServiceLoader isn't currently 
> very predictable when created and used in different contexts. For the 
> ServiceLoader usages in the JDK then isn't a problem because all (bar 
> one or two uninteresting cases) involve creating the ServiceLoader and 
> immediately iterating over the providers. However for other usages 
> then it may be an issue as the iteration over the providers may or may 
> not have the expected permissions. The webrev with the proposed 
> changes is here:
>
> http://cr.openjdk.java.net/~alanb/8019622/webrev/
>
> Mandy - this is one that we've chatted about a few times so you are 
> probably the best to review it (if you have time of course).
>
> -Alan.

Hi Alan,
you can use a method reference instead a lambda here,
so
   PrivilegedAction<Boolean> action = () -> hasNextService();
return AccessController.doPrivileged(action, acc);
can be written
   return AccessController.doPrivileged(this::hasNextService, acc);
(me crossing my fingers in hope that the compiler will not be confused 
by the overloads).

cheers,
Rémi




More information about the core-libs-dev mailing list