--- old/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/JVMCIServiceLocator.java 2017-04-28 11:48:40.000000000 +0200 +++ new/src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.services/src/jdk/vm/ci/services/JVMCIServiceLocator.java 2017-04-28 11:48:40.000000000 +0200 @@ -24,12 +24,15 @@ import java.util.ArrayList; import java.util.List; +import java.util.ServiceLoader; + +import jdk.vm.ci.services.internal.ReflectionAccessJDK; /** * Service-provider class for the runtime to locate providers of JVMCI services where the latter are - * not in packages exported by the JVMCI module. As part of instantiating - * {@link JVMCIServiceLocator}, all JVMCI packages will be {@linkplain Services#exportJVMCITo(Class) - * exported} to the module defining the class of the instantiated object. + * not in packages exported by the JVMCI module. As part of instantiating a + * {@link JVMCIServiceLocator}, all JVMCI packages will be opened to the module defining the class + * of the instantiated object. * * While the {@link #getProvider(Class)} method can be used directly, it's usually easier to use * {@link #getProviders(Class)}. @@ -49,30 +52,39 @@ } /** - * Creates a capability for accessing JVMCI. Once successfully instantiated, JVMCI exports all - * its packages to the module defining the type of this object. + * Creates a capability for accessing JVMCI. Once successfully instantiated, JVMCI opens all its + * packages to the module defining the type of this object. * * @throws SecurityException if a security manager has been installed and it denies * {@link JVMCIPermission} */ protected JVMCIServiceLocator() { this(checkPermission()); - Services.exportJVMCITo(getClass()); + Services.checkJVMCIEnabled(); + ReflectionAccessJDK.openJVMCITo(getClass()); } /** * Gets the provider of the service defined by {@code service} or {@code null} if this object * does not have a provider for {@code service}. */ - public abstract S getProvider(Class service); + protected abstract S getProvider(Class service); /** - * Gets the providers of the service defined by {@code service} by querying the - * {@link JVMCIServiceLocator} providers obtained by {@link Services#load(Class)}. + * Gets the providers of the service defined by {@code service} by querying the available + * {@link JVMCIServiceLocator} providers. + * + * @throws SecurityException if a security manager is present and it denies + * {@link JVMCIPermission} */ public static List getProviders(Class service) { + Services.checkJVMCIEnabled(); + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission(new JVMCIPermission()); + } List providers = new ArrayList<>(); - for (JVMCIServiceLocator access : Services.load(JVMCIServiceLocator.class)) { + for (JVMCIServiceLocator access : ServiceLoader.load(JVMCIServiceLocator.class, ClassLoader.getSystemClassLoader())) { S provider = access.getProvider(service); if (provider != null) { providers.add(provider);