diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/image/DisallowedImageHeapObjects.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/image/DisallowedImageHeapObjects.java index 7cd03ceed323..125efc0dba22 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/image/DisallowedImageHeapObjects.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/image/DisallowedImageHeapObjects.java @@ -81,8 +81,8 @@ public static void check(Object obj, DisallowedObjectReporter reporter) { // allowed unless the thread is mounted, in which case it references its carrier // thread and fails } else if (asThread.getState() != Thread.State.NEW && asThread.getState() != Thread.State.TERMINATED) { - throw reporter.raise("Detected a started Thread in the image heap. " + - "Threads running in the image generator are no longer running at image runtime.", + throw reporter.raise("Detected a started Thread in the image heap. Thread name: " + asThread.getName() + + ". Threads running in the image generator are no longer running at image runtime.", asThread, "Prevent threads from starting during image generation, or a started thread from being included in the image."); } } diff --git a/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalSubstitutions.java b/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalSubstitutions.java index 53f8025b360f..371c02f56871 100644 --- a/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalSubstitutions.java +++ b/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalSubstitutions.java @@ -24,6 +24,7 @@ */ package com.oracle.svm.graal.hotspot.libgraal; +import java.lang.ref.ReferenceQueue; import java.util.Map; import com.oracle.svm.core.annotate.Alias; @@ -40,7 +41,8 @@ public final class LibGraalSubstitutions { @TargetClass(value = Services.class, onlyWith = LibGraalFeature.IsEnabled.class) final class Target_jdk_vm_ci_services_Services { // Checkstyle: stop - @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias, isFinal = true)// + @Alias // + @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.FromAlias, isFinal = true)// public static boolean IS_IN_NATIVE_IMAGE = true; // Checkstyle: resume @@ -49,13 +51,22 @@ final class Target_jdk_vm_ci_services_Services { * requires a larger JVMCI change because the annotation is not visible in that project, so we * use this substitution instead. */ - @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) // + @Alias // + @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.Reset) // private static Map savedProperties; } +@TargetClass(className = "jdk.vm.ci.hotspot.Cleaner", onlyWith = LibGraalFeature.IsEnabled.class) +final class Target_jdk_vm_ci_hotspot_Cleaner { + @Alias // + @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.NewInstance, isFinal = true, declClass = ReferenceQueue.class)// + private static ReferenceQueue queue; +} + @TargetClass(className = "jdk.vm.ci.hotspot.HotSpotJDKReflection", onlyWith = LibGraalFeature.IsEnabled.class) final class Target_jdk_vm_ci_hotspot_HotSpotJDKReflection { - @Alias @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.None)// + @Alias // + @RecomputeFieldValue(kind = RecomputeFieldValue.Kind.None)// private long oopSizeOffset; } diff --git a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/hosted/GraalGraphObjectReplacer.java b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/hosted/GraalGraphObjectReplacer.java index 3b7474c85ba4..6ede186211f4 100644 --- a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/hosted/GraalGraphObjectReplacer.java +++ b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/hosted/GraalGraphObjectReplacer.java @@ -112,6 +112,8 @@ public class GraalGraphObjectReplacer implements Function { private final Field substrateTypeRawAllInstanceFieldsField; private final Field substrateMethodImplementationsField; + private final Class jvmciCleanerClass = ReflectionUtil.lookupClass(false, "jdk.vm.ci.hotspot.Cleaner"); + /** * Tracks whether it is legal to create new types. */ @@ -160,7 +162,7 @@ public Object apply(Object source) { HotSpotBackendFactory factory = (HotSpotBackendFactory) source; Architecture hostArch = HotSpotJVMCIRuntime.runtime().getHostJVMCIBackend().getTarget().arch; if (!factory.getArchitecture().equals(hostArch.getClass())) { - throw new UnsupportedFeatureException("Non-host archtecture HotSpotBackendFactory should not appear in the image: " + source); + throw new UnsupportedFeatureException("Non-host architecture HotSpotBackendFactory should not appear in the image: " + source); } } else if (source instanceof GraalRuntime) { dest = sGraalRuntime; @@ -201,7 +203,11 @@ public Object apply(Object source) { } assert dest != null; - String className = dest.getClass().getName(); + Class destClass = dest.getClass(); + if (jvmciCleanerClass.isAssignableFrom(destClass)) { + throw new UnsupportedFeatureException(jvmciCleanerClass.getName() + " objects should not appear in the image: " + source); + } + String className = destClass.getName(); assert SubstrateUtil.isBuildingLibgraal() || !className.contains(".hotspot.") || className.contains(".svm.jtt.hotspot.") : "HotSpot object in image " + className; assert !className.contains(".graal.reachability") : "Analysis meta object in image " + className; assert !className.contains(".pointsto.meta.") : "Analysis meta object in image " + className;