diff --git a/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/AArch64ReservedRegisters.java b/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/AArch64ReservedRegisters.java index 819dbafa70ef..a73327ba69be 100755 --- a/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/AArch64ReservedRegisters.java +++ b/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/AArch64ReservedRegisters.java @@ -28,10 +28,15 @@ import org.graalvm.nativeimage.Platforms; import com.oracle.svm.core.ReservedRegisters; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; import jdk.vm.ci.aarch64.AArch64; import jdk.vm.ci.code.Register; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) public final class AArch64ReservedRegisters extends ReservedRegisters { public static final Register THREAD_REGISTER = AArch64.r28; diff --git a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64ReservedRegisters.java b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64ReservedRegisters.java index 86b5133de600..a6fda9c1d174 100644 --- a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64ReservedRegisters.java +++ b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64ReservedRegisters.java @@ -32,10 +32,15 @@ import org.graalvm.nativeimage.Platforms; import com.oracle.svm.core.ReservedRegisters; +import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import jdk.vm.ci.amd64.AMD64; import jdk.vm.ci.code.Register; +@SingletonTraits(access = AllAccess.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) public final class AMD64ReservedRegisters extends ReservedRegisters { public static final Register THREAD_REGISTER = r15; diff --git a/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/image/LLVMCCompilerInvoker.java b/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/image/LLVMCCompilerInvoker.java index 8ca6bf7648b6..a9dde2708984 100644 --- a/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/image/LLVMCCompilerInvoker.java +++ b/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/image/LLVMCCompilerInvoker.java @@ -28,11 +28,16 @@ import java.nio.file.Path; import java.util.Scanner; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.UserError; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.c.codegen.CCompilerInvoker; import com.oracle.svm.hosted.image.LLVMToolchain; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) public class LLVMCCompilerInvoker extends CCompilerInvoker { public LLVMCCompilerInvoker(Path tempDirectory) { diff --git a/substratevm/src/com.oracle.svm.core.graal.riscv64/src/com/oracle/svm/core/graal/riscv64/RISCV64ReservedRegisters.java b/substratevm/src/com.oracle.svm.core.graal.riscv64/src/com/oracle/svm/core/graal/riscv64/RISCV64ReservedRegisters.java index 17e59be4fa11..e1e1ae6045db 100644 --- a/substratevm/src/com.oracle.svm.core.graal.riscv64/src/com/oracle/svm/core/graal/riscv64/RISCV64ReservedRegisters.java +++ b/substratevm/src/com.oracle.svm.core.graal.riscv64/src/com/oracle/svm/core/graal/riscv64/RISCV64ReservedRegisters.java @@ -28,10 +28,15 @@ import org.graalvm.nativeimage.Platforms; import com.oracle.svm.core.ReservedRegisters; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; import jdk.vm.ci.code.Register; import jdk.vm.ci.riscv64.RISCV64; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) public final class RISCV64ReservedRegisters extends ReservedRegisters { public static final Register THREAD_REGISTER = RISCV64.x23; diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixLogHandler.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixLogHandler.java index 407d6010f02f..37432f1c3bed 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixLogHandler.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixLogHandler.java @@ -38,14 +38,13 @@ import com.oracle.svm.core.log.Log; import com.oracle.svm.core.thread.VMThreads; import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; -import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; import com.oracle.svm.core.traits.BuiltinTraits.RuntimeAccessOnly; import com.oracle.svm.core.traits.BuiltinTraits.SingleLayer; import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.InitialLayerOnly; import com.oracle.svm.core.traits.SingletonTraits; -@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature class PosixLogHandlerFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixVirtualMemoryProvider.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixVirtualMemoryProvider.java index fc4f840f9bf8..ea509a091856 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixVirtualMemoryProvider.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixVirtualMemoryProvider.java @@ -57,7 +57,6 @@ import com.oracle.svm.core.posix.headers.Unistd; import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; -import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; import com.oracle.svm.core.traits.BuiltinTraits.SingleLayer; import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.InitialLayerOnly; @@ -67,7 +66,7 @@ import jdk.graal.compiler.word.Word; -@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature class PosixVirtualMemoryProviderFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinImageSingletonsFeature.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinImageSingletonsFeature.java index a14a39147865..015390ca3bab 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinImageSingletonsFeature.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinImageSingletonsFeature.java @@ -31,11 +31,11 @@ import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; import com.oracle.svm.core.os.ImageHeapProvider; import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; -import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.BuiltinTraits.SingleLayer; import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; import com.oracle.svm.core.traits.SingletonTraits; -@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = Disallowed.class) @AutomaticallyRegisteredFeature class DarwinImageSingletonsFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinPhysicalMemorySupportImpl.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinPhysicalMemorySupportImpl.java index 7e68fb59d37c..4ea4eb154cd5 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinPhysicalMemorySupportImpl.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinPhysicalMemorySupportImpl.java @@ -24,7 +24,6 @@ */ package com.oracle.svm.core.posix.darwin; -import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.nativeimage.c.type.CIntPointer; import org.graalvm.nativeimage.c.type.WordPointer; @@ -37,8 +36,15 @@ import com.oracle.svm.core.log.Log; import com.oracle.svm.core.posix.headers.Sysctl; import com.oracle.svm.core.posix.headers.darwin.DarwinSysctl; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.BuiltinTraits.RuntimeAccessOnly; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; +import jdk.graal.compiler.word.Word; + +@SingletonTraits(access = RuntimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) @AutomaticallyRegisteredImageSingleton(PhysicalMemorySupport.class) class DarwinPhysicalMemorySupportImpl implements PhysicalMemorySupport { diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/DumpLinuxOSInfo.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/DumpLinuxOSInfo.java index 252304b0eb04..b0a9c38169c3 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/DumpLinuxOSInfo.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/DumpLinuxOSInfo.java @@ -41,7 +41,7 @@ import com.oracle.svm.core.log.Log; import com.oracle.svm.core.os.RawFileOperationSupport; import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; -import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.BuiltinTraits.SingleLayer; import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; import com.oracle.svm.core.traits.SingletonTraits; @@ -107,7 +107,7 @@ private static int countLineBytes(CCharPointer buffer, int len) { } } -@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature class DumpLinuxOSInfoFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxImageSingletonsFeature.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxImageSingletonsFeature.java index 0f60a28eaf84..d301ddd6cd4c 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxImageSingletonsFeature.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxImageSingletonsFeature.java @@ -34,11 +34,11 @@ import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; import com.oracle.svm.core.os.ImageHeapProvider; import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; -import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.BuiltinTraits.SingleLayer; import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; import com.oracle.svm.core.traits.SingletonTraits; -@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature class LinuxImageSingletonsFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxPhysicalMemorySupportImpl.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxPhysicalMemorySupportImpl.java index 8b32b9257bd0..4e40c46a59d8 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxPhysicalMemorySupportImpl.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxPhysicalMemorySupportImpl.java @@ -41,10 +41,17 @@ import com.oracle.svm.core.heap.PhysicalMemory.PhysicalMemorySupport; import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; import com.oracle.svm.core.posix.headers.Unistd; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.RuntimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.SingleLayer; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.InitialLayerOnly; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; import jdk.graal.compiler.word.Word; +@SingletonTraits(access = RuntimeAccessOnly.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = InitialLayerOnly.class) public class LinuxPhysicalMemorySupportImpl implements PhysicalMemorySupport { private static final long K = 1024; @@ -119,11 +126,17 @@ private static long parseFirstNumber(String str) { } } +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature class LinuxPhysicalMemorySupportFeature implements InternalFeature { + @Override + public boolean isInConfiguration(IsInConfigurationAccess access) { + return ImageLayerBuildingSupport.firstImageBuild(); + } + @Override public void beforeAnalysis(BeforeAnalysisAccess access) { - if (ImageLayerBuildingSupport.firstImageBuild() && !ImageSingletons.contains(PhysicalMemorySupport.class)) { + if (!ImageSingletons.contains(PhysicalMemorySupport.class)) { ImageSingletons.add(PhysicalMemorySupport.class, new LinuxPhysicalMemorySupportImpl()); } } diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPhysicalMemorySupportImpl.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPhysicalMemorySupportImpl.java index 28e13fbf9a09..cc0fadf90e84 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPhysicalMemorySupportImpl.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPhysicalMemorySupportImpl.java @@ -26,7 +26,6 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; -import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.word.UnsignedWord; @@ -34,8 +33,15 @@ import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.graal.stackvalue.UnsafeStackValue; import com.oracle.svm.core.heap.PhysicalMemory.PhysicalMemorySupport; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.BuiltinTraits.RuntimeAccessOnly; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.windows.headers.SysinfoAPI; +import jdk.graal.compiler.word.Word; + +@SingletonTraits(access = RuntimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) @AutomaticallyRegisteredImageSingleton(PhysicalMemorySupport.class) class WindowsPhysicalMemorySupportImpl implements PhysicalMemorySupport { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/RuntimeAssertionsSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/RuntimeAssertionsSupport.java index b3593cb06a4f..00c64b32d7ae 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/RuntimeAssertionsSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/RuntimeAssertionsSupport.java @@ -24,23 +24,37 @@ */ package com.oracle.svm.core; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.StringJoiner; import java.util.function.Function; -import jdk.graal.compiler.api.replacements.Fold; -import jdk.graal.compiler.options.Option; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +import com.oracle.svm.core.layeredimagesingleton.ImageSingletonLoader; +import com.oracle.svm.core.layeredimagesingleton.ImageSingletonWriter; +import com.oracle.svm.core.layeredimagesingleton.LayeredImageSingleton; +import com.oracle.svm.core.layeredimagesingleton.LayeredImageSingleton.PersistFlags; import com.oracle.svm.core.option.APIOption; -import com.oracle.svm.core.option.HostedOptionKey; import com.oracle.svm.core.option.AccumulatingLocatableMultiOptionValue; -import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +import com.oracle.svm.core.option.HostedOptionKey; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.SingletonLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredCallbacksSupplier; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTrait; +import com.oracle.svm.core.traits.SingletonTraitKind; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; +import jdk.graal.compiler.api.replacements.Fold; +import jdk.graal.compiler.options.Option; + class RuntimeAssertionsOptionTransformer implements Function { private static final String SEPARATOR = ","; @@ -77,9 +91,19 @@ static class Disable extends RuntimeAssertionsOptionTransformer { } @AutomaticallyRegisteredImageSingleton +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = RuntimeAssertionsSupport.LayeredCallbacks.class, layeredInstallationKind = Independent.class) @Platforms(Platform.HOSTED_ONLY.class) public final class RuntimeAssertionsSupport { + private static final String PACKAGE = "package"; + private static final String CLASS = "class"; + + private static final String ASSERTION_STATUS_KEYS = "AssertionStatusKeys"; + private static final String ASSERTION_STATUS_VALUES = "AssertionStatusValues"; + + private static final String DEFAULT_ASSERTION_STATUS = "defaultAssertionStatus"; + private static final String SYSTEM_ASSERTION_STATUS = "systemAssertionStatus"; + public static final char ENABLE_PREFIX = '+'; public static final char DISABLE_PREFIX = '-'; public static final String PACKAGE_SUFFIX = "..."; @@ -201,4 +225,64 @@ public boolean getDefaultAssertionStatus() { public boolean getDefaultSystemAssertionStatus() { return systemAssertionStatus; } + + static class LayeredCallbacks extends SingletonLayeredCallbacksSupplier { + @Override + public SingletonTrait getLayeredCallbacksTrait() { + SingletonLayeredCallbacks action = new SingletonLayeredCallbacks() { + @Override + public LayeredImageSingleton.PersistFlags doPersist(ImageSingletonWriter writer, Object singleton) { + RuntimeAssertionsSupport runtimeAssertionsSupport = (RuntimeAssertionsSupport) singleton; + persistAssertionStatus(writer, PACKAGE, runtimeAssertionsSupport.packageAssertionStatus); + persistAssertionStatus(writer, CLASS, runtimeAssertionsSupport.classAssertionStatus); + writer.writeInt(DEFAULT_ASSERTION_STATUS, runtimeAssertionsSupport.defaultAssertionStatus ? 1 : 0); + writer.writeInt(SYSTEM_ASSERTION_STATUS, runtimeAssertionsSupport.systemAssertionStatus ? 1 : 0); + return PersistFlags.CALLBACK_ON_REGISTRATION; + } + + private void persistAssertionStatus(ImageSingletonWriter writer, String type, Map assertionStatus) { + List keys = new ArrayList<>(); + List values = new ArrayList<>(); + for (var entry : assertionStatus.entrySet()) { + keys.add(entry.getKey()); + values.add(entry.getValue()); + } + writer.writeStringList(type + ASSERTION_STATUS_KEYS, keys); + writer.writeBoolList(type + ASSERTION_STATUS_VALUES, values); + } + + @Override + public void onSingletonRegistration(ImageSingletonLoader loader, Object singleton) { + RuntimeAssertionsSupport runtimeAssertionsSupport = (RuntimeAssertionsSupport) singleton; + checkMaps(loadAssertionStatus(loader, PACKAGE), runtimeAssertionsSupport.packageAssertionStatus); + checkMaps(loadAssertionStatus(loader, CLASS), runtimeAssertionsSupport.classAssertionStatus); + checkBoolean(runtimeAssertionsSupport.defaultAssertionStatus, loader, DEFAULT_ASSERTION_STATUS); + checkBoolean(runtimeAssertionsSupport.systemAssertionStatus, loader, SYSTEM_ASSERTION_STATUS); + } + + private void checkBoolean(boolean currentLayerAssertionStatus, ImageSingletonLoader loader, String assertionStatusKey) { + boolean previousLayerStatus = loader.readInt(assertionStatusKey) == 1; + VMError.guarantee(currentLayerAssertionStatus == previousLayerStatus, "The assertion status is the previous layer was %s, but the assertion status in the current layer is %s", + currentLayerAssertionStatus, previousLayerStatus); + } + + private Map loadAssertionStatus(ImageSingletonLoader loader, String type) { + HashMap result = new HashMap<>(); + var keys = loader.readStringList(type + ASSERTION_STATUS_KEYS); + var values = loader.readBoolList(type + ASSERTION_STATUS_VALUES); + for (int i = 0; i < keys.size(); ++i) { + result.put(keys.get(i), values.get(i)); + } + return result; + } + + public static void checkMaps(Map previousLayerMap, Map currentLayerMap) { + VMError.guarantee(previousLayerMap.equals(currentLayerMap), + "The assertion status maps should be the same across layers, but the map in previous layers is %s and the map in the current layer is %s", + previousLayerMap, currentLayerMap); + } + }; + return new SingletonTrait(SingletonTraitKind.LAYERED_CALLBACKS, action); + } + } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateSegfaultHandler.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateSegfaultHandler.java index 2cfb38335726..8b66b53c68d8 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateSegfaultHandler.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateSegfaultHandler.java @@ -66,7 +66,7 @@ import com.oracle.svm.core.thread.VMThreads.SafepointBehavior; import com.oracle.svm.core.threadlocal.VMThreadLocalSupport; import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; -import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.BuiltinTraits.SingleLayer; import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.util.ReflectionUtil; @@ -76,7 +76,7 @@ import jdk.graal.compiler.options.Option; import jdk.graal.compiler.word.Word; -@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature class SubstrateSegfaultHandlerFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateTargetDescription.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateTargetDescription.java index 07d078a1b665..462647dae63e 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateTargetDescription.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateTargetDescription.java @@ -25,16 +25,32 @@ package com.oracle.svm.core; import java.util.EnumSet; +import java.util.List; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import com.oracle.svm.core.code.RuntimeCodeCache; +import com.oracle.svm.core.layeredimagesingleton.ImageSingletonLoader; +import com.oracle.svm.core.layeredimagesingleton.ImageSingletonWriter; +import com.oracle.svm.core.layeredimagesingleton.LayeredImageSingleton; +import com.oracle.svm.core.layeredimagesingleton.LayeredImageSingleton.PersistFlags; +import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; +import com.oracle.svm.core.traits.SingletonLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredCallbacksSupplier; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTrait; +import com.oracle.svm.core.traits.SingletonTraitKind; +import com.oracle.svm.core.traits.SingletonTraits; +import com.oracle.svm.core.util.VMError; import jdk.vm.ci.code.Architecture; import jdk.vm.ci.code.TargetDescription; +@SingletonTraits(access = AllAccess.class, layeredCallbacks = SubstrateTargetDescription.LayeredCallbacks.class, layeredInstallationKind = Independent.class) public class SubstrateTargetDescription extends TargetDescription { + private static final String RUNTIME_CHECKED_CPU_FEATURES = "runtimeCheckedCPUFeatures"; + @Platforms(Platform.HOSTED_ONLY.class) public static boolean shouldInlineObjectsInImageCode() { return SubstrateOptions.SpawnIsolates.getValue(); @@ -55,4 +71,33 @@ public SubstrateTargetDescription(Architecture arch, boolean isMP, int stackAlig public EnumSet getRuntimeCheckedCPUFeatures() { return runtimeCheckedCPUFeatures; } + + static class LayeredCallbacks extends SingletonLayeredCallbacksSupplier { + @Override + public SingletonTrait getLayeredCallbacksTrait() { + SingletonLayeredCallbacks action = new SingletonLayeredCallbacks() { + @Override + public LayeredImageSingleton.PersistFlags doPersist(ImageSingletonWriter writer, Object singleton) { + SubstrateTargetDescription substrateTargetDescription = (SubstrateTargetDescription) singleton; + writer.writeStringList(RUNTIME_CHECKED_CPU_FEATURES, getCPUFeaturesList(substrateTargetDescription)); + return PersistFlags.CALLBACK_ON_REGISTRATION; + } + + @Override + public void onSingletonRegistration(ImageSingletonLoader loader, Object singleton) { + SubstrateTargetDescription substrateTargetDescription = (SubstrateTargetDescription) singleton; + List previousLayerRuntimeCheckedCPUFeatures = loader.readStringList(RUNTIME_CHECKED_CPU_FEATURES); + List currentLayerRuntimeCheckedCPUFeatures = getCPUFeaturesList(substrateTargetDescription); + VMError.guarantee(previousLayerRuntimeCheckedCPUFeatures.equals(currentLayerRuntimeCheckedCPUFeatures), + "The runtime checked CPU Features should be consistent across layers. The previous layer CPU Features were %s, but the current layer are %s", + previousLayerRuntimeCheckedCPUFeatures, currentLayerRuntimeCheckedCPUFeatures); + } + }; + return new SingletonTrait(SingletonTraitKind.LAYERED_CALLBACKS, action); + } + } + + private static List getCPUFeaturesList(SubstrateTargetDescription substrateTargetDescription) { + return substrateTargetDescription.runtimeCheckedCPUFeatures.stream().map(Enum::toString).toList(); + } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/bootstrap/BootstrapMethodConfiguration.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/bootstrap/BootstrapMethodConfiguration.java index 8032a8914085..6bdaf4aa00b6 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/bootstrap/BootstrapMethodConfiguration.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/bootstrap/BootstrapMethodConfiguration.java @@ -43,6 +43,10 @@ import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.util.ReflectionUtil; import jdk.vm.ci.meta.ResolvedJavaMethod; @@ -52,6 +56,7 @@ * methods are trusted methods from the JDK. Additionally used to register methods used by some * bootstrap methods for runtime reflection. */ +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature public class BootstrapMethodConfiguration implements InternalFeature { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/locale/LocaleSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/locale/LocaleSupport.java index d94ba805e736..2e2b4046ca07 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/locale/LocaleSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/locale/LocaleSupport.java @@ -36,10 +36,22 @@ import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.CGlobalData; import com.oracle.svm.core.c.CGlobalDataFactory; +import com.oracle.svm.core.c.locale.LocaleSupport.LayeredCallbacks; import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.headers.LibC; import com.oracle.svm.core.jdk.SystemPropertiesSupport; import com.oracle.svm.core.jdk.UserSystemProperty; +import com.oracle.svm.core.layeredimagesingleton.ImageSingletonLoader; +import com.oracle.svm.core.layeredimagesingleton.ImageSingletonWriter; +import com.oracle.svm.core.layeredimagesingleton.LayeredImageSingleton; +import com.oracle.svm.core.layeredimagesingleton.LayeredImageSingleton.PersistFlags; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.SingletonLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredCallbacksSupplier; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTrait; +import com.oracle.svm.core.traits.SingletonTraitKind; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.BasedOnJDKFile; import com.oracle.svm.core.util.VMError; @@ -61,8 +73,11 @@ * Note that the JavaDoc of {@link java.util.Locale} explains commonly used terms such as script, * display, format, variant, and extensions. */ +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = LayeredCallbacks.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredImageSingleton public class LocaleSupport { + private static final String LOCALE = "locale"; + private static final CGlobalData STATE = CGlobalDataFactory.createWord(State.UNINITIALIZED); private LocaleData locale; @@ -199,4 +214,32 @@ private static final class State { static final UnsignedWord SUCCESS = Word.unsigned(2); static final UnsignedWord OUT_OF_MEMORY = Word.unsigned(3); } + + static class LayeredCallbacks extends SingletonLayeredCallbacksSupplier { + @Override + public SingletonTrait getLayeredCallbacksTrait() { + SingletonLayeredCallbacks action = new SingletonLayeredCallbacks() { + @Override + public LayeredImageSingleton.PersistFlags doPersist(ImageSingletonWriter writer, Object singleton) { + LocaleSupport localeSupport = (LocaleSupport) singleton; + writer.writeString(LOCALE, getLocaleString(localeSupport.locale)); + return PersistFlags.CALLBACK_ON_REGISTRATION; + } + + @Override + public void onSingletonRegistration(ImageSingletonLoader loader, Object singleton) { + LocaleSupport localeSupport = (LocaleSupport) singleton; + String previousLocale = loader.readString(LOCALE); + String currentLocale = getLocaleString(localeSupport.locale); + VMError.guarantee(currentLocale.equals(previousLocale), + "The locale data should be consistent across layers. The previous layer locale data were %s, but the locale data are %s", previousLocale, currentLocale); + } + + private static String getLocaleString(LocaleData localeData) { + return localeData == null ? "null" : localeData.toString(); + } + }; + return new SingletonTrait(SingletonTraitKind.LAYERED_CALLBACKS, action); + } + } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/config/ObjectLayout.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/config/ObjectLayout.java index 58686d32899a..88c2ba9d118f 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/config/ObjectLayout.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/config/ObjectLayout.java @@ -26,21 +26,26 @@ import java.lang.reflect.Field; import java.util.Arrays; -import java.util.EnumSet; +import java.util.List; import java.util.function.Predicate; import org.graalvm.nativeimage.AnnotationAccess; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.c.constant.CEnum; import org.graalvm.word.WordBase; import com.oracle.svm.core.SubstrateTargetDescription; import com.oracle.svm.core.Uninterruptible; -import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; +import com.oracle.svm.core.config.ObjectLayout.LayeredCallbacks; import com.oracle.svm.core.layeredimagesingleton.ImageSingletonLoader; import com.oracle.svm.core.layeredimagesingleton.ImageSingletonWriter; -import com.oracle.svm.core.layeredimagesingleton.LayeredImageSingleton; -import com.oracle.svm.core.layeredimagesingleton.LayeredImageSingletonBuilderFlags; +import com.oracle.svm.core.layeredimagesingleton.LayeredImageSingleton.PersistFlags; +import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; +import com.oracle.svm.core.traits.SingletonLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredCallbacksSupplier; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTrait; +import com.oracle.svm.core.traits.SingletonTraitKind; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; import jdk.graal.compiler.api.directives.GraalDirectives; @@ -73,6 +78,7 @@ * See this classes instantiation sites (such as {@code HostedConfiguration#createObjectLayout}) for * more details on the exact object layout for a given configuration. */ +@SingletonTraits(access = AllAccess.class, layeredCallbacks = LayeredCallbacks.class, layeredInstallationKind = Independent.class) public final class ObjectLayout { private final SubstrateTargetDescription target; @@ -114,32 +120,6 @@ public ObjectLayout(SubstrateTargetDescription target, int referenceSize, int ob this.identityHashMode = identityHashMode.value; this.identityHashNumBits = identityHashNumBits; this.identityHashShift = identityHashShift; - - if (ImageLayerBuildingSupport.buildingImageLayer()) { - int[] currentValues = { - /* this.target, */ - this.referenceSize, - this.objectAlignment, - this.alignmentMask, - this.hubSize, - this.hubOffset, - this.firstFieldOffset, - this.arrayLengthOffset, - this.arrayBaseOffset, - this.objectHeaderIdentityHashOffset, - this.identityHashMode, - this.identityHashNumBits, - this.identityHashShift, - }; - var numFields = Arrays.stream(ObjectLayout.class.getDeclaredFields()).filter(Predicate.not(Field::isSynthetic)).count(); - VMError.guarantee(numFields - 1 == currentValues.length, "Missing fields"); - - if (ImageLayerBuildingSupport.buildingInitialLayer()) { - ImageSingletons.add(PriorObjectLayout.class, new PriorObjectLayout(currentValues)); - } else { - VMError.guarantee(Arrays.equals(currentValues, ImageSingletons.lookup(PriorObjectLayout.class).priorValues)); - } - } } /** The minimum alignment of objects (instances and arrays). */ @@ -311,6 +291,22 @@ public int getMinImageHeapObjectSize() { return Math.min(getMinImageHeapArraySize(), getMinImageHeapInstanceSize()); } + private List getCurrentValues() { + return List.of(/* this.target, */ + this.referenceSize, + this.objectAlignment, + this.alignmentMask, + this.hubSize, + this.hubOffset, + this.firstFieldOffset, + this.arrayLengthOffset, + this.arrayBaseOffset, + this.objectHeaderIdentityHashOffset, + this.identityHashMode, + this.identityHashNumBits, + this.identityHashShift); + } + public static JavaKind getCallSignatureKind(boolean isEntryPoint, JavaType type, MetaAccessProvider metaAccess, TargetDescription target) { if (!(type instanceof ResolvedJavaType resolvedJavaType)) { assert type instanceof UnresolvedJavaType : type; @@ -341,28 +337,34 @@ public enum IdentityHashMode { } } - static class PriorObjectLayout implements LayeredImageSingleton { - final int[] priorValues; - - PriorObjectLayout(int[] priorValues) { - this.priorValues = priorValues; - } - - @Override - public EnumSet getImageBuilderFlags() { - return LayeredImageSingletonBuilderFlags.BUILDTIME_ACCESS_ONLY; - } - + static class LayeredCallbacks extends SingletonLayeredCallbacksSupplier { @Override - public PersistFlags preparePersist(ImageSingletonWriter writer) { - writer.writeIntList("priorValues", Arrays.stream(priorValues).boxed().toList()); - return PersistFlags.CREATE; - } - - @SuppressWarnings("unused") - public static Object createFromLoader(ImageSingletonLoader loader) { - int[] priorValues = loader.readIntList("priorValues").stream().mapToInt(e -> e).toArray(); - return new PriorObjectLayout(priorValues); + public SingletonTrait getLayeredCallbacksTrait() { + SingletonLayeredCallbacks action = new SingletonLayeredCallbacks() { + @Override + public PersistFlags doPersist(ImageSingletonWriter writer, Object singleton) { + ObjectLayout objectLayout = (ObjectLayout) singleton; + List currentValues = objectLayout.getCurrentValues(); + writer.writeIntList("priorValues", currentValues); + return PersistFlags.CALLBACK_ON_REGISTRATION; + } + + @Override + public void onSingletonRegistration(ImageSingletonLoader loader, Object singleton) { + ObjectLayout objectLayout = (ObjectLayout) singleton; + + List currentValues = objectLayout.getCurrentValues(); + List priorValues = loader.readIntList("priorValues"); + + var numFields = Arrays.stream(ObjectLayout.class.getDeclaredFields()).filter(Predicate.not(Field::isSynthetic)).count(); + VMError.guarantee(numFields - 1 == currentValues.size(), "Missing fields"); + + VMError.guarantee(currentValues.equals(priorValues), + "The object layout values should be consistent across layers. The previous layer object layout were %s, but the current layer are %s", + priorValues, currentValues); + } + }; + return new SingletonTrait(SingletonTraitKind.LAYERED_CALLBACKS, action); } } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/Container.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/Container.java index c20a0af1e969..9f5bde4f9fc2 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/Container.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/Container.java @@ -26,7 +26,6 @@ import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; -import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; @@ -39,13 +38,19 @@ import com.oracle.svm.core.c.CGlobalData; import com.oracle.svm.core.c.CGlobalDataFactory; import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; +import com.oracle.svm.core.traits.BuiltinTraits.SingleLayer; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.InitialLayerOnly; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.TimeUtils; import com.oracle.svm.core.util.VMError; import jdk.graal.compiler.api.replacements.Fold; import jdk.graal.compiler.nodes.PauseNode; +import jdk.graal.compiler.word.Word; /** Provides container awareness to the rest of the VM. */ +@SingletonTraits(access = AllAccess.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = InitialLayerOnly.class) @AutomaticallyRegisteredImageSingleton public class Container { /* The C++ library is shared between multiple isolates. */ diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/OperatingSystem.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/OperatingSystem.java index e7c871de5799..fda882e4cbf2 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/OperatingSystem.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/container/OperatingSystem.java @@ -24,25 +24,30 @@ */ package com.oracle.svm.core.container; -import com.oracle.svm.core.Uninterruptible; +import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; + import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.word.UnsignedWord; +import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.heap.PhysicalMemory; import com.oracle.svm.core.jdk.Jvm; +import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; +import com.oracle.svm.core.traits.BuiltinTraits.SingleLayer; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.InitialLayerOnly; +import com.oracle.svm.core.traits.SingletonTraits; import jdk.graal.compiler.api.replacements.Fold; -import static com.oracle.svm.core.Uninterruptible.CALLED_FROM_UNINTERRUPTIBLE_CODE; - /** * Query information about the machine that executes the native executable. This class bypasses the * container support (see {@link Container}) and directly queries the information from the operating * system. */ +@SingletonTraits(access = AllAccess.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = InitialLayerOnly.class) @AutomaticallyRegisteredImageSingleton public class OperatingSystem { private int cachedActiveProcessorCount; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/PhysicalMemory.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/PhysicalMemory.java index 3201854670fd..0cab553793e6 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/PhysicalMemory.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/PhysicalMemory.java @@ -36,10 +36,6 @@ import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.container.Container; import com.oracle.svm.core.container.OperatingSystem; -import com.oracle.svm.core.traits.BuiltinTraits.RuntimeAccessOnly; -import com.oracle.svm.core.traits.BuiltinTraits.SingleLayer; -import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.InitialLayerOnly; -import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.UnsignedUtils; import com.oracle.svm.core.util.VMError; import com.sun.management.OperatingSystemMXBean; @@ -52,7 +48,6 @@ public class PhysicalMemory { /** Implemented by operating-system specific code. */ - @SingletonTraits(access = RuntimeAccessOnly.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = InitialLayerOnly.class) public interface PhysicalMemorySupport { /** Get the size of physical memory from the OS. */ UnsignedWord size(); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/identityhashcode/SubstrateIdentityHashCodeFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/identityhashcode/SubstrateIdentityHashCodeFeature.java index 1290aa38b054..d82758b41c67 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/identityhashcode/SubstrateIdentityHashCodeFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/identityhashcode/SubstrateIdentityHashCodeFeature.java @@ -29,7 +29,12 @@ import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature final class SubstrateIdentityHashCodeFeature implements InternalFeature { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaNetSubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaNetSubstitutions.java index 6d72082686a6..53cc29839c83 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaNetSubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaNetSubstitutions.java @@ -36,7 +36,6 @@ import java.util.List; import java.util.Set; -import jdk.graal.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; @@ -55,12 +54,20 @@ import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; import com.oracle.svm.core.jdk.resources.ResourceURLConnection; import com.oracle.svm.core.option.SubstrateOptionsParser; +import com.oracle.svm.core.traits.BuiltinTraits.AllAccess; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.SingleLayer; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.InitialLayerOnly; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; import com.oracle.svm.util.LogUtils; import com.oracle.svm.util.ReflectionUtil; +import jdk.graal.compiler.word.Word; import sun.net.NetProperties; @TargetClass(java.net.URL.class) @@ -132,9 +139,15 @@ static boolean ensureInitialized() { } } +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature class JavaNetFeature implements InternalFeature { + @Override + public boolean isInConfiguration(IsInConfigurationAccess access) { + return ImageLayerBuildingSupport.firstImageBuild(); + } + @Override public void duringSetup(DuringSetupAccess access) { Set disabledURLProtocols = new HashSet<>(SubstrateOptions.DisableURLProtocols.getValue().values()); @@ -167,6 +180,7 @@ public void duringSetup(DuringSetupAccess access) { } +@SingletonTraits(access = AllAccess.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = InitialLayerOnly.class) @AutomaticallyRegisteredImageSingleton class URLProtocolsSupport { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SignalHandlerSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SignalHandlerSupport.java index c5e3339691f6..807192c024ac 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SignalHandlerSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SignalHandlerSupport.java @@ -36,7 +36,7 @@ import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; -import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.BuiltinTraits.SingleLayer; import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; @@ -66,7 +66,7 @@ public void stopDispatcherThread() { } } -@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature class SignalHandlerFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/ImageHeapProviderFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/ImageHeapProviderFeature.java index 749245b51f08..6cde17710ac3 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/ImageHeapProviderFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/ImageHeapProviderFeature.java @@ -30,11 +30,11 @@ import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; -import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.BuiltinTraits.SingleLayer; import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; import com.oracle.svm.core.traits.SingletonTraits; -@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature public class ImageHeapProviderFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/traits/BuiltinTraits.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/traits/BuiltinTraits.java index b191b1a45373..3e513f4e9654 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/traits/BuiltinTraits.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/traits/BuiltinTraits.java @@ -123,4 +123,17 @@ public SingletonTrait getTrait() { return DUPLICABLE_TRAIT; } } + + /** + * Trait indicating this singleton is not yet fully compatible with layered images. See + * {@link SingletonTraitKind#PARTIALLY_LAYER_AWARE} for more information. + */ + public static final SingletonTrait PARTIALLY_LAYER_AWARE = new SingletonTrait(SingletonTraitKind.PARTIALLY_LAYER_AWARE, EmptyMetadata.EMPTY); + + public static class PartiallyLayerAware extends SingletonTraitsSupplier { + @Override + public SingletonTrait getTrait() { + return PARTIALLY_LAYER_AWARE; + } + } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/traits/SingletonTraitKind.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/traits/SingletonTraitKind.java index b4332a4369c2..051f84ec5bec 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/traits/SingletonTraitKind.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/traits/SingletonTraitKind.java @@ -80,7 +80,12 @@ public enum SingletonTraitKind { * overhead due to having multiple copies of this singleton installed (via different layers) * within the image heap. */ - DUPLICABLE(EmptyMetadata.class); + DUPLICABLE(EmptyMetadata.class), + + /** + * Used as a marker to indicate the singleton is not yet fully compatible with layered images. + */ + PARTIALLY_LAYER_AWARE(EmptyMetadata.class); private final Class metadataClass; @@ -99,7 +104,7 @@ public Class getMetadataClass() { public boolean isInConfiguration(boolean layeredBuild) { return switch (this) { case ACCESS -> true; - case LAYERED_CALLBACKS, DUPLICABLE, LAYERED_INSTALLATION_KIND -> layeredBuild; + case LAYERED_CALLBACKS, DUPLICABLE, LAYERED_INSTALLATION_KIND, PARTIALLY_LAYER_AWARE -> layeredBuild; }; } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ClassNewInstanceFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ClassNewInstanceFeature.java index 4a9507cc6d1b..dce7061f7e07 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ClassNewInstanceFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ClassNewInstanceFeature.java @@ -26,11 +26,22 @@ import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.SingleLayer; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = SingleLayer.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature public class ClassNewInstanceFeature implements InternalFeature { + @Override + public boolean isInConfiguration(IsInConfigurationAccess access) { + return ImageLayerBuildingSupport.firstImageBuild(); + } + @Override public void beforeAnalysis(BeforeAnalysisAccess a) { BeforeAnalysisAccessImpl access = (BeforeAnalysisAccessImpl) a; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ClassPredefinitionFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ClassPredefinitionFeature.java index b104aa9521b3..2de13c5ab1ef 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ClassPredefinitionFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ClassPredefinitionFeature.java @@ -64,6 +64,11 @@ import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.hub.PredefinedClassesSupport; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.BuiltinTraits.PartiallyLayerAware; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.UserError; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl.AfterRegistrationAccessImpl; @@ -157,6 +162,7 @@ public void beforeAnalysis(BeforeAnalysisAccess access) { } } + @SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class, other = PartiallyLayerAware.class) private final class PredefinedClassesRegistryImpl implements PredefinedClassesRegistry { @Override public void add(String nameInfo, String providedHash, URI baseUri) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/CodeBreakdownProvider.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/CodeBreakdownProvider.java index 5871090816d0..f981b8e48cb1 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/CodeBreakdownProvider.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/CodeBreakdownProvider.java @@ -30,8 +30,13 @@ import org.graalvm.nativeimage.ImageSingletons; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.code.CompileQueue.CompileTask; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) class CodeBreakdownProvider { private Map, Long> codeBreakdown; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/DeadlockWatchdog.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/DeadlockWatchdog.java index c40039b9cc16..34896ec0241b 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/DeadlockWatchdog.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/DeadlockWatchdog.java @@ -37,8 +37,13 @@ import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.option.SubstrateOptionsParser; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.ExitStatus; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) public class DeadlockWatchdog implements Closeable { private final int watchdogInterval; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/FallbackFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/FallbackFeature.java index d5087694889e..65b2a981b902 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/FallbackFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/FallbackFeature.java @@ -45,6 +45,10 @@ import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.UserError; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl.AfterAnalysisAccessImpl; @@ -53,6 +57,7 @@ import jdk.vm.ci.code.BytecodePosition; import jdk.vm.ci.meta.ResolvedJavaMethod; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature public class FallbackFeature implements InternalFeature { private static final String ABORT_MSG_PREFIX = "Aborting stand-alone image build"; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/HeapBreakdownProvider.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/HeapBreakdownProvider.java index 651596c4119d..e7019b5b427c 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/HeapBreakdownProvider.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/HeapBreakdownProvider.java @@ -43,6 +43,10 @@ import com.oracle.svm.core.imagelayer.ImageLayerBuildingSupport; import com.oracle.svm.core.jdk.Resources; import com.oracle.svm.core.jdk.resources.ResourceStorageEntryBase; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl.BeforeImageWriteAccessImpl; import com.oracle.svm.hosted.ProgressReporter.LinkStrategy; @@ -55,6 +59,7 @@ import jdk.vm.ci.meta.JavaKind; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) public class HeapBreakdownProvider { private static final String BYTE_ARRAY_PREFIX = "byte[] for "; private static final Field STRING_VALUE = ReflectionUtil.lookupField(String.class, "value"); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/HostedConfiguration.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/HostedConfiguration.java index 770af1af3102..d04accb06a30 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/HostedConfiguration.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/HostedConfiguration.java @@ -56,6 +56,10 @@ import com.oracle.svm.core.graal.meta.RuntimeConfiguration; import com.oracle.svm.core.hub.DynamicHub; import com.oracle.svm.core.monitor.MultiThreadedMonitorSupport; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.analysis.Inflation; import com.oracle.svm.hosted.analysis.flow.SVMMethodTypeFlowBuilder; import com.oracle.svm.hosted.classinitialization.ClassInitializationSupport; @@ -89,6 +93,7 @@ import jdk.vm.ci.meta.MetaAccessProvider; import jdk.vm.ci.meta.ResolvedJavaField; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) public class HostedConfiguration { public HostedConfiguration() { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/Log4ShellFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/Log4ShellFeature.java index 8d05561ccc52..2c064ada29d7 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/Log4ShellFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/Log4ShellFeature.java @@ -42,9 +42,13 @@ import java.util.Set; import java.util.stream.Stream; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.util.LogUtils; -import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; /** * A feature that detects whether a native image may be vulnerable to Log4Shell. @@ -53,6 +57,7 @@ * If a vulnerable version is detected, the feature will then check whether any vulnerable methods * are reachable. */ +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature public class Log4ShellFeature implements InternalFeature { private static final String log4jClassName = "org.apache.logging.log4j.Logger"; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporterFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporterFeature.java index 4a043ef8df90..33e777384cf1 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporterFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporterFeature.java @@ -40,6 +40,10 @@ import com.oracle.svm.core.jdk.resources.NativeImageResourceFileSystem; import com.oracle.svm.core.jni.access.JNIAccessibleClass; import com.oracle.svm.core.jni.access.JNIReflectionDictionary; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.FeatureImpl.AfterCompilationAccessImpl; import com.oracle.svm.hosted.FeatureImpl.BeforeImageWriteAccessImpl; import com.oracle.svm.hosted.ProgressReporter.DirectPrinter; @@ -49,6 +53,7 @@ import com.oracle.svm.hosted.util.CPUTypeRISCV64; import com.oracle.svm.util.LogUtils; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature public class ProgressReporterFeature implements InternalFeature { protected final ProgressReporter reporter = ProgressReporter.singleton(); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/TemporaryBuildDirectoryProviderImpl.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/TemporaryBuildDirectoryProviderImpl.java index db983240dda8..9272c84ac3b0 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/TemporaryBuildDirectoryProviderImpl.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/TemporaryBuildDirectoryProviderImpl.java @@ -32,9 +32,14 @@ import java.nio.file.attribute.BasicFileAttributes; import com.oracle.svm.core.c.libc.TemporaryBuildDirectoryProvider; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.TimeUtils; import com.oracle.svm.core.util.VMError; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) public class TemporaryBuildDirectoryProviderImpl implements TemporaryBuildDirectoryProvider, AutoCloseable { private final Path tempDirectoryOptionValue; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ameta/HostedDynamicHubFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ameta/HostedDynamicHubFeature.java index dfb9325d404a..40d104e079a0 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ameta/HostedDynamicHubFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ameta/HostedDynamicHubFeature.java @@ -28,9 +28,14 @@ import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.hub.DynamicHub; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl; import com.oracle.svm.hosted.SVMHost; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature public class HostedDynamicHubFeature implements InternalFeature { private AnalysisMetaAccess metaAccess; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/annotation/AnnotationFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/annotation/AnnotationFeature.java index cdd0002334d4..38312ef5fe89 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/annotation/AnnotationFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/annotation/AnnotationFeature.java @@ -35,6 +35,10 @@ import com.oracle.graal.pointsto.ObjectScanner; import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl; import com.oracle.svm.hosted.reflect.ReflectionDataBuilder; @@ -46,6 +50,7 @@ * every reachable {@link Annotation} object in the heap and then checking if it is an annotation * that was materialized by the JDK, i.e., it is a {@link Proxy}. */ +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature public class AnnotationFeature implements InternalFeature { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/codegen/CCompilerInvoker.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/codegen/CCompilerInvoker.java index 8d0cf3633172..3cbbb4644583 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/codegen/CCompilerInvoker.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/codegen/CCompilerInvoker.java @@ -43,11 +43,17 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; +import com.oracle.svm.core.JavaVersionUtil; import com.oracle.svm.core.OS; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.SubstrateTargetDescription; import com.oracle.svm.core.SubstrateUtil; import com.oracle.svm.core.option.SubstrateOptionsParser; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.InterruptImageBuilding; import com.oracle.svm.core.util.UserError; import com.oracle.svm.core.util.VMError; @@ -55,7 +61,6 @@ import com.oracle.svm.hosted.c.util.FileUtils; import com.oracle.svm.util.ClassUtil; -import com.oracle.svm.core.JavaVersionUtil; import jdk.vm.ci.aarch64.AArch64; import jdk.vm.ci.amd64.AMD64; import jdk.vm.ci.code.Architecture; @@ -109,6 +114,7 @@ private static UserError.UserException addSkipCheckingInfo(UserError.UserExcepti return UserError.abort(messages); } + @SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) private static class WindowsCCompilerInvoker extends CCompilerInvoker { WindowsCCompilerInvoker(Path tempDirectory) { @@ -213,6 +219,7 @@ protected List compileStrictOptions() { } } + @SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) private static class LinuxCCompilerInvoker extends CCompilerInvoker { LinuxCCompilerInvoker(Path tempDirectory) { @@ -284,6 +291,7 @@ protected void verify() { } + @SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) private static class DarwinCCompilerInvoker extends CCompilerInvoker { DarwinCCompilerInvoker(Path tempDirectory) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/libc/HostedLibCFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/libc/HostedLibCFeature.java index dcd10b5ac27e..3f8f44f283b0 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/libc/HostedLibCFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/libc/HostedLibCFeature.java @@ -33,8 +33,13 @@ import com.oracle.svm.core.c.libc.LibCBase; import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.UserError; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature public class HostedLibCFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CodeLayoutOptimizationFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CodeLayoutOptimizationFeature.java index 528ecbdbc4f8..de607deda231 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CodeLayoutOptimizationFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CodeLayoutOptimizationFeature.java @@ -30,7 +30,12 @@ import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature public class CodeLayoutOptimizationFeature implements InternalFeature { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JDKInitializationFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JDKInitializationFeature.java index 09a3fbc0cd02..11f4458dae3f 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JDKInitializationFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JDKInitializationFeature.java @@ -37,6 +37,10 @@ import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.ProtectionDomainSupport; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.FeatureImpl; import com.oracle.svm.hosted.FeatureImpl.AfterRegistrationAccessImpl; import com.oracle.svm.hosted.ImageClassLoader; @@ -54,6 +58,7 @@ import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.ResolvedJavaMethod; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature public class JDKInitializationFeature implements InternalFeature { private static final String JDK_CLASS_REASON = "Core JDK classes are initialized at build time"; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JDKRegistrations.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JDKRegistrations.java index 2e4726e8a7cc..5a34eef46b1b 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JDKRegistrations.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JDKRegistrations.java @@ -34,9 +34,14 @@ import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.JNIRegistrationUtil; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; import com.oracle.svm.util.ReflectionUtil; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature class JDKRegistrations extends JNIRegistrationUtil implements InternalFeature { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationAWTSupport.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationAWTSupport.java index 626205c390ec..abc1805b9ff7 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationAWTSupport.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationAWTSupport.java @@ -30,9 +30,15 @@ import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.JNIRegistrationUtil; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.BuiltinTraits.PartiallyLayerAware; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.FeatureImpl.BeforeImageWriteAccessImpl; @Platforms({Platform.WINDOWS.class, Platform.LINUX.class}) +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class, other = PartiallyLayerAware.class) @AutomaticallyRegisteredFeature public class JNIRegistrationAWTSupport extends JNIRegistrationUtil implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationAttach.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationAttach.java index 3c540007fdaf..2904a3a64bae 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationAttach.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationAttach.java @@ -32,9 +32,15 @@ import com.oracle.svm.core.jdk.JNIRegistrationUtil; import com.oracle.svm.core.jdk.NativeLibrarySupport; import com.oracle.svm.core.jdk.PlatformNativeLibrarySupport; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.BuiltinTraits.PartiallyLayerAware; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.c.NativeLibraries; @Platforms(InternalPlatform.PLATFORM_JNI.class) +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class, other = PartiallyLayerAware.class) @AutomaticallyRegisteredFeature class JNIRegistrationAttach extends JNIRegistrationUtil implements InternalFeature { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationJava.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationJava.java index 570b5c468744..605de8fb1418 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationJava.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationJava.java @@ -38,12 +38,17 @@ import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.JNIRegistrationUtil; import com.oracle.svm.core.jdk.PlatformNativeLibrarySupport; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.FeatureImpl; /** * Registration of classes, methods, and fields accessed via JNI by C code of the JDK. */ @Platforms(InternalPlatform.PLATFORM_JNI.class) +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature class JNIRegistrationJava extends JNIRegistrationUtil implements InternalFeature { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationJavaNet.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationJavaNet.java index a222bd207f54..d4bbcd964970 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationJavaNet.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationJavaNet.java @@ -35,6 +35,10 @@ import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.JNIRegistrationUtil; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl; @@ -42,6 +46,7 @@ * Registration of classes, methods, and fields accessed via JNI by C code of the JDK. */ @Platforms({InternalPlatform.PLATFORM_JNI.class}) +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature class JNIRegistrationJavaNet extends JNIRegistrationUtil implements InternalFeature { private boolean hasPlatformSocketOptions; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationJavaNio.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationJavaNio.java index 822ad1096119..59ae52064d64 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationJavaNio.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationJavaNio.java @@ -37,11 +37,16 @@ import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.JNIRegistrationUtil; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; /** * Registration of classes, methods, and fields accessed via JNI by C code of the JDK. */ @Platforms({InternalPlatform.PLATFORM_JNI.class}) +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature public class JNIRegistrationJavaNio extends JNIRegistrationUtil implements InternalFeature { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationManagementExt.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationManagementExt.java index db7f41216e4a..f6cf8f18bee2 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationManagementExt.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationManagementExt.java @@ -28,9 +28,15 @@ import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.JNIRegistrationUtil; import com.oracle.svm.core.jdk.PlatformNativeLibrarySupport; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.BuiltinTraits.PartiallyLayerAware; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl; import com.oracle.svm.hosted.c.NativeLibraries; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class, other = PartiallyLayerAware.class) @AutomaticallyRegisteredFeature public class JNIRegistrationManagementExt extends JNIRegistrationUtil implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationPrefs.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationPrefs.java index 4fac0eeae654..b1f7c3cc0176 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationPrefs.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationPrefs.java @@ -36,11 +36,17 @@ import com.oracle.svm.core.jdk.JNIRegistrationUtil; import com.oracle.svm.core.jdk.JavaNetHttpFeature; import com.oracle.svm.core.jdk.NativeLibrarySupport; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.BuiltinTraits.PartiallyLayerAware; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl; import com.oracle.svm.hosted.c.NativeLibraries; @Platforms({InternalPlatform.PLATFORM_JNI.class}) +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class, other = PartiallyLayerAware.class) @AutomaticallyRegisteredFeature public class JNIRegistrationPrefs extends JNIRegistrationUtil implements InternalFeature { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationSupport.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationSupport.java index 55441c71f564..bc9c7581a437 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationSupport.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationSupport.java @@ -42,7 +42,6 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.stream.Stream; -import com.oracle.svm.hosted.imagelayer.CapnProtoAdapters; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.impl.InternalPlatform; @@ -60,6 +59,11 @@ import com.oracle.svm.core.layeredimagesingleton.LayeredImageSingleton; import com.oracle.svm.core.layeredimagesingleton.LayeredImageSingletonBuilderFlags; import com.oracle.svm.core.option.HostedOptionKey; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.BuiltinTraits.PartiallyLayerAware; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.core.util.InterruptImageBuilding; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl.AfterImageWriteAccessImpl; @@ -68,6 +72,7 @@ import com.oracle.svm.hosted.c.NativeLibraries; import com.oracle.svm.hosted.c.codegen.CCompilerInvoker; import com.oracle.svm.hosted.c.util.FileUtils; +import com.oracle.svm.hosted.imagelayer.CapnProtoAdapters; import com.oracle.svm.hosted.imagelayer.SVMImageLayerSingletonLoader; import com.oracle.svm.hosted.imagelayer.SVMImageLayerWriter; @@ -87,6 +92,7 @@ /** Registration of native JDK libraries. */ @Platforms(InternalPlatform.PLATFORM_JNI.class) +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class, other = PartiallyLayerAware.class) @AutomaticallyRegisteredFeature public final class JNIRegistrationSupport extends JNIRegistrationUtil implements InternalFeature { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationsJavaZip.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationsJavaZip.java index 0ceec9e9cf07..3fd489478088 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationsJavaZip.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationsJavaZip.java @@ -32,9 +32,15 @@ import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.JNIRegistrationUtil; import com.oracle.svm.core.jdk.NativeLibrarySupport; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.BuiltinTraits.PartiallyLayerAware; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.c.NativeLibraries; @Platforms(InternalPlatform.PLATFORM_JNI.class) +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class, other = PartiallyLayerAware.class) @AutomaticallyRegisteredFeature class JNIRegistrationsJavaZip extends JNIRegistrationUtil implements InternalFeature { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/localization/CharsetSubstitutionsFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/localization/CharsetSubstitutionsFeature.java index ebe8e3659f41..4bc9098f533c 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/localization/CharsetSubstitutionsFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/localization/CharsetSubstitutionsFeature.java @@ -28,7 +28,12 @@ import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature class CharsetSubstitutionsFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/lambda/StableLambdaProxyNameFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/lambda/StableLambdaProxyNameFeature.java index fd4c594e0e37..1c02d60f1d12 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/lambda/StableLambdaProxyNameFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/lambda/StableLambdaProxyNameFeature.java @@ -33,6 +33,10 @@ import com.oracle.svm.core.SubstrateUtil; import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.FeatureImpl.AfterAnalysisAccessImpl; import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl; @@ -41,6 +45,7 @@ /** * @see LambdaProxyRenamingSubstitutionProcessor */ +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature public final class StableLambdaProxyNameFeature implements InternalFeature { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/methodhandles/StableInjectedInvokerNameFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/methodhandles/StableInjectedInvokerNameFeature.java index 835c3618427c..bc38f6708d5b 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/methodhandles/StableInjectedInvokerNameFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/methodhandles/StableInjectedInvokerNameFeature.java @@ -35,12 +35,17 @@ import com.oracle.svm.core.SubstrateUtil; import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.FeatureImpl.AfterAnalysisAccessImpl; import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl; /** * @see InjectedInvokerRenamingSubstitutionProcessor */ +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature final class StableInjectedInvokerNameFeature implements InternalFeature { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/option/BuildTimeOptionValidationFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/option/BuildTimeOptionValidationFeature.java index 6a23ce4bd9e7..79f81bbd1278 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/option/BuildTimeOptionValidationFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/option/BuildTimeOptionValidationFeature.java @@ -27,10 +27,15 @@ import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.option.SubstrateOptionKey; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl; import jdk.graal.compiler.options.OptionDescriptor; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature public class BuildTimeOptionValidationFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy/StableProxyNameFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy/StableProxyNameFeature.java index b038446ae84e..ee1125d0b44f 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy/StableProxyNameFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy/StableProxyNameFeature.java @@ -32,11 +32,16 @@ import com.oracle.svm.core.SubstrateUtil; import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.FeatureImpl.AfterAnalysisAccessImpl; /** * @see ProxyRenamingSubstitutionProcessor */ +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) @AutomaticallyRegisteredFeature final class StableProxyNameFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/snippets/ExceptionUnwindFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/snippets/ExceptionUnwindFeature.java index d39fecf43ca4..d0dcfec4d5d4 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/snippets/ExceptionUnwindFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/snippets/ExceptionUnwindFeature.java @@ -34,9 +34,14 @@ import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider; import com.oracle.svm.core.snippets.ExceptionUnwind; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl; @AutomaticallyRegisteredFeature +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) @Platforms(InternalPlatform.NATIVE_ONLY.class) final class ExceptionUnwindFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/snippets/ImplicitExceptionsFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/snippets/ImplicitExceptionsFeature.java index c89a783cdafb..d9213734ba5a 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/snippets/ImplicitExceptionsFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/snippets/ImplicitExceptionsFeature.java @@ -32,9 +32,14 @@ import com.oracle.svm.core.graal.snippets.NonSnippetLowerings; import com.oracle.svm.core.snippets.ImplicitExceptions; import com.oracle.svm.core.snippets.SnippetRuntime.SubstrateForeignCallDescriptor; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Independent; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl; @AutomaticallyRegisteredFeature +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Independent.class) final class ImplicitExceptionsFeature implements InternalFeature { @Override diff --git a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/WebImageJSHeapBreakdownProvider.java b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/WebImageJSHeapBreakdownProvider.java index e1b099dbe2d0..c06e4e4270c3 100644 --- a/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/WebImageJSHeapBreakdownProvider.java +++ b/web-image/src/com.oracle.svm.hosted.webimage/src/com/oracle/svm/hosted/webimage/WebImageJSHeapBreakdownProvider.java @@ -30,6 +30,10 @@ import org.graalvm.nativeimage.ImageSingletons; +import com.oracle.svm.core.traits.BuiltinTraits.BuildtimeAccessOnly; +import com.oracle.svm.core.traits.BuiltinTraits.NoLayeredCallbacks; +import com.oracle.svm.core.traits.SingletonLayeredInstallationKind.Disallowed; +import com.oracle.svm.core.traits.SingletonTraits; import com.oracle.svm.hosted.FeatureImpl; import com.oracle.svm.hosted.HeapBreakdownProvider; import com.oracle.svm.hosted.meta.HostedClass; @@ -37,6 +41,7 @@ import com.oracle.svm.hosted.webimage.codegen.WebImageProviders; import com.oracle.svm.webimage.object.ConstantIdentityMapping; +@SingletonTraits(access = BuildtimeAccessOnly.class, layeredCallbacks = NoLayeredCallbacks.class, layeredInstallationKind = Disallowed.class) public class WebImageJSHeapBreakdownProvider extends HeapBreakdownProvider { /**