< prev index next >
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.serviceprovider/src/org/graalvm/compiler/serviceprovider/GraalServices.java
Print this page
rev 56282 : [mq]: graal
*** 87,103 ****
if (IS_BUILDING_NATIVE_IMAGE) {
synchronized (servicesCache) {
ArrayList<S> providersList = new ArrayList<>();
for (S provider : providers) {
- /*
- * When building libgraal, we want providers that comes from the Graal community
- * and enterprise modules but not those available on the native-image class
- * path.
- */
Module module = provider.getClass().getModule();
! if (module.isNamed()) {
providersList.add(provider);
}
}
providers = providersList;
servicesCache.put(service, providersList);
--- 87,98 ----
if (IS_BUILDING_NATIVE_IMAGE) {
synchronized (servicesCache) {
ArrayList<S> providersList = new ArrayList<>();
for (S provider : providers) {
Module module = provider.getClass().getModule();
! if (isHotSpotGraalModule(module.getName())) {
providersList.add(provider);
}
}
providers = providersList;
servicesCache.put(service, providersList);
*** 106,117 ****
}
return providers;
}
protected static <S> Iterable<S> load0(Class<S> service) {
! Iterable<S> iterable = ServiceLoader.load(service);
return new Iterable<>() {
@Override
public Iterator<S> iterator() {
Iterator<S> iterator = iterable.iterator();
return new Iterator<>() {
--- 101,133 ----
}
return providers;
}
+ /**
+ * Determines if the module named by {@code name} is part of Graal when it is configured as a
+ * HotSpot JIT compiler.
+ */
+ private static boolean isHotSpotGraalModule(String name) {
+ if (name != null) {
+ return name.equals("jdk.internal.vm.compiler") ||
+ name.equals("jdk.internal.vm.compiler.management") ||
+ name.equals("com.oracle.graal.graal_enterprise");
+ }
+ return false;
+ }
+
protected static <S> Iterable<S> load0(Class<S> service) {
! Module module = GraalServices.class.getModule();
! // Graal cannot know all the services used by another module
! // (e.g. enterprise) so dynamically register the service use now.
! if (!module.canUse(service)) {
! module.addUses(service);
! }
!
! ModuleLayer layer = module.getLayer();
! Iterable<S> iterable = ServiceLoader.load(layer, service);
return new Iterable<>() {
@Override
public Iterator<S> iterator() {
Iterator<S> iterator = iterable.iterator();
return new Iterator<>() {
*** 218,227 ****
--- 234,247 ----
/**
* Determines if invoking {@link Object#toString()} on an instance of {@code c} will only run
* trusted code.
*/
public static boolean isToStringTrusted(Class<?> c) {
+ if (IS_IN_NATIVE_IMAGE) {
+ return true;
+ }
+
Module module = c.getModule();
Module jvmciModule = JVMCI_MODULE;
assert jvmciModule.getPackages().contains("jdk.vm.ci.runtime");
if (module == jvmciModule || jvmciModule.isOpen(JVMCI_RUNTIME_PACKAGE, module)) {
// Can access non-statically-exported package in JVMCI
< prev index next >