diff --git a/compiler/src/org.graalvm.compiler.core.match.processor/src/org/graalvm/compiler/core/match/processor/MatchProcessor.java b/compiler/src/org.graalvm.compiler.core.match.processor/src/org/graalvm/compiler/core/match/processor/MatchProcessor.java index 5bd8959e0651..06510a92a1d3 100644 --- a/compiler/src/org.graalvm.compiler.core.match.processor/src/org/graalvm/compiler/core/match/processor/MatchProcessor.java +++ b/compiler/src/org.graalvm.compiler.core.match.processor/src/org/graalvm/compiler/core/match/processor/MatchProcessor.java @@ -41,7 +41,6 @@ import javax.annotation.processing.Filer; import javax.annotation.processing.RoundEnvironment; import javax.annotation.processing.SupportedAnnotationTypes; -import javax.lang.model.SourceVersion; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; @@ -56,7 +55,6 @@ import javax.lang.model.util.Types; import javax.tools.Diagnostic.Kind; import javax.tools.FileObject; -import javax.tools.JavaFileObject; import javax.tools.StandardLocation; import org.graalvm.compiler.processor.AbstractProcessor; @@ -87,11 +85,6 @@ public class MatchProcessor extends AbstractProcessor { public MatchProcessor() { } - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - private final Set processedMatchRules = new HashSet<>(); private final Set processedMatchableNodes = new HashSet<>(); @@ -605,22 +598,6 @@ private void createFiles(MatchRuleDescriptor info) { this.createProviderFile(pkg + "." + matchStatementClassName, "org.graalvm.compiler.core.match.MatchStatementSet", originatingElements); } - protected PrintWriter createSourceFile(String pkg, String relativeName, Filer filer, Element... originatingElements) { - try { - // Ensure Unix line endings to comply with Graal code style guide checked by Checkstyle - JavaFileObject sourceFile = filer.createSourceFile(pkg + "." + relativeName, originatingElements); - return new PrintWriter(sourceFile.openWriter()) { - - @Override - public void println() { - print("\n"); - } - }; - } catch (IOException e) { - throw new RuntimeException(e); - } - } - /** * Used to generate the MatchStatement constructor invocation. */ diff --git a/compiler/src/org.graalvm.compiler.lir.processor/src/org/graalvm/compiler/lir/processor/IntrinsicStubProcessor.java b/compiler/src/org.graalvm.compiler.lir.processor/src/org/graalvm/compiler/lir/processor/IntrinsicStubProcessor.java index 4659afd2a409..6c76301935a7 100644 --- a/compiler/src/org.graalvm.compiler.lir.processor/src/org/graalvm/compiler/lir/processor/IntrinsicStubProcessor.java +++ b/compiler/src/org.graalvm.compiler.lir.processor/src/org/graalvm/compiler/lir/processor/IntrinsicStubProcessor.java @@ -36,7 +36,6 @@ import java.util.stream.Collectors; import javax.annotation.processing.RoundEnvironment; -import javax.lang.model.SourceVersion; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; @@ -74,11 +73,6 @@ enum TargetVM { private TypeElement generateStubs; private TypeMirror constantNodeParameter; - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - @Override public Set getSupportedAnnotationTypes() { return Set.of(GENERATE_STUB_CLASS_NAME, GENERATE_STUBS_CLASS_NAME, GENERATED_STUBS_HOLDER_CLASS_NAME); diff --git a/compiler/src/org.graalvm.compiler.lir.processor/src/org/graalvm/compiler/lir/processor/StubPortProcessor.java b/compiler/src/org.graalvm.compiler.lir.processor/src/org/graalvm/compiler/lir/processor/StubPortProcessor.java index b6d249f7fcf2..56bf0ebabba5 100644 --- a/compiler/src/org.graalvm.compiler.lir.processor/src/org/graalvm/compiler/lir/processor/StubPortProcessor.java +++ b/compiler/src/org.graalvm.compiler.lir.processor/src/org/graalvm/compiler/lir/processor/StubPortProcessor.java @@ -40,7 +40,6 @@ import java.util.stream.Collectors; import javax.annotation.processing.RoundEnvironment; -import javax.lang.model.SourceVersion; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; @@ -67,11 +66,6 @@ public class StubPortProcessor extends AbstractProcessor { static final int SEARCH_RANGE = 100; - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - @Override public Set getSupportedAnnotationTypes() { return Set.of(STUB_PORT_CLASS_NAME, STUB_PORTS_CLASS_NAME); diff --git a/compiler/src/org.graalvm.compiler.nodeinfo.processor/src/org/graalvm/compiler/nodeinfo/processor/GraphNodeProcessor.java b/compiler/src/org.graalvm.compiler.nodeinfo.processor/src/org/graalvm/compiler/nodeinfo/processor/GraphNodeProcessor.java index 24fc4297f878..f24e5dd38244 100644 --- a/compiler/src/org.graalvm.compiler.nodeinfo.processor/src/org/graalvm/compiler/nodeinfo/processor/GraphNodeProcessor.java +++ b/compiler/src/org.graalvm.compiler.nodeinfo.processor/src/org/graalvm/compiler/nodeinfo/processor/GraphNodeProcessor.java @@ -56,11 +56,6 @@ public class GraphNodeProcessor extends AbstractProcessor { private static final String NODE_INFO_CLASS_NAME = "org.graalvm.compiler.nodeinfo.NodeInfo"; - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - /** * Node class currently being processed. */ diff --git a/compiler/src/org.graalvm.compiler.options.processor/src/org/graalvm/compiler/options/processor/OptionProcessor.java b/compiler/src/org.graalvm.compiler.options.processor/src/org/graalvm/compiler/options/processor/OptionProcessor.java index 941470ff57b1..75584ac8ed46 100644 --- a/compiler/src/org.graalvm.compiler.options.processor/src/org/graalvm/compiler/options/processor/OptionProcessor.java +++ b/compiler/src/org.graalvm.compiler.options.processor/src/org/graalvm/compiler/options/processor/OptionProcessor.java @@ -54,7 +54,6 @@ import javax.lang.model.util.Types; import javax.tools.Diagnostic.Kind; import javax.tools.FileObject; -import javax.tools.JavaFileObject; import javax.tools.StandardLocation; import org.graalvm.compiler.processor.AbstractProcessor; @@ -74,11 +73,6 @@ public class OptionProcessor extends AbstractProcessor { private static final String OPTION_DESCRIPTOR_CLASS_NAME = "org.graalvm.compiler.options.OptionDescriptor"; private static final String OPTION_DESCRIPTORS_CLASS_NAME = "org.graalvm.compiler.options.OptionDescriptors"; - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - private final Set processed = new HashSet<>(); private TypeMirror optionTypeMirror; @@ -325,23 +319,6 @@ public static void createOptionsDescriptorsFile(ProcessingEnvironment processing } } - public static PrintWriter createSourceFile(String pkg, String relativeName, Filer filer, Element... originatingElements) { - try { - // Ensure Unix line endings to comply with code style guide checked by Checkstyle - String className = pkg + "." + relativeName; - JavaFileObject sourceFile = filer.createSourceFile(className, originatingElements); - return new PrintWriter(sourceFile.openWriter()) { - - @Override - public void println() { - print("\n"); - } - }; - } catch (IOException e) { - throw new RuntimeException(e); - } - } - public static class OptionInfo implements Comparable { public final String name; diff --git a/compiler/src/org.graalvm.compiler.processor/src/org/graalvm/compiler/processor/AbstractProcessor.java b/compiler/src/org.graalvm.compiler.processor/src/org/graalvm/compiler/processor/AbstractProcessor.java index f425b76b76bc..0b81a04135d9 100644 --- a/compiler/src/org.graalvm.compiler.processor/src/org/graalvm/compiler/processor/AbstractProcessor.java +++ b/compiler/src/org.graalvm.compiler.processor/src/org/graalvm/compiler/processor/AbstractProcessor.java @@ -36,19 +36,24 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.annotation.processing.Filer; import javax.annotation.processing.FilerException; import javax.annotation.processing.ProcessingEnvironment; import javax.annotation.processing.RoundEnvironment; +import javax.lang.model.SourceVersion; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.AnnotationValue; import javax.lang.model.element.Element; +import javax.lang.model.element.ElementKind; import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.PackageElement; import javax.lang.model.element.TypeElement; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; import javax.lang.model.util.ElementFilter; import javax.tools.Diagnostic.Kind; import javax.tools.FileObject; +import javax.tools.JavaFileObject; import javax.tools.StandardLocation; /** @@ -65,6 +70,11 @@ public ProcessingEnvironment env() { return processingEnv; } + @Override + public final SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } + @Override public boolean process(Set annotations, RoundEnvironment roundEnv) { return doProcess(annotations, roundEnv); @@ -287,6 +297,30 @@ public static List getAnnotationValueList(AnnotationMirror annotation, St return result; } + public static PackageElement getPackage(Element element) { + Element e = element.getEnclosingElement(); + while (e != null && e.getKind() != ElementKind.PACKAGE) { + e = e.getEnclosingElement(); + } + return (PackageElement) e; + } + + public static PrintWriter createSourceFile(String pkg, String relativeName, Filer filer, Element... originatingElements) { + try { + /* Ensure Unix line endings to comply with code style guide checked by Checkstyle. */ + String className = pkg + "." + relativeName; + JavaFileObject sourceFile = filer.createSourceFile(className, originatingElements); + return new PrintWriter(sourceFile.openWriter()) { + @Override + public void println() { + print("\n"); + } + }; + } catch (IOException e) { + throw new RuntimeException(e); + } + } + /** * Creates a {@code META-INF/providers/} file whose contents are a single * line containing {@code serviceClassName}. diff --git a/compiler/src/org.graalvm.compiler.replacements.processor/src/org/graalvm/compiler/replacements/processor/ReplacementsAnnotationProcessor.java b/compiler/src/org.graalvm.compiler.replacements.processor/src/org/graalvm/compiler/replacements/processor/ReplacementsAnnotationProcessor.java index f30b0c9b8102..897d5c052eb3 100644 --- a/compiler/src/org.graalvm.compiler.replacements.processor/src/org/graalvm/compiler/replacements/processor/ReplacementsAnnotationProcessor.java +++ b/compiler/src/org.graalvm.compiler.replacements.processor/src/org/graalvm/compiler/replacements/processor/ReplacementsAnnotationProcessor.java @@ -30,7 +30,6 @@ import java.util.Set; import javax.annotation.processing.RoundEnvironment; -import javax.lang.model.SourceVersion; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; @@ -45,11 +44,6 @@ public class ReplacementsAnnotationProcessor extends AbstractProcessor { private List handlers; - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - @Override public boolean doProcess(Set annotations, RoundEnvironment roundEnv) { if (!roundEnv.processingOver()) { diff --git a/compiler/src/org.graalvm.compiler.serviceprovider.processor/src/org/graalvm/compiler/serviceprovider/processor/ServiceProviderProcessor.java b/compiler/src/org.graalvm.compiler.serviceprovider.processor/src/org/graalvm/compiler/serviceprovider/processor/ServiceProviderProcessor.java index 3d77b5ddfe77..a0b0d9aa12b0 100644 --- a/compiler/src/org.graalvm.compiler.serviceprovider.processor/src/org/graalvm/compiler/serviceprovider/processor/ServiceProviderProcessor.java +++ b/compiler/src/org.graalvm.compiler.serviceprovider.processor/src/org/graalvm/compiler/serviceprovider/processor/ServiceProviderProcessor.java @@ -32,7 +32,6 @@ import javax.annotation.processing.RoundEnvironment; import javax.annotation.processing.SupportedAnnotationTypes; -import javax.lang.model.SourceVersion; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; @@ -56,11 +55,6 @@ public class ServiceProviderProcessor extends AbstractProcessor { private final Set processed = new HashSet<>(); private final Map serviceProviders = new HashMap<>(); - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - private boolean verifyAnnotation(TypeMirror serviceInterface, TypeElement serviceProvider) { if (!processingEnv.getTypeUtils().isSubtype(serviceProvider.asType(), serviceInterface)) { String msg = String.format("Service provider class %s must implement service interface %s", serviceProvider.getSimpleName(), serviceInterface); diff --git a/compiler/src/org.graalvm.libgraal.jni.processor/src/org/graalvm/libgraal/jni/processor/AbstractFromLibGraalProcessor.java b/compiler/src/org.graalvm.libgraal.jni.processor/src/org/graalvm/libgraal/jni/processor/AbstractFromLibGraalProcessor.java index 7126e7c8c1d9..546ee3e17394 100644 --- a/compiler/src/org.graalvm.libgraal.jni.processor/src/org/graalvm/libgraal/jni/processor/AbstractFromLibGraalProcessor.java +++ b/compiler/src/org.graalvm.libgraal.jni.processor/src/org/graalvm/libgraal/jni/processor/AbstractFromLibGraalProcessor.java @@ -24,7 +24,6 @@ */ package org.graalvm.libgraal.jni.processor; -import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Collections; @@ -37,7 +36,6 @@ import javax.annotation.processing.Filer; import javax.annotation.processing.RoundEnvironment; -import javax.lang.model.SourceVersion; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; @@ -49,7 +47,6 @@ import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeKind; import javax.lang.model.util.ElementFilter; -import javax.tools.JavaFileObject; import org.graalvm.compiler.processor.AbstractProcessor; import org.graalvm.libgraal.jni.annotation.FromLibGraalId; @@ -76,11 +73,6 @@ protected boolean accept(@SuppressWarnings("unused") ExecutableElement annotated return true; } - @Override - public final SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - private final Set processed = new HashSet<>(); /** @@ -248,21 +240,6 @@ private void createGenSource(CallsInfo info, String pkg, Name topDeclaringClass, } } - static PrintWriter createSourceFile(String pkg, String relativeName, Filer filer, Element... originatingElements) { - try { - // Ensure Unix line endings to comply with code style guide checked by Checkstyle - JavaFileObject sourceFile = filer.createSourceFile(pkg + "." + relativeName, originatingElements); - return new PrintWriter(sourceFile.openWriter()) { - @Override - public void println() { - print("\n"); - } - }; - } catch (IOException e) { - throw new RuntimeException(e); - } - } - private String getAccessorClassSimpleName() { Class topLevel = null; for (Class current = idClass; current != null; current = current.getEnclosingClass()) { diff --git a/compiler/src/org.graalvm.libgraal.jni.processor/src/org/graalvm/libgraal/jni/processor/FromLibGraalEntryPointsResolverProcessor.java b/compiler/src/org.graalvm.libgraal.jni.processor/src/org/graalvm/libgraal/jni/processor/FromLibGraalEntryPointsResolverProcessor.java index 39db5064cbb6..bcf9acd439bc 100644 --- a/compiler/src/org.graalvm.libgraal.jni.processor/src/org/graalvm/libgraal/jni/processor/FromLibGraalEntryPointsResolverProcessor.java +++ b/compiler/src/org.graalvm.libgraal.jni.processor/src/org/graalvm/libgraal/jni/processor/FromLibGraalEntryPointsResolverProcessor.java @@ -25,14 +25,13 @@ package org.graalvm.libgraal.jni.processor; import static org.graalvm.libgraal.jni.processor.AbstractFromLibGraalProcessor.topDeclaringType; -import static org.graalvm.libgraal.jni.processor.AbstractFromLibGraalProcessor.createSourceFile; import java.io.PrintWriter; import java.util.List; import java.util.Set; + import javax.annotation.processing.RoundEnvironment; import javax.annotation.processing.SupportedAnnotationTypes; -import javax.lang.model.SourceVersion; import javax.lang.model.element.AnnotationMirror; import javax.lang.model.element.Element; import javax.lang.model.element.ElementKind; @@ -44,6 +43,7 @@ import javax.lang.model.type.DeclaredType; import javax.lang.model.type.TypeMirror; import javax.tools.Diagnostic.Kind; + import org.graalvm.compiler.processor.AbstractProcessor; import org.graalvm.libgraal.jni.annotation.FromLibGraalEntryPointsResolver; import org.graalvm.libgraal.jni.annotation.FromLibGraalId; @@ -55,11 +55,6 @@ @SupportedAnnotationTypes("org.graalvm.libgraal.jni.annotation.FromLibGraalEntryPointsResolver") public final class FromLibGraalEntryPointsResolverProcessor extends AbstractProcessor { - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - @Override public boolean doProcess(Set annotations, RoundEnvironment roundEnv) { if (roundEnv.processingOver()) { diff --git a/compiler/src/org.graalvm.nativebridge.processor/src/org/graalvm/nativebridge/processor/NativeBridgeProcessor.java b/compiler/src/org.graalvm.nativebridge.processor/src/org/graalvm/nativebridge/processor/NativeBridgeProcessor.java index 4e8c98fd67ff..31290220b279 100644 --- a/compiler/src/org.graalvm.nativebridge.processor/src/org/graalvm/nativebridge/processor/NativeBridgeProcessor.java +++ b/compiler/src/org.graalvm.nativebridge.processor/src/org/graalvm/nativebridge/processor/NativeBridgeProcessor.java @@ -24,18 +24,6 @@ */ package org.graalvm.nativebridge.processor; -import org.graalvm.compiler.processor.AbstractProcessor; -import org.graalvm.nativebridge.processor.AbstractBridgeParser.DefinitionData; -import org.graalvm.nativebridge.processor.AbstractBridgeParser.AbstractTypeCache; -import javax.annotation.processing.RoundEnvironment; -import javax.annotation.processing.SupportedAnnotationTypes; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.Element; -import javax.lang.model.element.Modifier; -import javax.lang.model.element.PackageElement; -import javax.lang.model.element.TypeElement; -import javax.tools.Diagnostic; -import javax.tools.JavaFileObject; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; @@ -48,6 +36,19 @@ import java.util.Set; import java.util.stream.Collectors; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.lang.model.element.Element; +import javax.lang.model.element.Modifier; +import javax.lang.model.element.PackageElement; +import javax.lang.model.element.TypeElement; +import javax.tools.Diagnostic; +import javax.tools.JavaFileObject; + +import org.graalvm.compiler.processor.AbstractProcessor; +import org.graalvm.nativebridge.processor.AbstractBridgeParser.AbstractTypeCache; +import org.graalvm.nativebridge.processor.AbstractBridgeParser.DefinitionData; + @SupportedAnnotationTypes({ HotSpotToNativeBridgeParser.GENERATE_HOTSPOT_TO_NATIVE_ANNOTATION, NativeToHotSpotBridgeParser.GENERATE_NATIVE_TO_HOTSPOT_ANNOTATION, @@ -58,11 +59,6 @@ public final class NativeBridgeProcessor extends AbstractProcessor { public NativeBridgeProcessor() { } - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latest(); - } - @Override protected boolean doProcess(Set annotations, RoundEnvironment roundEnv) { Map> toGenerate = new HashMap<>(); diff --git a/sdk/src/com.oracle.svm.core.annotate/src/com/oracle/svm/core/annotate/AutomaticFeature.java b/sdk/src/com.oracle.svm.core.annotate/src/com/oracle/svm/core/annotate/AutomaticFeature.java index 00248d233d26..995e9ee73aa0 100644 --- a/sdk/src/com.oracle.svm.core.annotate/src/com/oracle/svm/core/annotate/AutomaticFeature.java +++ b/sdk/src/com.oracle.svm.core.annotate/src/com/oracle/svm/core/annotate/AutomaticFeature.java @@ -53,11 +53,16 @@ * use {@code "--features "} in the {@code Args} of a * {@code native-image.properties} file to ensure a user-provided feature gets processed. * - * Feature classes can use this annotation are unconditionally added when they are reachable on the + * Feature classes that use this annotation are unconditionally added when they are reachable on the * class path. * + * This annotation is deprecated because a full scan of the class path is necessary to find + * annotated classes. This full classpath scanning will be removed in a future version of GraalVM, + * which means that this annotation needs to be removed then too. + * * @since 22.3 */ +@Deprecated(forRemoval = true) @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) @Platforms(Platform.HOSTED_ONLY.class) diff --git a/substratevm/mx.substratevm/mx_substratevm.py b/substratevm/mx.substratevm/mx_substratevm.py index 8a44106c2231..518753d66556 100644 --- a/substratevm/mx.substratevm/mx_substratevm.py +++ b/substratevm/mx.substratevm/mx_substratevm.py @@ -1150,8 +1150,8 @@ def _native_image_launcher_extra_jvm_args(): '-J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.annotate=ALL-UNNAMED', '-J--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.option=ALL-UNNAMED', ## Packages used after option-processing can be opened by the builder (`-J`-prefix not needed) - # LibGraalFeature implements com.oracle.svm.core.graal.GraalFeature (needed to be able to instantiate LibGraalFeature) - '--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.graal=ALL-UNNAMED', + # LibGraalFeature implements com.oracle.svm.core.feature.InternalFeature (needed to be able to instantiate LibGraalFeature) + '--add-exports=org.graalvm.nativeimage.builder/com.oracle.svm.core.feature=ALL-UNNAMED', # Make ModuleSupport accessible to do the remaining opening-up in LibGraalFeature constructor '--add-exports=org.graalvm.nativeimage.base/com.oracle.svm.util=ALL-UNNAMED', diff --git a/substratevm/mx.substratevm/suite.py b/substratevm/mx.substratevm/suite.py index 8d7c31efa2da..26f53121b8be 100644 --- a/substratevm/mx.substratevm/suite.py +++ b/substratevm/mx.substratevm/suite.py @@ -204,6 +204,20 @@ "workingSets": "SVM", }, + "com.oracle.svm.processor" : { + "subDir" : "src", + "sourceDirs" : ["src"], + "dependencies" : [ + "compiler:GRAAL_PROCESSOR" + ], + "requires" : [ + "java.compiler" # javax.annotation.processing.* + ], + "javaCompliance": "11+", + "checkstyle" : "com.oracle.svm.core", + "workingSets" : "SVM", + }, + "com.oracle.svm.core": { "subDir": "src", "sourceDirs": [ @@ -276,6 +290,7 @@ "checkstyleVersion" : "8.36.1", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "workingSets": "SVM", }, @@ -285,6 +300,10 @@ "sourceDirs": ["src"], "dependencies": ["com.oracle.svm.core"], "javaCompliance": "11+", + "annotationProcessors": [ + "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", + ], "workingSets": "SVM", "spotbugs": "false", }, @@ -304,6 +323,10 @@ ], }, "javaCompliance": "17+", + "annotationProcessors": [ + "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", + ], "checkstyle": "com.oracle.svm.core", "workingSets": "SVM", }, @@ -335,6 +358,7 @@ "javaCompliance": "11+", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "workingSets": "SVM", }, @@ -354,6 +378,7 @@ "javaCompliance": "11+", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "workingSets": "SVM", }, @@ -372,6 +397,7 @@ "javaCompliance": "11+", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "workingSets": "SVM", }, @@ -388,6 +414,7 @@ "javaCompliance": "11+", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "workingSets": "SVM", }, @@ -408,6 +435,7 @@ "javaCompliance": "11+", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "workingSets": "SVM", "spotbugs": "false", @@ -428,6 +456,7 @@ "javaCompliance": "11+", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "workingSets": "SVM", "spotbugs": "false", @@ -516,6 +545,7 @@ "checkstyleVersion": "8.36.1", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "workingSets": "SVM", }, @@ -535,6 +565,7 @@ "javaCompliance": "17+", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "workingSets": "SVM", }, @@ -670,6 +701,7 @@ "workingSets": "SVM", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "javaCompliance": "11+", "spotbugs": "false", @@ -689,6 +721,7 @@ "workingSets": "SVM", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "javaCompliance": "11+", "spotbugs": "false", @@ -717,6 +750,7 @@ "workingSets": "SVM", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "javaCompliance": "11+", "spotbugs": "false", @@ -734,6 +768,7 @@ "workingSets": "SVM", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "javaCompliance": "17+", "spotbugs": "false", @@ -752,6 +787,7 @@ "workingSets": "SVM", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "javaCompliance": "11+", "spotbugs": "false", @@ -764,9 +800,6 @@ "dependencies" : ["sdk:GRAAL_SDK"], "checkstyle" : "com.oracle.svm.hosted", "javaCompliance": "11+", - "annotationProcessors" : [ - "compiler:GRAAL_PROCESSOR", - ], "workingSets" : "SVM", "spotbugs" : "false", }, @@ -789,7 +822,10 @@ }, "checkstyle" : "com.oracle.svm.hosted", "javaCompliance": "11+", - "annotationProcessors" : ["compiler:GRAAL_PROCESSOR"], + "annotationProcessors": [ + "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", + ], "workingSets" : "SVM", "spotbugs" : "false", }, @@ -814,6 +850,7 @@ "javaCompliance": "11+", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], }, @@ -829,6 +866,7 @@ "workingSets": "SVM", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "javaCompliance": "11+", "spotbugs": "false", @@ -848,6 +886,7 @@ "javaCompliance": "11+", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "workingSets": "SVM", }, @@ -862,6 +901,7 @@ "javaCompliance": "11+", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "workingSets": "SVM", }, @@ -885,6 +925,7 @@ "javaCompliance": "11+", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "workingSets": "SVM", }, @@ -898,6 +939,8 @@ "checkstyle": "com.oracle.svm.hosted", "javaCompliance": "11+", "annotationProcessors": [ + "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", "truffle:TRUFFLE_DSL_PROCESSOR", ], "workingSets": "SVM", @@ -913,6 +956,8 @@ "checkstyle": "com.oracle.svm.hosted", "javaCompliance": "11+", "annotationProcessors": [ + "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", "truffle:TRUFFLE_DSL_PROCESSOR", ], "workingSets": "SVM", @@ -928,6 +973,8 @@ "checkstyle": "com.oracle.svm.hosted", "javaCompliance": "11+", "annotationProcessors": [ + "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", "truffle:TRUFFLE_DSL_PROCESSOR", ], "workingSets": "SVM", @@ -943,6 +990,7 @@ "javaCompliance": "11+", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "workingSets": "SVM", "spotbugs": "false", @@ -962,6 +1010,7 @@ "javaCompliance": "11+", "annotationProcessors" : [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "workingSets" : "SVM", "spotbugs": "false", @@ -983,6 +1032,7 @@ "javaCompliance": "11+", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "defaultBuild": False, }, @@ -1016,6 +1066,7 @@ "workingSets": "SVM", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "javaCompliance": "11+", "spotbugs": "false", @@ -1036,6 +1087,7 @@ "workingSets": "SVM", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "javaCompliance": "11+", "spotbugs": "false", @@ -1054,6 +1106,7 @@ "workingSets": "SVM", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "javaCompliance": "11+", "spotbugs": "false", @@ -1072,6 +1125,7 @@ "workingSets": "SVM", "annotationProcessors": [ "compiler:GRAAL_PROCESSOR", + "SVM_PROCESSOR", ], "javaCompliance": "11+", }, @@ -1081,6 +1135,17 @@ # # External Distributions # + "SVM_PROCESSOR" : { + "subDir": "src", + "dependencies" : [ + "com.oracle.svm.processor", + ], + "distDependencies": [ + "compiler:GRAAL_PROCESSOR", + ], + "maven": False, + }, + "SVM": { "subDir": "src", "description" : "SubstrateVM image builder components", @@ -1114,8 +1179,7 @@ "com.oracle.svm.hosted to java.base", "com.oracle.svm.hosted.agent to java.instrument", "com.oracle.svm.truffle.api to org.graalvm.truffle", - "com.oracle.svm.core.option to com.oracle.svm_enterprise.ml_dataset", - "* to org.graalvm.nativeimage.base,jdk.internal.vm.compiler,org.graalvm.nativeimage.driver,org.graalvm.nativeimage.configure,org.graalvm.nativeimage.librarysupport,org.graalvm.nativeimage.junitsupport,org.graalvm.nativeimage.llvm,org.graalvm.nativeimage.agent.jvmtibase,org.graalvm.nativeimage.agent.tracing,org.graalvm.nativeimage.agent.diagnostics,com.oracle.svm.svm_enterprise", + "* to org.graalvm.nativeimage.base,jdk.internal.vm.compiler,org.graalvm.nativeimage.driver,org.graalvm.nativeimage.configure,org.graalvm.nativeimage.librarysupport,org.graalvm.nativeimage.junitsupport,org.graalvm.nativeimage.llvm,org.graalvm.nativeimage.agent.jvmtibase,org.graalvm.nativeimage.agent.tracing,org.graalvm.nativeimage.agent.diagnostics,com.oracle.svm.svm_enterprise,com.oracle.svm.svm_enterprise.llvm,com.oracle.svm_enterprise.ml_dataset", ], "opens" : [ "com.oracle.svm.core to jdk.internal.vm.compiler", @@ -1144,6 +1208,7 @@ "com.oracle.svm.hosted.agent.NativeImageBytecodeInstrumentationAgentExtension", "com.oracle.svm.hosted.NativeImageClassLoaderPostProcessing", "java.util.spi.ResourceBundleControlProvider", + "com.oracle.svm.core.feature.AutomaticallyRegisteredFeatureServiceRegistration", ], "requiresConcealed": { "jdk.internal.vm.ci": [ diff --git a/substratevm/src/com.oracle.svm.configure/resources/META-INF/native-image/com.oracle.svm/configure/native-image.properties b/substratevm/src/com.oracle.svm.configure/resources/META-INF/native-image/com.oracle.svm/configure/native-image.properties new file mode 100644 index 000000000000..74d654890bd5 --- /dev/null +++ b/substratevm/src/com.oracle.svm.configure/resources/META-INF/native-image/com.oracle.svm/configure/native-image.properties @@ -0,0 +1 @@ +Args = --features=com.oracle.svm.configure.config.SignatureUtilFeature diff --git a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/SignatureUtil.java b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/SignatureUtil.java index 077fc21fdee5..216c9345dca7 100644 --- a/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/SignatureUtil.java +++ b/substratevm/src/com.oracle.svm.configure/src/com/oracle/svm/configure/config/SignatureUtil.java @@ -29,7 +29,6 @@ import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.util.ModuleSupport; import jdk.vm.ci.meta.JavaKind; @@ -101,7 +100,6 @@ public static String toInternalClassName(String qualifiedForNameString) { } } -@AutomaticFeature class SignatureUtilFeature implements Feature { @Override public void afterRegistration(AfterRegistrationAccess access) { diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AlignedHeapChunk.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AlignedHeapChunk.java index 0c076173d6f2..f689a2b96404 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AlignedHeapChunk.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AlignedHeapChunk.java @@ -30,16 +30,14 @@ import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.struct.RawStructure; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.MemoryWalker; -import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.AlwaysInline; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.MemoryWalker; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.genscavenge.remset.RememberedSet; import com.oracle.svm.core.heap.ObjectVisitor; import com.oracle.svm.core.util.PointerUtils; @@ -154,6 +152,7 @@ static MemoryWalker.HeapChunkAccess getMemoryWal } /** Methods for a {@link MemoryWalker} to access an aligned heap chunk. */ + @AutomaticallyRegisteredImageSingleton(onlyWith = UseSerialOrEpsilonGC.class) static final class MemoryWalkerAccessImpl extends HeapChunk.MemoryWalkerAccessImpl { @Platforms(Platform.HOSTED_ONLY.class) @@ -171,16 +170,3 @@ public UnsignedWord getAllocationStart(AlignedHeapChunk.AlignedHeader heapChunk) } } } - -@AutomaticFeature -class AlignedHeapChunkMemoryWalkerAccessFeature implements Feature { - @Override - public boolean isInConfiguration(IsInConfigurationAccess access) { - return SubstrateOptions.UseSerialGC.getValue() || SubstrateOptions.UseEpsilonGC.getValue(); - } - - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(AlignedHeapChunk.MemoryWalkerAccessImpl.class, new AlignedHeapChunk.MemoryWalkerAccessImpl()); - } -} diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/JfrGCEventSupport.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/JfrGCEventSupport.java index 5b1a474db52b..5c813ee3c3fc 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/JfrGCEventSupport.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/JfrGCEventSupport.java @@ -27,12 +27,12 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.StackValue; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.UnsignedWord; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.heap.GCCause; import com.oracle.svm.core.jfr.HasJfrSupport; import com.oracle.svm.core.jfr.JfrEvent; @@ -137,8 +137,8 @@ private int popPhase() { } } -@AutomaticFeature -class JfrGCEventFeature implements Feature { +@AutomaticallyRegisteredFeature +class JfrGCEventFeature implements InternalFeature { @Override public boolean isInConfiguration(IsInConfigurationAccess access) { return SubstrateOptions.UseSerialGC.getValue(); diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/PinnedObjectImpl.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/PinnedObjectImpl.java index 2e896a58770a..f58a5b910776 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/PinnedObjectImpl.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/PinnedObjectImpl.java @@ -26,14 +26,13 @@ import org.graalvm.compiler.word.Word; import org.graalvm.nativeimage.PinnedObject; -import org.graalvm.nativeimage.Platform; -import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.impl.PinnedObjectSupport; import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.heap.ObjectHeader; import com.oracle.svm.core.hub.DynamicHub; import com.oracle.svm.core.hub.LayoutEncoding; @@ -41,12 +40,10 @@ import com.oracle.svm.core.thread.VMOperation; /** Support for pinning objects to a memory address with {@link PinnedObject}. */ -public final class PinnedObjectImpl implements PinnedObject { - public static class PinnedObjectSupportImpl implements PinnedObjectSupport { - @Platforms(Platform.HOSTED_ONLY.class) - public PinnedObjectSupportImpl() { - } +final class PinnedObjectImpl implements PinnedObject { + @AutomaticallyRegisteredImageSingleton(value = PinnedObjectSupport.class, onlyWith = UseSerialOrEpsilonGC.class) + static class PinnedObjectSupportImpl implements PinnedObjectSupport { @Override public PinnedObject create(Object object) { PinnedObjectImpl result = new PinnedObjectImpl(object); diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/UnalignedHeapChunk.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/UnalignedHeapChunk.java index 8761821484bd..dbe9f164a2d4 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/UnalignedHeapChunk.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/UnalignedHeapChunk.java @@ -30,17 +30,15 @@ import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.struct.RawStructure; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.MemoryWalker; -import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.AlwaysInline; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.MemoryWalker; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.config.ConfigurationValues; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.genscavenge.remset.RememberedSet; import com.oracle.svm.core.heap.ObjectVisitor; import com.oracle.svm.core.util.UnsignedUtils; @@ -164,6 +162,7 @@ public static MemoryWalker.HeapChunkAccess g return ImageSingletons.lookup(UnalignedHeapChunk.MemoryWalkerAccessImpl.class); } + @AutomaticallyRegisteredImageSingleton(onlyWith = UseSerialOrEpsilonGC.class) static final class MemoryWalkerAccessImpl extends HeapChunk.MemoryWalkerAccessImpl { @Platforms(Platform.HOSTED_ONLY.class) @@ -181,16 +180,3 @@ public UnsignedWord getAllocationStart(UnalignedHeapChunk.UnalignedHeader heapCh } } } - -@AutomaticFeature -class UnalignedHeapChunkMemoryWalkerAccessFeature implements Feature { - @Override - public boolean isInConfiguration(IsInConfigurationAccess access) { - return SubstrateOptions.UseSerialGC.getValue() || SubstrateOptions.UseEpsilonGC.getValue(); - } - - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(UnalignedHeapChunk.MemoryWalkerAccessImpl.class, new UnalignedHeapChunk.MemoryWalkerAccessImpl()); - } -} diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/UseSerialOrEpsilonGC.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/UseSerialOrEpsilonGC.java index cce0bb85bf71..245874b4f0ef 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/UseSerialOrEpsilonGC.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/UseSerialOrEpsilonGC.java @@ -32,7 +32,7 @@ import com.oracle.svm.core.SubstrateOptions; @Platforms(Platform.HOSTED_ONLY.class) -class UseSerialOrEpsilonGC implements BooleanSupplier { +public class UseSerialOrEpsilonGC implements BooleanSupplier { @Override public boolean getAsBoolean() { return SubstrateOptions.UseSerialGC.getValue() || SubstrateOptions.UseEpsilonGC.getValue(); diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/graal/BarrierSnippets.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/graal/BarrierSnippets.java index 1fcb9e8472b7..46aae819b809 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/graal/BarrierSnippets.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/graal/BarrierSnippets.java @@ -54,13 +54,14 @@ import org.graalvm.word.UnsignedWord; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.genscavenge.ObjectHeaderImpl; import com.oracle.svm.core.genscavenge.SerialGCOptions; import com.oracle.svm.core.genscavenge.remset.RememberedSet; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.snippets.NodeLoweringProvider; import com.oracle.svm.core.graal.snippets.SubstrateTemplates; import com.oracle.svm.core.heap.StoredContinuation; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.Counter; import com.oracle.svm.core.util.CounterFeature; @@ -195,8 +196,8 @@ class BarrierSnippetCounters { final Counter postWriteBarrierUnaligned = new Counter(counters, "postWriteBarrierUnaligned", "unaligned object path of post-write barriers"); } -@AutomaticFeature -class BarrierSnippetCountersFeature implements Feature { +@AutomaticallyRegisteredFeature +class BarrierSnippetCountersFeature implements InternalFeature { @Override public boolean isInConfiguration(IsInConfigurationAccess access) { return SubstrateOptions.UseSerialGC.getValue() && SubstrateOptions.useRememberedSet(); diff --git a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/graal/GenScavengeGCFeature.java b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/graal/GenScavengeGCFeature.java index b034d570dfb7..8d7fd2d0af2a 100644 --- a/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/graal/GenScavengeGCFeature.java +++ b/substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/graal/GenScavengeGCFeature.java @@ -33,10 +33,10 @@ import org.graalvm.compiler.phases.util.Providers; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.hosted.Feature; -import org.graalvm.nativeimage.impl.PinnedObjectSupport; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.genscavenge.ChunkedImageHeapLayouter; import com.oracle.svm.core.genscavenge.CompleteGarbageCollectorMXBean; import com.oracle.svm.core.genscavenge.HeapImpl; @@ -44,13 +44,11 @@ import com.oracle.svm.core.genscavenge.ImageHeapInfo; import com.oracle.svm.core.genscavenge.IncrementalGarbageCollectorMXBean; import com.oracle.svm.core.genscavenge.LinearImageHeapLayouter; -import com.oracle.svm.core.genscavenge.PinnedObjectImpl.PinnedObjectSupportImpl; import com.oracle.svm.core.genscavenge.jvmstat.EpsilonGCPerfData; import com.oracle.svm.core.genscavenge.jvmstat.SerialGCPerfData; import com.oracle.svm.core.genscavenge.remset.CardTableBasedRememberedSet; import com.oracle.svm.core.genscavenge.remset.NoRememberedSet; import com.oracle.svm.core.genscavenge.remset.RememberedSet; -import com.oracle.svm.core.graal.InternalFeature; import com.oracle.svm.core.graal.meta.RuntimeConfiguration; import com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider; import com.oracle.svm.core.graal.snippets.GCAllocationSupport; @@ -60,23 +58,23 @@ import com.oracle.svm.core.heap.BarrierSetProvider; import com.oracle.svm.core.heap.Heap; import com.oracle.svm.core.image.ImageHeapLayouter; -import com.oracle.svm.core.jdk.RuntimeFeature; +import com.oracle.svm.core.jdk.RuntimeSupportFeature; import com.oracle.svm.core.jdk.management.ManagementFeature; import com.oracle.svm.core.jdk.management.ManagementSupport; import com.oracle.svm.core.jvmstat.PerfDataFeature; import com.oracle.svm.core.jvmstat.PerfDataHolder; import com.oracle.svm.core.jvmstat.PerfManager; -@AutomaticFeature +@AutomaticallyRegisteredFeature class GenScavengeGCFeature implements InternalFeature { @Override public boolean isInConfiguration(IsInConfigurationAccess access) { - return SubstrateOptions.UseSerialGC.getValue() || SubstrateOptions.UseEpsilonGC.getValue(); + return new com.oracle.svm.core.genscavenge.UseSerialOrEpsilonGC().getAsBoolean(); } @Override public List> getRequiredFeatures() { - return Arrays.asList(RuntimeFeature.class, ManagementFeature.class, PerfDataFeature.class, AllocationFeature.class); + return Arrays.asList(RuntimeSupportFeature.class, ManagementFeature.class, PerfDataFeature.class, AllocationFeature.class); } @Override @@ -96,7 +94,6 @@ public void duringSetup(DuringSetupAccess access) { managementSupport.addPlatformManagedObjectSingleton(java.lang.management.MemoryMXBean.class, new HeapImplMemoryMXBean()); managementSupport.addPlatformManagedObjectList(com.sun.management.GarbageCollectorMXBean.class, Arrays.asList(new IncrementalGarbageCollectorMXBean(), new CompleteGarbageCollectorMXBean())); - ImageSingletons.add(PinnedObjectSupport.class, new PinnedObjectSupportImpl()); if (ImageSingletons.contains(PerfManager.class)) { ImageSingletons.lookup(PerfManager.class).register(createPerfData()); } diff --git a/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/AArch64NativeImagePatcher.java b/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/AArch64NativePatchConsumerFactory.java similarity index 94% rename from substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/AArch64NativeImagePatcher.java rename to substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/AArch64NativePatchConsumerFactory.java index 152794253e4b..be90d999ac66 100644 --- a/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/AArch64NativeImagePatcher.java +++ b/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/AArch64NativePatchConsumerFactory.java @@ -30,25 +30,16 @@ import org.graalvm.compiler.asm.aarch64.AArch64Assembler.SingleInstructionAnnotation; import org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler; import org.graalvm.compiler.code.CompilationResult; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.graal.code.NativeImagePatcher; import com.oracle.svm.core.graal.code.PatchConsumerFactory; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.VMError; -@AutomaticFeature -@Platforms({Platform.AARCH64.class}) -public class AArch64NativeImagePatcher implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(PatchConsumerFactory.NativePatchConsumerFactory.class, new AArch64NativePatchConsumerFactory()); - } -} - +@AutomaticallyRegisteredImageSingleton(PatchConsumerFactory.NativePatchConsumerFactory.class) +@Platforms(Platform.AARCH64.class) final class AArch64NativePatchConsumerFactory extends PatchConsumerFactory.NativePatchConsumerFactory { @Override public Consumer newConsumer(CompilationResult compilationResult) { diff --git a/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/SubstrateAArch64Feature.java b/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/SubstrateAArch64Feature.java index ca6852019b68..972424d36107 100644 --- a/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/SubstrateAArch64Feature.java +++ b/substratevm/src/com.oracle.svm.core.graal.aarch64/src/com/oracle/svm/core/graal/aarch64/SubstrateAArch64Feature.java @@ -34,25 +34,25 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.svm.core.ReservedRegisters; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.code.SubstrateBackend; import com.oracle.svm.core.graal.code.SubstrateBackendFactory; import com.oracle.svm.core.graal.code.SubstrateLoweringProviderFactory; import com.oracle.svm.core.graal.code.SubstrateRegisterConfigFactory; import com.oracle.svm.core.graal.code.SubstrateSuitesCreatorProvider; import com.oracle.svm.core.graal.meta.SubstrateRegisterConfig.ConfigKind; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import jdk.vm.ci.code.RegisterConfig; import jdk.vm.ci.code.TargetDescription; import jdk.vm.ci.meta.MetaAccessProvider; -@AutomaticFeature +@AutomaticallyRegisteredFeature @Platforms(Platform.AARCH64.class) -class SubstrateAArch64Feature implements Feature { +class SubstrateAArch64Feature implements InternalFeature { @Override public void afterRegistration(AfterRegistrationAccess access) { diff --git a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64NativeImagePatcher.java b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64NativeImagePatcher.java index 56399ca08ece..e08b4ab19a2f 100644 --- a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64NativeImagePatcher.java +++ b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/AMD64NativeImagePatcher.java @@ -30,25 +30,16 @@ import org.graalvm.compiler.asm.amd64.AMD64BaseAssembler.AddressDisplacementAnnotation; import org.graalvm.compiler.asm.amd64.AMD64BaseAssembler.OperandDataAnnotation; import org.graalvm.compiler.code.CompilationResult; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.graal.code.NativeImagePatcher; import com.oracle.svm.core.graal.code.PatchConsumerFactory; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.VMError; -@AutomaticFeature -@Platforms({Platform.AMD64.class}) -class AMD64NativeImagePatcherFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(PatchConsumerFactory.NativePatchConsumerFactory.class, new AMD64NativePatchConsumerFactory()); - } -} - +@AutomaticallyRegisteredImageSingleton(PatchConsumerFactory.NativePatchConsumerFactory.class) +@Platforms(Platform.AMD64.class) final class AMD64NativePatchConsumerFactory extends PatchConsumerFactory.NativePatchConsumerFactory { @Override public Consumer newConsumer(CompilationResult compilationResult) { diff --git a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64Feature.java b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64Feature.java index 66077dfb687e..59a2ad504e42 100644 --- a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64Feature.java +++ b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64Feature.java @@ -34,25 +34,25 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.svm.core.ReservedRegisters; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.code.SubstrateBackend; import com.oracle.svm.core.graal.code.SubstrateBackendFactory; import com.oracle.svm.core.graal.code.SubstrateLoweringProviderFactory; import com.oracle.svm.core.graal.code.SubstrateRegisterConfigFactory; import com.oracle.svm.core.graal.code.SubstrateSuitesCreatorProvider; import com.oracle.svm.core.graal.meta.SubstrateRegisterConfig.ConfigKind; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import jdk.vm.ci.code.RegisterConfig; import jdk.vm.ci.code.TargetDescription; import jdk.vm.ci.meta.MetaAccessProvider; -@AutomaticFeature +@AutomaticallyRegisteredFeature @Platforms(Platform.AMD64.class) -class SubstrateAMD64Feature implements Feature { +class SubstrateAMD64Feature implements InternalFeature { @Override public void afterRegistration(AfterRegistrationAccess access) { diff --git a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64GraphBuilderPlugins.java b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64GraphBuilderPlugins.java index 68559a6f2fba..2c07d78008cb 100644 --- a/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64GraphBuilderPlugins.java +++ b/substratevm/src/com.oracle.svm.core.graal.amd64/src/com/oracle/svm/core/graal/amd64/SubstrateAMD64GraphBuilderPlugins.java @@ -39,13 +39,13 @@ import com.oracle.svm.core.ParsingReason; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.ResolvedJavaMethod; -@AutomaticFeature +@AutomaticallyRegisteredFeature @Platforms(Platform.AMD64.class) public class SubstrateAMD64GraphBuilderPlugins implements InternalFeature { diff --git a/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/LLVMFeature.java b/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/LLVMFeature.java index ff0232cea5a5..e7cbba6b35a8 100644 --- a/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/LLVMFeature.java +++ b/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/LLVMFeature.java @@ -40,8 +40,7 @@ import com.oracle.graal.pointsto.meta.AnalysisMethod; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.code.SubstrateBackend; import com.oracle.svm.core.graal.code.SubstrateBackendFactory; import com.oracle.svm.core.graal.code.SubstrateLoweringProviderFactory; @@ -55,6 +54,7 @@ import com.oracle.svm.core.graal.snippets.NodeLoweringProvider; import com.oracle.svm.core.option.HostedOptionKey; import com.oracle.svm.core.snippets.ExceptionUnwind; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.UserError; import com.oracle.svm.hosted.FeatureImpl; import com.oracle.svm.hosted.code.CompileQueue; @@ -70,7 +70,7 @@ * lowerings, code cache and exception handling mechanism required to emit LLVM bitcode * from Graal graphs, and compile this bitcode into machine code. */ -@AutomaticFeature +@AutomaticallyRegisteredFeature @Platforms({Platform.LINUX.class, Platform.DARWIN.class}) public class LLVMFeature implements Feature, InternalFeature { diff --git a/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/util/LLVMTargetSpecific.java b/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/util/LLVMTargetSpecific.java index d0ee10a1e5f0..6321b4a9fee1 100644 --- a/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/util/LLVMTargetSpecific.java +++ b/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/util/LLVMTargetSpecific.java @@ -31,11 +31,11 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.svm.core.FrameAccess; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; /** * LLVM target-specific inline assembly snippets and information. @@ -108,9 +108,9 @@ default String getLLVMRegisterName(String register) { String getScratchRegister(); } -@AutomaticFeature +@AutomaticallyRegisteredFeature @Platforms(Platform.AMD64.class) -class LLVMAMD64TargetSpecificFeature implements Feature { +class LLVMAMD64TargetSpecificFeature implements InternalFeature { private static final int AMD64_RSP_IDX = 7; private static final int AMD64_RBP_IDX = 6; @@ -190,9 +190,9 @@ public String getScratchRegister() { } } -@AutomaticFeature +@AutomaticallyRegisteredFeature @Platforms(Platform.AARCH64.class) -class LLVMAArch64TargetSpecificFeature implements Feature { +class LLVMAArch64TargetSpecificFeature implements InternalFeature { private static final int AARCH64_FP_IDX = 29; private static final int AARCH64_SP_IDX = 31; diff --git a/substratevm/src/com.oracle.svm.core.jdk17/src/com/oracle/svm/core/jdk17/RecordSupportJDK17OrLater.java b/substratevm/src/com.oracle.svm.core.jdk17/src/com/oracle/svm/core/jdk17/RecordSupportJDK17OrLater.java index 7a1206f4f558..9956715f8b1e 100644 --- a/substratevm/src/com.oracle.svm.core.jdk17/src/com/oracle/svm/core/jdk17/RecordSupportJDK17OrLater.java +++ b/substratevm/src/com.oracle.svm.core.jdk17/src/com/oracle/svm/core/jdk17/RecordSupportJDK17OrLater.java @@ -30,14 +30,12 @@ import java.util.Arrays; import java.util.Objects; -import org.graalvm.compiler.serviceprovider.JavaVersionUtil; -import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; - -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.jdk.JDK17OrLater; import com.oracle.svm.core.jdk.RecordSupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.VMError; +@AutomaticallyRegisteredImageSingleton(value = RecordSupport.class, onlyWith = JDK17OrLater.class) final class RecordSupportJDK17OrLater extends RecordSupport { @Override public boolean isRecord(Class clazz) { @@ -71,16 +69,3 @@ public Constructor getCanonicalRecordConstructor(Class clazz) { } } } - -@AutomaticFeature -final class RecordFeatureJDK17OrLater implements Feature { - @Override - public boolean isInConfiguration(IsInConfigurationAccess access) { - return JavaVersionUtil.JAVA_SPEC >= 17; - } - - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(RecordSupport.class, new RecordSupportJDK17OrLater()); - } -} diff --git a/substratevm/src/com.oracle.svm.core.jdk17/src/com/oracle/svm/core/jdk17/SealedClassSupportJDK17OrLater.java b/substratevm/src/com.oracle.svm.core.jdk17/src/com/oracle/svm/core/jdk17/SealedClassSupportJDK17OrLater.java index b1650d926bd2..b8d4dfef0c90 100644 --- a/substratevm/src/com.oracle.svm.core.jdk17/src/com/oracle/svm/core/jdk17/SealedClassSupportJDK17OrLater.java +++ b/substratevm/src/com.oracle.svm.core.jdk17/src/com/oracle/svm/core/jdk17/SealedClassSupportJDK17OrLater.java @@ -24,13 +24,11 @@ */ package com.oracle.svm.core.jdk17; -import org.graalvm.compiler.serviceprovider.JavaVersionUtil; -import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; - -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.jdk.JDK17OrLater; import com.oracle.svm.core.jdk.SealedClassSupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +@AutomaticallyRegisteredImageSingleton(value = SealedClassSupport.class, onlyWith = JDK17OrLater.class) final class SealedClassSupportJDK17OrLater extends SealedClassSupport { @Override @@ -43,17 +41,3 @@ public Class[] getPermittedSubclasses(Class clazz) { return clazz.getPermittedSubclasses(); } } - -@AutomaticFeature -final class SealedClassFeatureJDK17OrLater implements Feature { - - @Override - public boolean isInConfiguration(IsInConfigurationAccess access) { - return JavaVersionUtil.JAVA_SPEC >= 17; - } - - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(SealedClassSupport.class, new SealedClassSupportJDK17OrLater()); - } -} diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixLoadAverageSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixLoadAverageSupport.java index 8c9338fac518..66b174800dc6 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixLoadAverageSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixLoadAverageSupport.java @@ -24,14 +24,13 @@ */ package com.oracle.svm.core.posix; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.PinnedObject; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.jdk.LoadAverageSupport; import com.oracle.svm.core.posix.headers.Stdlib; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +@AutomaticallyRegisteredImageSingleton(LoadAverageSupport.class) class PosixLoadAverageSupport implements LoadAverageSupport { @Override public int getLoadAverage(double[] loadavg, int nelems) { @@ -44,11 +43,3 @@ public int getLoadAverage(double[] loadavg, int nelems) { } } } - -@AutomaticFeature -class PosixLoadAverageSupportFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(LoadAverageSupport.class, new PosixLoadAverageSupport()); - } -} 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 ad1a84a668dc..344d2b6e868f 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 @@ -28,17 +28,17 @@ import org.graalvm.nativeimage.LogHandler; import org.graalvm.nativeimage.c.type.CCharPointer; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.UnsignedWord; import com.oracle.svm.core.SubstrateDiagnostics; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.headers.LibC; import com.oracle.svm.core.log.Log; import com.oracle.svm.core.thread.VMThreads; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; -@AutomaticFeature -class PosixLogHandlerFeature implements Feature { +@AutomaticallyRegisteredFeature +class PosixLogHandlerFeature implements InternalFeature { @Override public void beforeAnalysis(BeforeAnalysisAccess access) { Log.finalizeDefaultLogHandler(new PosixLogHandler()); diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixNativeLibraryFeature.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixNativeLibraryFeature.java index bfd75b39fe89..308b280c0509 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixNativeLibraryFeature.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixNativeLibraryFeature.java @@ -30,7 +30,6 @@ import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.nativeimage.c.type.CTypeConversion.CCharPointerHolder; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.InternalPlatform; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; @@ -38,8 +37,8 @@ import com.oracle.svm.core.Isolates; import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.annotate.TargetClass; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.headers.LibC; import com.oracle.svm.core.jdk.JNIPlatformNativeLibrarySupport; import com.oracle.svm.core.jdk.Jvm; @@ -49,9 +48,10 @@ import com.oracle.svm.core.posix.headers.Dlfcn; import com.oracle.svm.core.posix.headers.Resource; import com.oracle.svm.core.posix.headers.darwin.DarwinSyslimits; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; -@AutomaticFeature -class PosixNativeLibraryFeature implements Feature { +@AutomaticallyRegisteredFeature +class PosixNativeLibraryFeature implements InternalFeature { @Override public void afterRegistration(AfterRegistrationAccess access) { PosixNativeLibrarySupport.initialize(); diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixRawFileOperationSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixRawFileOperationSupport.java index 0455c12cc3fa..fe39bc674048 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixRawFileOperationSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixRawFileOperationSupport.java @@ -31,14 +31,14 @@ import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.type.CTypeConversion; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.Pointer; import org.graalvm.word.SignedWord; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.headers.LibC; import com.oracle.svm.core.os.AbstractRawFileOperationSupport; import com.oracle.svm.core.os.AbstractRawFileOperationSupport.RawFileOperationSupportHolder; @@ -159,8 +159,8 @@ private static int parseMode(FileAccessMode mode) { } } -@AutomaticFeature -class PosixRawFileOperationFeature implements Feature { +@AutomaticallyRegisteredFeature +class PosixRawFileOperationFeature implements InternalFeature { @Override public void beforeAnalysis(BeforeAnalysisAccess access) { ByteOrder nativeByteOrder = ByteOrder.nativeOrder(); diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSubstrateSegfaultHandler.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSubstrateSegfaultHandler.java index 6322b5c8c1ec..b5e0557ff76d 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSubstrateSegfaultHandler.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSubstrateSegfaultHandler.java @@ -24,24 +24,22 @@ */ package com.oracle.svm.core.posix; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.function.CEntryPoint; import org.graalvm.nativeimage.c.function.CEntryPoint.Publish; import org.graalvm.nativeimage.c.function.CEntryPointLiteral; import org.graalvm.nativeimage.c.struct.SizeOf; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.PointerBase; import org.graalvm.word.WordFactory; import com.oracle.svm.core.SubstrateSegfaultHandler; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.heap.RestrictHeapAccess; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.function.CEntryPointOptions; import com.oracle.svm.core.c.function.CEntryPointOptions.NoEpilogue; import com.oracle.svm.core.c.function.CEntryPointOptions.NoPrologue; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.headers.LibC; +import com.oracle.svm.core.heap.RestrictHeapAccess; import com.oracle.svm.core.log.Log; import com.oracle.svm.core.os.MemoryProtectionProvider; import com.oracle.svm.core.posix.headers.Signal; @@ -51,14 +49,7 @@ import com.oracle.svm.core.posix.headers.Signal.ucontext_t; import com.oracle.svm.core.util.VMError; -@AutomaticFeature -class PosixSubstrateSegfaultHandlerFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(SubstrateSegfaultHandler.class, new PosixSubstrateSegfaultHandler()); - } -} - +@AutomaticallyRegisteredImageSingleton(SubstrateSegfaultHandler.class) class PosixSubstrateSegfaultHandler extends SubstrateSegfaultHandler { @CEntryPoint(include = CEntryPoint.NotIncludedAutomatically.class, publishAs = Publish.NotPublished) @CEntryPointOptions(prologue = NoPrologue.class, epilogue = NoEpilogue.class) diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSubstrateSigprofHandler.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSubstrateSigprofHandler.java index 7c8560bd7580..adf030deab9c 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSubstrateSigprofHandler.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/PosixSubstrateSigprofHandler.java @@ -25,7 +25,6 @@ package com.oracle.svm.core.posix; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; @@ -34,29 +33,20 @@ import org.graalvm.nativeimage.c.function.CEntryPointLiteral; import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.nativeimage.c.type.VoidPointer; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.heap.RestrictHeapAccess; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.function.CEntryPointOptions; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.headers.LibC; +import com.oracle.svm.core.heap.RestrictHeapAccess; import com.oracle.svm.core.posix.headers.Pthread; import com.oracle.svm.core.posix.headers.Signal; import com.oracle.svm.core.posix.headers.Time; import com.oracle.svm.core.sampler.SubstrateSigprofHandler; -@AutomaticFeature -@SuppressWarnings("unused") -class PosixSubstrateSigprofHandlerFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(SubstrateSigprofHandler.class, new PosixSubstrateSigprofHandler()); - } -} - +@AutomaticallyRegisteredImageSingleton(SubstrateSigprofHandler.class) public class PosixSubstrateSigprofHandler extends SubstrateSigprofHandler { public static final long INTERVAL_S = 0; 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 a175d63978ba..eb75600efee6 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 @@ -43,24 +43,24 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.c.type.WordPointer; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordBase; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; 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.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.os.VirtualMemoryProvider; import com.oracle.svm.core.posix.headers.Unistd; import com.oracle.svm.core.util.PointerUtils; import com.oracle.svm.core.util.UnsignedUtils; -@AutomaticFeature -class PosixVirtualMemoryProviderFeature implements Feature { +@AutomaticallyRegisteredFeature +class PosixVirtualMemoryProviderFeature implements InternalFeature { @Override public void beforeAnalysis(BeforeAnalysisAccess access) { if (!ImageSingletons.contains(VirtualMemoryProvider.class)) { diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/SunMiscSubstitutions.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/SunMiscSubstitutions.java index 2f09934901f3..d16fc0e95a66 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/SunMiscSubstitutions.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/SunMiscSubstitutions.java @@ -28,23 +28,23 @@ import java.util.List; import java.util.concurrent.locks.ReentrantLock; -import com.oracle.svm.core.Uninterruptible; -import com.oracle.svm.core.c.function.CEntryPointOptions; -import com.oracle.svm.core.c.function.CEntryPointOptions.NoEpilogue; -import com.oracle.svm.core.c.function.CEntryPointOptions.NoPrologue; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.function.CEntryPoint; import org.graalvm.nativeimage.c.function.CEntryPoint.Publish; import org.graalvm.nativeimage.c.function.CEntryPointLiteral; import org.graalvm.nativeimage.c.type.CIntPointer; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; +import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; +import com.oracle.svm.core.c.function.CEntryPointOptions; +import com.oracle.svm.core.c.function.CEntryPointOptions.NoEpilogue; +import com.oracle.svm.core.c.function.CEntryPointOptions.NoPrologue; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.headers.LibC; import com.oracle.svm.core.jdk.RuntimeSupport; import com.oracle.svm.core.log.Log; @@ -370,8 +370,8 @@ protected long decrementCount() { } } -@AutomaticFeature -class IgnoreSIGPIPEFeature implements Feature { +@AutomaticallyRegisteredFeature +class IgnoreSIGPIPEFeature implements InternalFeature { @Override public void beforeAnalysis(BeforeAnalysisAccess access) { diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/UnmanagedMemorySupportImpl.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/UnmanagedMemorySupportImpl.java index eadc9cad6cfe..6c56453a7466 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/UnmanagedMemorySupportImpl.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/UnmanagedMemorySupportImpl.java @@ -24,17 +24,16 @@ */ package com.oracle.svm.core.posix; -import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.UnmanagedMemorySupport; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.headers.LibC; +@AutomaticallyRegisteredImageSingleton(UnmanagedMemorySupport.class) class UnmanagedMemorySupportImpl implements UnmanagedMemorySupport { @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) @@ -60,11 +59,3 @@ public void free(PointerBase ptr) { LibC.free(ptr); } } - -@AutomaticFeature -class UnmanagedMemoryFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(UnmanagedMemorySupport.class, new UnmanagedMemorySupportImpl()); - } -} diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/aarch64/AArch64DarwinUContextRegisterDumper.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/aarch64/AArch64DarwinUContextRegisterDumper.java index eddbff6b0faa..3ef56de91472 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/aarch64/AArch64DarwinUContextRegisterDumper.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/aarch64/AArch64DarwinUContextRegisterDumper.java @@ -26,16 +26,14 @@ import static com.oracle.svm.core.RegisterDumper.dumpReg; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.PointerBase; import org.graalvm.word.WordFactory; import com.oracle.svm.core.RegisterDumper; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.graal.aarch64.AArch64ReservedRegisters; import com.oracle.svm.core.log.Log; import com.oracle.svm.core.posix.UContextRegisterDumper; @@ -44,18 +42,14 @@ import jdk.vm.ci.aarch64.AArch64; -@Platforms({Platform.DARWIN_AARCH64.class}) -@AutomaticFeature -class AArch64DarwinUContextRegisterDumperFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { +@AutomaticallyRegisteredImageSingleton(RegisterDumper.class) +@Platforms(Platform.DARWIN_AARCH64.class) +class AArch64DarwinUContextRegisterDumper implements UContextRegisterDumper { + AArch64DarwinUContextRegisterDumper() { VMError.guarantee(AArch64.r27.equals(AArch64ReservedRegisters.HEAP_BASE_REGISTER_CANDIDATE)); VMError.guarantee(AArch64.r28.equals(AArch64ReservedRegisters.THREAD_REGISTER_CANDIDATE)); - ImageSingletons.add(RegisterDumper.class, new AArch64DarwinUContextRegisterDumper()); } -} -public class AArch64DarwinUContextRegisterDumper implements UContextRegisterDumper { @Override public void dumpRegisters(Log log, Signal.ucontext_t uContext, boolean printLocationInfo, boolean allowJavaHeapAccess, boolean allowUnsafeOperations) { Signal.AArch64DarwinMContext64 sigcontext = uContext.uc_mcontext_darwin_aarch64(); diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/aarch64/AArch64LinuxUContextRegisterDumper.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/aarch64/AArch64LinuxUContextRegisterDumper.java index d364efcd2bb8..5811fc973679 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/aarch64/AArch64LinuxUContextRegisterDumper.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/aarch64/AArch64LinuxUContextRegisterDumper.java @@ -26,16 +26,14 @@ import static com.oracle.svm.core.RegisterDumper.dumpReg; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.PointerBase; import org.graalvm.word.WordFactory; import com.oracle.svm.core.RegisterDumper; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.graal.aarch64.AArch64ReservedRegisters; import com.oracle.svm.core.log.Log; import com.oracle.svm.core.posix.UContextRegisterDumper; @@ -46,18 +44,14 @@ import jdk.vm.ci.aarch64.AArch64; -@Platforms({Platform.LINUX_AARCH64_BASE.class}) -@AutomaticFeature -class AArch64LinuxUContextRegisterDumperFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { +@AutomaticallyRegisteredImageSingleton(RegisterDumper.class) +@Platforms(Platform.LINUX_AARCH64_BASE.class) +class AArch64LinuxUContextRegisterDumper implements UContextRegisterDumper { + AArch64LinuxUContextRegisterDumper() { VMError.guarantee(AArch64.r27.equals(AArch64ReservedRegisters.HEAP_BASE_REGISTER_CANDIDATE)); VMError.guarantee(AArch64.r28.equals(AArch64ReservedRegisters.THREAD_REGISTER_CANDIDATE)); - ImageSingletons.add(RegisterDumper.class, new AArch64LinuxUContextRegisterDumper()); } -} -class AArch64LinuxUContextRegisterDumper implements UContextRegisterDumper { @Override public void dumpRegisters(Log log, ucontext_t uContext, boolean printLocationInfo, boolean allowJavaHeapAccess, boolean allowUnsafeOperations) { mcontext_linux_aarch64_t sigcontext = uContext.uc_mcontext_linux_aarch64(); diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/amd64/AMD64DarwinUContextRegisterDumper.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/amd64/AMD64DarwinUContextRegisterDumper.java index e685eeb0c6a0..1f31b005308d 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/amd64/AMD64DarwinUContextRegisterDumper.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/amd64/AMD64DarwinUContextRegisterDumper.java @@ -26,16 +26,14 @@ import static com.oracle.svm.core.RegisterDumper.dumpReg; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import com.oracle.svm.core.RegisterDumper; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.graal.amd64.AMD64ReservedRegisters; import com.oracle.svm.core.log.Log; import com.oracle.svm.core.posix.UContextRegisterDumper; @@ -45,18 +43,14 @@ import jdk.vm.ci.amd64.AMD64; -@Platforms({Platform.DARWIN_AMD64.class}) -@AutomaticFeature -class AMD64DarwinUContextRegisterDumperFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { +@AutomaticallyRegisteredImageSingleton(RegisterDumper.class) +@Platforms(Platform.DARWIN_AMD64.class) +class AMD64DarwinUContextRegisterDumper implements UContextRegisterDumper { + AMD64DarwinUContextRegisterDumper() { VMError.guarantee(AMD64.r14.equals(AMD64ReservedRegisters.HEAP_BASE_REGISTER_CANDIDATE)); VMError.guarantee(AMD64.r15.equals(AMD64ReservedRegisters.THREAD_REGISTER_CANDIDATE)); - ImageSingletons.add(RegisterDumper.class, new AMD64DarwinUContextRegisterDumper()); } -} -class AMD64DarwinUContextRegisterDumper implements UContextRegisterDumper { @Override public void dumpRegisters(Log log, ucontext_t uContext, boolean printLocationInfo, boolean allowJavaHeapAccess, boolean allowUnsafeOperations) { Signal.AMD64DarwinMContext64 sigcontext = uContext.uc_mcontext_darwin_amd64(); diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/amd64/AMD64LinuxUContextRegisterDumper.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/amd64/AMD64LinuxUContextRegisterDumper.java index 2a741211d9c4..597192eee1e5 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/amd64/AMD64LinuxUContextRegisterDumper.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/amd64/AMD64LinuxUContextRegisterDumper.java @@ -26,16 +26,14 @@ import static com.oracle.svm.core.RegisterDumper.dumpReg; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.PointerBase; import org.graalvm.word.WordFactory; import com.oracle.svm.core.RegisterDumper; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.graal.amd64.AMD64ReservedRegisters; import com.oracle.svm.core.log.Log; import com.oracle.svm.core.posix.UContextRegisterDumper; @@ -46,18 +44,14 @@ import jdk.vm.ci.amd64.AMD64; -@Platforms({Platform.LINUX_AMD64.class}) -@AutomaticFeature -class AMD64LinuxUContextRegisterDumperFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { +@AutomaticallyRegisteredImageSingleton(RegisterDumper.class) +@Platforms(Platform.LINUX_AMD64.class) +class AMD64LinuxUContextRegisterDumper implements UContextRegisterDumper { + AMD64LinuxUContextRegisterDumper() { VMError.guarantee(AMD64.r14.equals(AMD64ReservedRegisters.HEAP_BASE_REGISTER_CANDIDATE)); VMError.guarantee(AMD64.r15.equals(AMD64ReservedRegisters.THREAD_REGISTER_CANDIDATE)); - ImageSingletons.add(RegisterDumper.class, new AMD64LinuxUContextRegisterDumper()); } -} -class AMD64LinuxUContextRegisterDumper implements UContextRegisterDumper { @Override public void dumpRegisters(Log log, ucontext_t uContext, boolean printLocationInfo, boolean allowJavaHeapAccess, boolean allowUnsafeOperations) { GregsPointer gregs = uContext.uc_mcontext_linux_amd64_gregs(); diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinImageHeapProvider.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinImageHeapProvider.java index f49bc24a5d58..5f9a71c3ea3a 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinImageHeapProvider.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinImageHeapProvider.java @@ -24,28 +24,14 @@ */ package com.oracle.svm.core.posix.darwin; -import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.function.CEntryPointErrors; import com.oracle.svm.core.os.AbstractCopyingImageHeapProvider; -import com.oracle.svm.core.os.ImageHeapProvider; import com.oracle.svm.core.posix.headers.darwin.DarwinVirtualMemory; -@AutomaticFeature -class DarwinImageHeapProviderFeature implements Feature { - @Override - public void duringSetup(DuringSetupAccess access) { - if (!ImageSingletons.contains(ImageHeapProvider.class)) { - ImageSingletons.add(ImageHeapProvider.class, new DarwinImageHeapProvider()); - } - } -} - /** Creates image heaps on Darwin that are copy-on-write clones of the loaded image heap. */ public class DarwinImageHeapProvider extends AbstractCopyingImageHeapProvider { @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 6fac38d5c017..8876276dd74c 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 @@ -25,16 +25,17 @@ package com.oracle.svm.core.posix.darwin; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.headers.LibCSupport; - -@AutomaticFeature -class DarwinImageSingletonsFeature implements Feature { +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.os.ImageHeapProvider; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +@AutomaticallyRegisteredFeature +class DarwinImageSingletonsFeature implements InternalFeature { @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(LibCSupport.class, new DarwinLibCSupport()); + public void duringSetup(DuringSetupAccess access) { + if (!ImageSingletons.contains(ImageHeapProvider.class)) { + ImageSingletons.add(ImageHeapProvider.class, new DarwinImageHeapProvider()); + } } } diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinLibCSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinLibCSupport.java index 804bac001ac5..47a47956ba84 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinLibCSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinLibCSupport.java @@ -25,9 +25,12 @@ package com.oracle.svm.core.posix.darwin; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +import com.oracle.svm.core.headers.LibCSupport; import com.oracle.svm.core.posix.PosixLibCSupport; import com.oracle.svm.core.posix.headers.darwin.DarwinErrno; +@AutomaticallyRegisteredImageSingleton(LibCSupport.class) class DarwinLibCSupport extends PosixLibCSupport { @Override diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinProcessPropertiesSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinProcessPropertiesSupport.java index 50f56eb081fd..ad7db4d72afb 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinProcessPropertiesSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinProcessPropertiesSupport.java @@ -24,21 +24,20 @@ */ package com.oracle.svm.core.posix.darwin; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.PinnedObject; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CIntPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.ProcessPropertiesSupport; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.posix.PosixProcessPropertiesSupport; import com.oracle.svm.core.posix.headers.darwin.DarwinDyld; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.VMError; +@AutomaticallyRegisteredImageSingleton(ProcessPropertiesSupport.class) public class DarwinProcessPropertiesSupport extends PosixProcessPropertiesSupport { @Override @@ -61,13 +60,4 @@ public String getExecutableName() { return realpath(executableString); } } - - @AutomaticFeature - public static class ImagePropertiesFeature implements Feature { - - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(ProcessPropertiesSupport.class, new DarwinProcessPropertiesSupport()); - } - } } diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinStackOverflowSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinStackOverflowSupport.java index a286eb7d6f99..5064d7157f4b 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinStackOverflowSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinStackOverflowSupport.java @@ -24,29 +24,28 @@ */ package com.oracle.svm.core.posix.darwin; -import com.oracle.svm.core.util.VMError; -import org.graalvm.nativeimage.ImageSingletons; +import static com.oracle.svm.core.posix.headers.darwin.DarwinVirtualMemory.VM_PROT_READ; +import static com.oracle.svm.core.posix.headers.darwin.DarwinVirtualMemory.VM_PROT_WRITE; +import static com.oracle.svm.core.posix.headers.darwin.DarwinVirtualMemory.VM_REGION_BASIC_INFO_64; +import static com.oracle.svm.core.posix.headers.darwin.DarwinVirtualMemory.VM_REGION_SUBMAP_INFO_COUNT_64; +import static com.oracle.svm.core.posix.headers.darwin.DarwinVirtualMemory.mach_task_self; +import static com.oracle.svm.core.posix.headers.darwin.DarwinVirtualMemory.mach_vm_region; +import static com.oracle.svm.core.posix.headers.darwin.DarwinVirtualMemory.vm_region_basic_info_data_64_t; + import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.type.CIntPointer; import org.graalvm.nativeimage.c.type.WordPointer; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.posix.headers.Pthread; import com.oracle.svm.core.posix.headers.darwin.DarwinPthread; import com.oracle.svm.core.stack.StackOverflowCheck; +import com.oracle.svm.core.util.VMError; -import static com.oracle.svm.core.posix.headers.darwin.DarwinVirtualMemory.VM_PROT_READ; -import static com.oracle.svm.core.posix.headers.darwin.DarwinVirtualMemory.VM_PROT_WRITE; -import static com.oracle.svm.core.posix.headers.darwin.DarwinVirtualMemory.VM_REGION_BASIC_INFO_64; -import static com.oracle.svm.core.posix.headers.darwin.DarwinVirtualMemory.VM_REGION_SUBMAP_INFO_COUNT_64; -import static com.oracle.svm.core.posix.headers.darwin.DarwinVirtualMemory.mach_task_self; -import static com.oracle.svm.core.posix.headers.darwin.DarwinVirtualMemory.mach_vm_region; -import static com.oracle.svm.core.posix.headers.darwin.DarwinVirtualMemory.vm_region_basic_info_data_64_t; - +@AutomaticallyRegisteredImageSingleton(StackOverflowCheck.OSSupport.class) class DarwinStackOverflowSupport implements StackOverflowCheck.OSSupport { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) @Override @@ -123,11 +122,3 @@ public UnsignedWord lookupStackEnd(UnsignedWord requestedStackSize) { return stackaddr.subtract(stacksize); } } - -@AutomaticFeature -class DarwinStackOverflowSupportFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(StackOverflowCheck.OSSupport.class, new DarwinStackOverflowSupport()); - } -} diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinSubstitutions.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinSubstitutions.java index dc678baef0c1..97501596639f 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinSubstitutions.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinSubstitutions.java @@ -29,10 +29,8 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.StackValue; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.Uninterruptible; @@ -40,6 +38,7 @@ import com.oracle.svm.core.posix.headers.Time.timeval; import com.oracle.svm.core.posix.headers.Time.timezone; import com.oracle.svm.core.posix.headers.darwin.DarwinTime.MachTimebaseInfo; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; @TargetClass(java.lang.System.class) final class Target_java_lang_System_Darwin { @@ -83,6 +82,7 @@ public static String mapLibraryName(String libname) { } /** Additional static-like fields for {@link Target_java_lang_System_Darwin}. */ +@AutomaticallyRegisteredImageSingleton final class Util_java_lang_System { boolean timeBaseValid = false; boolean fastTime = false; @@ -93,15 +93,6 @@ final class Util_java_lang_System { } } -@AutomaticFeature -class DarwinSubsitutionsFeature implements Feature { - - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(Util_java_lang_System.class, new Util_java_lang_System()); - } -} - /** Dummy class to have a class with the file's name. */ public final class DarwinSubstitutions { } diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinSystemPropertiesSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinSystemPropertiesSupport.java index 9947b9a5497e..138ebb17d725 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinSystemPropertiesSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinSystemPropertiesSupport.java @@ -24,7 +24,6 @@ */ package com.oracle.svm.core.posix.darwin; -import com.oracle.svm.core.headers.LibC; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.StackValue; @@ -32,17 +31,18 @@ import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.nativeimage.c.type.CTypeConversion.CCharPointerHolder; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.headers.LibC; import com.oracle.svm.core.jdk.SystemPropertiesSupport; import com.oracle.svm.core.posix.PosixSystemPropertiesSupport; import com.oracle.svm.core.posix.headers.Limits; import com.oracle.svm.core.posix.headers.Stdlib; import com.oracle.svm.core.posix.headers.Unistd; import com.oracle.svm.core.posix.headers.darwin.Foundation; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; @CLibrary(value = "darwin", requireStatic = true) public class DarwinSystemPropertiesSupport extends PosixSystemPropertiesSupport { @@ -126,8 +126,8 @@ protected String osVersionValue() { } } -@AutomaticFeature -class DarwinSystemPropertiesFeature implements Feature { +@AutomaticallyRegisteredFeature +class DarwinSystemPropertiesFeature implements InternalFeature { @Override public void duringSetup(DuringSetupAccess access) { ImageSingletons.add(SystemPropertiesSupport.class, new DarwinSystemPropertiesSupport()); diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinThreadCpuTimeSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinThreadCpuTimeSupport.java index 3268e95d5c09..f6bb75e049c7 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinThreadCpuTimeSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinThreadCpuTimeSupport.java @@ -24,22 +24,20 @@ */ package com.oracle.svm.core.posix.darwin; -import com.oracle.svm.core.annotate.AutomaticFeature; +import org.graalvm.nativeimage.StackValue; +import org.graalvm.nativeimage.c.type.CIntPointer; + import com.oracle.svm.core.Uninterruptible; -import com.oracle.svm.core.thread.ThreadCpuTimeSupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.posix.headers.Pthread; import com.oracle.svm.core.posix.headers.Pthread.pthread_t; import com.oracle.svm.core.posix.headers.darwin.DarwinPthread; import com.oracle.svm.core.posix.headers.darwin.DarwinThreadInfo; import com.oracle.svm.core.posix.headers.darwin.DarwinThreadInfo.thread_basic_info_data_t; +import com.oracle.svm.core.thread.ThreadCpuTimeSupport; import com.oracle.svm.core.thread.VMThreads.OSThreadHandle; -import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.Platform; -import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.StackValue; -import org.graalvm.nativeimage.c.type.CIntPointer; -import org.graalvm.nativeimage.hosted.Feature; +@AutomaticallyRegisteredImageSingleton(ThreadCpuTimeSupport.class) final class DarwinThreadCpuTimeSupport implements ThreadCpuTimeSupport { @Override @@ -75,15 +73,4 @@ public long getThreadCpuTime(OSThreadHandle osThreadHandle, boolean includeSyste } return seconds * 1_000_000_000 + micros * 1_000; } - -} - -@Platforms({Platform.DARWIN.class}) -@AutomaticFeature -final class DarwinThreadCpuTimeFeature implements Feature { - - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(ThreadCpuTimeSupport.class, new DarwinThreadCpuTimeSupport()); - } } diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinPhysicalMemory.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/PhysicalMemorySupportImpl.java similarity index 52% rename from substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinPhysicalMemory.java rename to substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/PhysicalMemorySupportImpl.java index 103781783526..b88f8f54eeed 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/DarwinPhysicalMemory.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/darwin/PhysicalMemorySupportImpl.java @@ -24,50 +24,38 @@ */ package com.oracle.svm.core.posix.darwin; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.nativeimage.c.type.CIntPointer; import org.graalvm.nativeimage.c.type.WordPointer; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.headers.LibC; -import com.oracle.svm.core.heap.PhysicalMemory; +import com.oracle.svm.core.heap.PhysicalMemory.PhysicalMemorySupport; 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.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.VMError; -class DarwinPhysicalMemory extends PhysicalMemory { +@AutomaticallyRegisteredImageSingleton(PhysicalMemorySupport.class) +class PhysicalMemorySupportImpl implements PhysicalMemorySupport { - static class PhysicalMemorySupportImpl implements PhysicalMemorySupport { + @Override + public UnsignedWord size() { + CIntPointer namePointer = StackValue.get(2, CIntPointer.class); + namePointer.write(0, DarwinSysctl.CTL_HW()); + namePointer.write(1, DarwinSysctl.HW_MEMSIZE()); - @Override - public UnsignedWord size() { - CIntPointer namePointer = StackValue.get(2, CIntPointer.class); - namePointer.write(0, DarwinSysctl.CTL_HW()); - namePointer.write(1, DarwinSysctl.HW_MEMSIZE()); - - WordPointer physicalMemoryPointer = StackValue.get(WordPointer.class); - WordPointer physicalMemorySizePointer = StackValue.get(WordPointer.class); - physicalMemorySizePointer.write(SizeOf.unsigned(WordPointer.class)); - final int sysctlResult = Sysctl.sysctl(namePointer, 2, physicalMemoryPointer, physicalMemorySizePointer, WordFactory.nullPointer(), 0); - if (sysctlResult != 0) { - Log.log().string("DarwinPhysicalMemory.PhysicalMemorySupportImpl.size(): sysctl() returns with errno: ").signed(LibC.errno()).newline(); - throw VMError.shouldNotReachHere("DarwinPhysicalMemory.PhysicalMemorySupportImpl.size() failed."); - } - return physicalMemoryPointer.read(); - } - } - - @AutomaticFeature - static class PhysicalMemoryFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(PhysicalMemorySupport.class, new PhysicalMemorySupportImpl()); + WordPointer physicalMemoryPointer = StackValue.get(WordPointer.class); + WordPointer physicalMemorySizePointer = StackValue.get(WordPointer.class); + physicalMemorySizePointer.write(SizeOf.unsigned(WordPointer.class)); + final int sysctlResult = Sysctl.sysctl(namePointer, 2, physicalMemoryPointer, physicalMemorySizePointer, WordFactory.nullPointer(), 0); + if (sysctlResult != 0) { + Log.log().string("DarwinPhysicalMemory.PhysicalMemorySupportImpl.size(): sysctl() returns with errno: ").signed(LibC.errno()).newline(); + throw VMError.shouldNotReachHere("DarwinPhysicalMemory.PhysicalMemorySupportImpl.size() failed."); } + return physicalMemoryPointer.read(); } } diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/heapdump/AllocationFreeFileOutputStreamPosix.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/heapdump/AllocationFreeFileOutputStreamPosix.java index 04baa6fcc1b0..ad1234d4ba8c 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/heapdump/AllocationFreeFileOutputStreamPosix.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/heapdump/AllocationFreeFileOutputStreamPosix.java @@ -28,24 +28,26 @@ import java.io.FileOutputStream; import java.io.IOException; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.type.CCharPointer; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.heapdump.HeapDumpWriterImpl.AllocationFreeFileOutputStream; import com.oracle.svm.core.posix.PosixUtils; import com.oracle.svm.core.posix.headers.Unistd; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.VMError; /** * Posix implementation of allocation-free output stream created from FileOutputStream. * + * The limitation to Linux and Darwin is necessary because the implementation currently uses + * posix-dependent low-level code. See GR-9725. */ +@AutomaticallyRegisteredImageSingleton(AllocationFreeFileOutputStream.class) +@Platforms({Platform.LINUX.class, Platform.DARWIN.class}) final class AllocationFreeFileOutputStreamPosix extends AllocationFreeFileOutputStream { /** @@ -145,17 +147,3 @@ protected long position(long offset) { return Unistd.lseek(fd, WordFactory.signed(offset), Unistd.SEEK_SET()).rawValue(); } } - -/* - * The limitation to Linux and Darwin is necessary because the implementation currently uses - * posix-dependent low-level code. See GR-9725. - */ -@Platforms({Platform.LINUX.class, Platform.DARWIN.class}) -@AutomaticFeature -class AllocationFreeFileOutputStreamFeature implements Feature { - - @Override - public void afterRegistration(Feature.AfterRegistrationAccess access) { - ImageSingletons.add(AllocationFreeFileOutputStream.class, new AllocationFreeFileOutputStreamPosix()); - } -} diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/jvmstat/PosixPerfMemoryProvider.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/jvmstat/PosixPerfMemoryProvider.java index 2ae60312c4b2..d6db3441610d 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/jvmstat/PosixPerfMemoryProvider.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/jvmstat/PosixPerfMemoryProvider.java @@ -59,12 +59,11 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.svm.core.VMInspectionOptions; import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.annotate.TargetClass; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.headers.LibC; import com.oracle.svm.core.jvmstat.PerfManager; import com.oracle.svm.core.jvmstat.PerfMemoryPrologue; @@ -72,6 +71,7 @@ import com.oracle.svm.core.posix.headers.Errno; import com.oracle.svm.core.posix.headers.Signal; import com.oracle.svm.core.posix.headers.Unistd; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; /** * This class uses high-level JDK features at the moment. In the future, we will need to rewrite @@ -276,9 +276,9 @@ public void teardown() { } } -@AutomaticFeature +@AutomaticallyRegisteredFeature @Platforms({Platform.LINUX.class, Platform.DARWIN.class}) -class PosixPerfMemoryFeature implements Feature { +class PosixPerfMemoryFeature implements InternalFeature { @Override public boolean isInConfiguration(IsInConfigurationAccess access) { return VMInspectionOptions.hasJvmstatSupport() && PerfDataMemoryMappedFile.getValue(); diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxImageHeapProvider.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxImageHeapProvider.java index 7f3c9d09d32f..19ecc921cb69 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxImageHeapProvider.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxImageHeapProvider.java @@ -39,11 +39,9 @@ import java.util.concurrent.ThreadLocalRandom; import org.graalvm.compiler.word.Word; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.WordPointer; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.ComparableWord; import org.graalvm.word.LocationIdentity; import org.graalvm.word.Pointer; @@ -52,7 +50,6 @@ import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.CGlobalData; import com.oracle.svm.core.c.CGlobalDataFactory; @@ -62,7 +59,6 @@ import com.oracle.svm.core.heap.Heap; import com.oracle.svm.core.os.AbstractImageHeapProvider; import com.oracle.svm.core.os.CopyingImageHeapProvider; -import com.oracle.svm.core.os.ImageHeapProvider; import com.oracle.svm.core.os.VirtualMemoryProvider; import com.oracle.svm.core.os.VirtualMemoryProvider.Access; import com.oracle.svm.core.posix.PosixUtils; @@ -70,16 +66,6 @@ import com.oracle.svm.core.posix.headers.Unistd; import com.oracle.svm.core.util.PointerUtils; -@AutomaticFeature -class LinuxImageHeapProviderFeature implements Feature { - @Override - public void duringSetup(DuringSetupAccess access) { - if (!ImageSingletons.contains(ImageHeapProvider.class)) { - ImageSingletons.add(ImageHeapProvider.class, new LinuxImageHeapProvider()); - } - } -} - /** * An optimal image heap provider for Linux which creates isolate image heaps that retain the * copy-on-write, lazy loading and reclamation semantics provided by the original heap's backing 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 025632fb7bf8..744818a5ab61 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 @@ -30,14 +30,16 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.c.libc.LibCBase; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.headers.LibCSupport; +import com.oracle.svm.core.os.ImageHeapProvider; import com.oracle.svm.core.posix.linux.libc.BionicLibC; import com.oracle.svm.core.posix.linux.libc.LibCFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; -@AutomaticFeature -class LinuxImageSingletonsFeature implements Feature { +@AutomaticallyRegisteredFeature +class LinuxImageSingletonsFeature implements InternalFeature { @Override public List> getRequiredFeatures() { @@ -52,4 +54,11 @@ public void afterRegistration(AfterRegistrationAccess access) { ImageSingletons.add(LibCSupport.class, new LinuxLibCSupport()); } } + + @Override + public void duringSetup(DuringSetupAccess access) { + if (!ImageSingletons.contains(ImageHeapProvider.class)) { + ImageSingletons.add(ImageHeapProvider.class, new LinuxImageHeapProvider()); + } + } } diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxPhysicalMemory.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxPhysicalMemorySupportImpl.java similarity index 54% rename from substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxPhysicalMemory.java rename to substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxPhysicalMemorySupportImpl.java index 75713e6683cd..f7e563b32d8f 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxPhysicalMemory.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxPhysicalMemorySupportImpl.java @@ -24,36 +24,24 @@ */ package com.oracle.svm.core.posix.linux; -import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.heap.PhysicalMemory; +import com.oracle.svm.core.heap.PhysicalMemory.PhysicalMemorySupport; import com.oracle.svm.core.posix.headers.Unistd; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.VMError; -class LinuxPhysicalMemory extends PhysicalMemory { +@AutomaticallyRegisteredImageSingleton(PhysicalMemorySupport.class) +class LinuxPhysicalMemorySupportImpl implements PhysicalMemorySupport { - static class PhysicalMemorySupportImpl implements PhysicalMemorySupport { - - @Override - public UnsignedWord size() { - long numberOfPhysicalMemoryPages = Unistd.sysconf(Unistd._SC_PHYS_PAGES()); - long sizeOfAPhysicalMemoryPage = Unistd.sysconf(Unistd._SC_PAGESIZE()); - if (numberOfPhysicalMemoryPages == -1 || sizeOfAPhysicalMemoryPage == -1) { - throw VMError.shouldNotReachHere("Physical memory size (number of pages or page size) not available"); - } - return WordFactory.unsigned(numberOfPhysicalMemoryPages).multiply(WordFactory.unsigned(sizeOfAPhysicalMemoryPage)); - } - } - - @AutomaticFeature - static class PhysicalMemoryFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(PhysicalMemorySupport.class, new PhysicalMemorySupportImpl()); + @Override + public UnsignedWord size() { + long numberOfPhysicalMemoryPages = Unistd.sysconf(Unistd._SC_PHYS_PAGES()); + long sizeOfAPhysicalMemoryPage = Unistd.sysconf(Unistd._SC_PAGESIZE()); + if (numberOfPhysicalMemoryPages == -1 || sizeOfAPhysicalMemoryPage == -1) { + throw VMError.shouldNotReachHere("Physical memory size (number of pages or page size) not available"); } + return WordFactory.unsigned(numberOfPhysicalMemoryPages).multiply(WordFactory.unsigned(sizeOfAPhysicalMemoryPage)); } } diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxProcessPropertiesSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxProcessPropertiesSupport.java index 9df09d99bbed..bd1a005e7049 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxProcessPropertiesSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxProcessPropertiesSupport.java @@ -24,13 +24,12 @@ */ package com.oracle.svm.core.posix.linux; -import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.ProcessPropertiesSupport; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.posix.PosixProcessPropertiesSupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +@AutomaticallyRegisteredImageSingleton(ProcessPropertiesSupport.class) public class LinuxProcessPropertiesSupport extends PosixProcessPropertiesSupport { @Override @@ -38,14 +37,4 @@ public String getExecutableName() { final String exefileString = "/proc/self/exe"; return realpath(exefileString); } - - @AutomaticFeature - public static class ImagePropertiesFeature implements Feature { - - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(ProcessPropertiesSupport.class, new LinuxProcessPropertiesSupport()); - } - } - } diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxStackOverflowSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxStackOverflowSupport.java index e0c25cc3be30..ad0eb554dd40 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxStackOverflowSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxStackOverflowSupport.java @@ -24,19 +24,18 @@ */ package com.oracle.svm.core.posix.linux; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.type.WordPointer; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.posix.PosixUtils; import com.oracle.svm.core.posix.headers.Pthread; import com.oracle.svm.core.stack.StackOverflowCheck; +@AutomaticallyRegisteredImageSingleton(StackOverflowCheck.OSSupport.class) class LinuxStackOverflowSupport implements StackOverflowCheck.OSSupport { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) @@ -104,11 +103,3 @@ public UnsignedWord lookupStackEnd(UnsignedWord requestedStackSize) { return stackEnd; } } - -@AutomaticFeature -class LinuxStackOverflowSupportFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(StackOverflowCheck.OSSupport.class, new LinuxStackOverflowSupport()); - } -} diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxSystemPropertiesSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxSystemPropertiesSupport.java index dc556c73017f..d787133ac086 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxSystemPropertiesSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxSystemPropertiesSupport.java @@ -29,13 +29,13 @@ import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.nativeimage.c.type.CTypeConversion.CCharPointerHolder; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.SystemPropertiesSupport; import com.oracle.svm.core.posix.PosixSystemPropertiesSupport; import com.oracle.svm.core.posix.headers.Stdlib; import com.oracle.svm.core.posix.headers.Utsname; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; public class LinuxSystemPropertiesSupport extends PosixSystemPropertiesSupport { @@ -87,8 +87,9 @@ protected String osVersionValue() { } } -@AutomaticFeature -class LinuxSystemPropertiesFeature implements Feature { +@AutomaticallyRegisteredFeature +class LinuxSystemPropertiesFeature implements InternalFeature { + @Override public void duringSetup(DuringSetupAccess access) { ImageSingletons.add(SystemPropertiesSupport.class, new LinuxSystemPropertiesSupport()); diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxThreadCpuTimeSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxThreadCpuTimeSupport.java index dfdff377f2a0..0af1bf390726 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxThreadCpuTimeSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/LinuxThreadCpuTimeSupport.java @@ -24,22 +24,19 @@ */ package com.oracle.svm.core.posix.linux; +import org.graalvm.nativeimage.StackValue; +import org.graalvm.nativeimage.c.type.CIntPointer; + import com.oracle.svm.core.Uninterruptible; -import com.oracle.svm.core.thread.ThreadCpuTimeSupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.posix.headers.Pthread.pthread_t; +import com.oracle.svm.core.posix.headers.Time.timespec; import com.oracle.svm.core.posix.headers.linux.LinuxPthread; import com.oracle.svm.core.posix.headers.linux.LinuxTime; +import com.oracle.svm.core.thread.ThreadCpuTimeSupport; import com.oracle.svm.core.thread.VMThreads.OSThreadHandle; -import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.Platform; -import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.StackValue; -import org.graalvm.nativeimage.c.type.CIntPointer; -import org.graalvm.nativeimage.hosted.Feature; - -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.posix.headers.Time.timespec; +@AutomaticallyRegisteredImageSingleton(ThreadCpuTimeSupport.class) final class LinuxThreadCpuTimeSupport implements ThreadCpuTimeSupport { @Override @@ -81,13 +78,3 @@ private static long getThreadCpuTimeImpl(int clockId) { return time.tv_sec() * 1_000_000_000 + time.tv_nsec(); } } - -@Platforms({Platform.LINUX.class}) -@AutomaticFeature -final class LinuxThreadCpuTimeFeature implements Feature { - - @Override - public void afterRegistration(Feature.AfterRegistrationAccess access) { - ImageSingletons.add(ThreadCpuTimeSupport.class, new LinuxThreadCpuTimeSupport()); - } -} diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/libc/LibCFeature.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/libc/LibCFeature.java index fd874f2b810c..14554a23c546 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/libc/LibCFeature.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/linux/libc/LibCFeature.java @@ -32,16 +32,16 @@ import org.graalvm.compiler.options.OptionValues; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.c.libc.LibCBase; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.option.APIOption; import com.oracle.svm.core.option.HostedOptionKey; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.UserError; -@AutomaticFeature -public class LibCFeature implements Feature { +@AutomaticallyRegisteredFeature +public class LibCFeature implements InternalFeature { @Override public boolean isInConfiguration(IsInConfigurationAccess access) { diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/pthread/PthreadVMLockSupport.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/pthread/PthreadVMLockSupport.java index 87ac1eb4a935..3f6d6708d972 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/pthread/PthreadVMLockSupport.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/pthread/PthreadVMLockSupport.java @@ -35,17 +35,17 @@ import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.struct.SizeOf; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.heap.RestrictHeapAccess; import com.oracle.svm.core.Uninterruptible; -import com.oracle.svm.core.heap.UnknownObjectField; import com.oracle.svm.core.config.ConfigurationValues; import com.oracle.svm.core.config.ObjectLayout; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.heap.RestrictHeapAccess; +import com.oracle.svm.core.heap.UnknownObjectField; import com.oracle.svm.core.locks.ClassInstanceReplacer; import com.oracle.svm.core.locks.VMCondition; import com.oracle.svm.core.locks.VMLockSupport; @@ -63,8 +63,8 @@ * Support of {@link VMMutex} and {@link VMCondition} in multi-threaded environments. Locking is * implemented via pthreads. */ -@AutomaticFeature -final class PthreadVMLockFeature implements Feature { +@AutomaticallyRegisteredFeature +final class PthreadVMLockFeature implements InternalFeature { private final ClassInstanceReplacer mutexReplacer = new ClassInstanceReplacer<>(VMMutex.class) { @Override diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixPlatformThreads.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixPlatformThreads.java index a7041a297caf..a274f43086ea 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixPlatformThreads.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixPlatformThreads.java @@ -25,7 +25,6 @@ package com.oracle.svm.core.posix.thread; import org.graalvm.compiler.core.common.SuppressFBWarnings; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.ObjectHandle; import org.graalvm.nativeimage.Platform.HOSTED_ONLY; import org.graalvm.nativeimage.Platforms; @@ -39,12 +38,10 @@ import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.nativeimage.c.type.CTypeConversion.CCharPointerHolder; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordBase; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.annotate.Inject; import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.TargetClass; @@ -71,9 +68,11 @@ import com.oracle.svm.core.thread.ParkEvent; import com.oracle.svm.core.thread.ParkEvent.ParkEventFactory; import com.oracle.svm.core.thread.PlatformThreads; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.UnsignedUtils; import com.oracle.svm.core.util.VMError; +@AutomaticallyRegisteredImageSingleton(PlatformThreads.class) public final class PosixPlatformThreads extends PlatformThreads { @SuppressFBWarnings(value = "BC", justification = "Cast for @TargetClass") @@ -325,18 +324,10 @@ protected void unpark() { } } +@AutomaticallyRegisteredImageSingleton(ParkEventFactory.class) class PosixParkEventFactory implements ParkEventFactory { @Override public ParkEvent create() { return new PosixParkEvent(); } } - -@AutomaticFeature -class PosixThreadsFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(PlatformThreads.class, new PosixPlatformThreads()); - ImageSingletons.add(ParkEventFactory.class, new PosixParkEventFactory()); - } -} diff --git a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixVMThreads.java b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixVMThreads.java index 498332cdd0ba..fc7cb5628fb2 100644 --- a/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixVMThreads.java +++ b/substratevm/src/com.oracle.svm.core.posix/src/com/oracle/svm/core/posix/thread/PosixVMThreads.java @@ -24,19 +24,17 @@ */ package com.oracle.svm.core.posix.thread; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.function.CFunction; import org.graalvm.nativeimage.c.function.CFunction.Transition; import org.graalvm.nativeimage.c.type.CCharPointer; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.PointerBase; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; 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.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.headers.LibC; import com.oracle.svm.core.posix.PosixUtils; import com.oracle.svm.core.posix.headers.Pthread; @@ -47,6 +45,7 @@ import com.oracle.svm.core.thread.VMThreads; import com.oracle.svm.core.util.TimeUtils; +@AutomaticallyRegisteredImageSingleton(VMThreads.class) public final class PosixVMThreads extends VMThreads { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) @@ -115,11 +114,3 @@ public void failFatally(int code, CCharPointer message) { LibC.exit(code); } } - -@AutomaticFeature -class PosixVMThreadsFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(VMThreads.class, new PosixVMThreads()); - } -} diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsImageSingletonsFeature.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsFeature.java similarity index 66% rename from substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsImageSingletonsFeature.java rename to substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsFeature.java index 4dbc6d320018..5265174e0079 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsImageSingletonsFeature.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsFeature.java @@ -25,16 +25,24 @@ package com.oracle.svm.core.windows; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.headers.LibCSupport; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.log.Log; +import com.oracle.svm.core.os.ImageHeapProvider; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; -@AutomaticFeature -class WindowsImageSingletonsFeature implements Feature { +@AutomaticallyRegisteredFeature +class WindowsFeature implements InternalFeature { @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(LibCSupport.class, new WindowsLibCSupport()); + public void duringSetup(DuringSetupAccess access) { + if (!ImageSingletons.contains(ImageHeapProvider.class)) { + ImageSingletons.add(ImageHeapProvider.class, new WindowsImageHeapProvider()); + } + } + + @Override + public void beforeAnalysis(BeforeAnalysisAccess access) { + Log.finalizeDefaultLogHandler(new WindowsLogHandler()); } } diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsImageHeapProvider.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsImageHeapProvider.java index dc106c8b61d3..65b6998a356c 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsImageHeapProvider.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsImageHeapProvider.java @@ -29,20 +29,17 @@ import static com.oracle.svm.core.Isolates.IMAGE_HEAP_RELOCATABLE_END; import static org.graalvm.nativeimage.c.function.CFunction.Transition.NO_TRANSITION; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.function.CFunctionPointer; import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.WordPointer; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.LocationIdentity; import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.CGlobalData; import com.oracle.svm.core.c.CGlobalDataFactory; @@ -50,7 +47,6 @@ import com.oracle.svm.core.c.function.CEntryPointErrors; import com.oracle.svm.core.headers.LibC; import com.oracle.svm.core.os.AbstractCopyingImageHeapProvider; -import com.oracle.svm.core.os.ImageHeapProvider; import com.oracle.svm.core.os.VirtualMemoryProvider; import com.oracle.svm.core.os.VirtualMemoryProvider.Access; import com.oracle.svm.core.windows.headers.FileAPI; @@ -61,16 +57,6 @@ import com.oracle.svm.core.windows.headers.WinBase.HMODULE; import com.oracle.svm.core.windows.headers.WindowsLibC.WCharPointer; -@AutomaticFeature -class WindowsImageHeapProviderFeature implements Feature { - @Override - public void duringSetup(DuringSetupAccess access) { - if (!ImageSingletons.contains(ImageHeapProvider.class)) { - ImageSingletons.add(ImageHeapProvider.class, new WindowsImageHeapProvider()); - } - } -} - /** * An image heap provider for Windows that creates image heaps that are copy-on-write clones of the * loaded image heap. diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsLibCSupport.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsLibCSupport.java index 3439385d0267..f4dd38084dee 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsLibCSupport.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsLibCSupport.java @@ -32,8 +32,10 @@ import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.headers.LibCSupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.windows.headers.WindowsLibC; +@AutomaticallyRegisteredImageSingleton(LibCSupport.class) class WindowsLibCSupport implements LibCSupport { @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsLogHandler.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsLogHandler.java index 3b8da302f896..d7181ccb51bf 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsLogHandler.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsLogHandler.java @@ -25,28 +25,14 @@ package com.oracle.svm.core.windows; import org.graalvm.nativeimage.LogHandler; -import org.graalvm.nativeimage.Platform; -import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.type.CCharPointer; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.UnsignedWord; import com.oracle.svm.core.SubstrateDiagnostics; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.headers.LibC; -import com.oracle.svm.core.log.Log; import com.oracle.svm.core.thread.VMThreads; import com.oracle.svm.core.windows.headers.FileAPI; -@AutomaticFeature -@Platforms(Platform.WINDOWS.class) -class WindowsLogHandlerFeature implements Feature { - @Override - public void beforeAnalysis(BeforeAnalysisAccess access) { - Log.finalizeDefaultLogHandler(new WindowsLogHandler()); - } -} - public class WindowsLogHandler implements LogHandler { @Override diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsNativeLibraryFeature.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsNativeLibrarySupport.java similarity index 92% rename from substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsNativeLibraryFeature.java rename to substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsNativeLibrarySupport.java index 10c3495b2c60..992fbd8bb3a6 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsNativeLibraryFeature.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsNativeLibrarySupport.java @@ -26,45 +26,31 @@ import java.io.FileDescriptor; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.nativeimage.c.type.CTypeConversion.CCharPointerHolder; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.PointerBase; import org.graalvm.word.WordFactory; import com.oracle.svm.core.Isolates; import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.jdk.JNIPlatformNativeLibrarySupport; import com.oracle.svm.core.jdk.Jvm; import com.oracle.svm.core.jdk.NativeLibrarySupport; import com.oracle.svm.core.jdk.PlatformNativeLibrarySupport; import com.oracle.svm.core.log.Log; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.windows.headers.FileAPI; import com.oracle.svm.core.windows.headers.LibLoaderAPI; import com.oracle.svm.core.windows.headers.WinBase.HMODULE; import com.oracle.svm.core.windows.headers.WinSock; -@AutomaticFeature -@Platforms(Platform.WINDOWS.class) -class WindowsNativeLibraryFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - WindowsNativeLibrarySupport.initialize(); - } -} - +@AutomaticallyRegisteredImageSingleton(PlatformNativeLibrarySupport.class) class WindowsNativeLibrarySupport extends JNIPlatformNativeLibrarySupport { - static void initialize() { - ImageSingletons.add(PlatformNativeLibrarySupport.class, new WindowsNativeLibrarySupport()); - } - @Override public boolean initializeBuiltinLibraries() { try { diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPhysicalMemory.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPhysicalMemorySupportImpl.java similarity index 59% rename from substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPhysicalMemory.java rename to substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPhysicalMemorySupportImpl.java index 9090740ab979..72bb52490a4b 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPhysicalMemory.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPhysicalMemorySupportImpl.java @@ -24,35 +24,23 @@ */ package com.oracle.svm.core.windows; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.struct.SizeOf; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.heap.PhysicalMemory; +import com.oracle.svm.core.heap.PhysicalMemory.PhysicalMemorySupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.windows.headers.SysinfoAPI; -class WindowsPhysicalMemory extends PhysicalMemory { +@AutomaticallyRegisteredImageSingleton(PhysicalMemorySupport.class) +class WindowsPhysicalMemorySupportImpl implements PhysicalMemorySupport { - static class WindowsPhysicalMemorySupportImpl implements PhysicalMemorySupport { - - @Override - public UnsignedWord size() { - SysinfoAPI.MEMORYSTATUSEX memStatusEx = StackValue.get(SysinfoAPI.MEMORYSTATUSEX.class); - memStatusEx.set_dwLength(SizeOf.get(SysinfoAPI.MEMORYSTATUSEX.class)); - SysinfoAPI.GlobalMemoryStatusEx(memStatusEx); - return WordFactory.unsigned(memStatusEx.ullTotalPhys()); - } - } - - @AutomaticFeature - static class PhysicalMemoryFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(PhysicalMemorySupport.class, new WindowsPhysicalMemorySupportImpl()); - } + @Override + public UnsignedWord size() { + SysinfoAPI.MEMORYSTATUSEX memStatusEx = StackValue.get(SysinfoAPI.MEMORYSTATUSEX.class); + memStatusEx.set_dwLength(SizeOf.get(SysinfoAPI.MEMORYSTATUSEX.class)); + SysinfoAPI.GlobalMemoryStatusEx(memStatusEx); + return WordFactory.unsigned(memStatusEx.ullTotalPhys()); } } diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformThreads.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformThreads.java index 344dccc3cb83..3151ecbdc233 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformThreads.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsPlatformThreads.java @@ -24,7 +24,6 @@ */ package com.oracle.svm.core.windows; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.ObjectHandle; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platform.HOSTED_ONLY; @@ -39,11 +38,9 @@ import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CIntPointer; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.WordBase; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.CGlobalData; import com.oracle.svm.core.c.CGlobalDataFactory; @@ -51,6 +48,7 @@ import com.oracle.svm.core.c.function.CEntryPointErrors; import com.oracle.svm.core.c.function.CEntryPointOptions; import com.oracle.svm.core.c.function.CEntryPointSetup.LeaveDetachThreadEpilogue; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.log.Log; import com.oracle.svm.core.stack.StackOverflowCheck; import com.oracle.svm.core.thread.ParkEvent; @@ -62,6 +60,7 @@ import com.oracle.svm.core.windows.headers.SynchAPI; import com.oracle.svm.core.windows.headers.WinBase; +@AutomaticallyRegisteredImageSingleton(PlatformThreads.class) @Platforms(Platform.WINDOWS.class) public final class WindowsPlatformThreads extends PlatformThreads { @Platforms(HOSTED_ONLY.class) @@ -230,6 +229,7 @@ protected void unpark() { } } +@AutomaticallyRegisteredImageSingleton(ParkEventFactory.class) @Platforms(Platform.WINDOWS.class) class WindowsParkEventFactory implements ParkEventFactory { @Override @@ -237,13 +237,3 @@ public ParkEvent create() { return new WindowsParkEvent(); } } - -@AutomaticFeature -@Platforms(Platform.WINDOWS.class) -class WindowsThreadsFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(PlatformThreads.class, new WindowsPlatformThreads()); - ImageSingletons.add(ParkEventFactory.class, new WindowsParkEventFactory()); - } -} diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsProcessPropertiesSupport.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsProcessPropertiesSupport.java index f18a8cfdaa95..69233a83aa26 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsProcessPropertiesSupport.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsProcessPropertiesSupport.java @@ -32,24 +32,23 @@ import java.util.List; import java.util.Map; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.function.CEntryPointLiteral; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.ProcessPropertiesSupport; import org.graalvm.word.PointerBase; import org.graalvm.word.WordFactory; import com.oracle.svm.core.BaseProcessPropertiesSupport; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.VMError; import com.oracle.svm.core.windows.headers.LibLoaderAPI; import com.oracle.svm.core.windows.headers.Process; import com.oracle.svm.core.windows.headers.WinBase; import com.oracle.svm.core.windows.headers.WinBase.HANDLE; +@AutomaticallyRegisteredImageSingleton(ProcessPropertiesSupport.class) public class WindowsProcessPropertiesSupport extends BaseProcessPropertiesSupport { @Override @@ -165,14 +164,4 @@ public boolean isAlive(long processID) { public int waitForProcessExit(long processID) { throw VMError.unimplemented(); } - - @AutomaticFeature - public static class ImagePropertiesFeature implements Feature { - - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(ProcessPropertiesSupport.class, new WindowsProcessPropertiesSupport()); - } - } - } diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsRegisterDumper.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsRegisterDumper.java index d4de8d661cb9..c6d7b6e5838d 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsRegisterDumper.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsRegisterDumper.java @@ -26,14 +26,12 @@ import static com.oracle.svm.core.RegisterDumper.dumpReg; -import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.PointerBase; import org.graalvm.word.WordFactory; import com.oracle.svm.core.RegisterDumper; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.graal.amd64.AMD64ReservedRegisters; import com.oracle.svm.core.log.Log; import com.oracle.svm.core.util.VMError; @@ -41,17 +39,13 @@ import jdk.vm.ci.amd64.AMD64; -@AutomaticFeature -class WindowsRegisterDumperFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { +@AutomaticallyRegisteredImageSingleton(RegisterDumper.class) +class WindowsRegisterDumper implements RegisterDumper { + WindowsRegisterDumper() { VMError.guarantee(AMD64.r14.equals(AMD64ReservedRegisters.HEAP_BASE_REGISTER_CANDIDATE)); VMError.guarantee(AMD64.r15.equals(AMD64ReservedRegisters.THREAD_REGISTER_CANDIDATE)); - ImageSingletons.add(RegisterDumper.class, new WindowsRegisterDumper()); } -} -public class WindowsRegisterDumper implements RegisterDumper { @Override public void dumpRegisters(Log log, Context context, boolean printLocationInfo, boolean allowJavaHeapAccess, boolean allowUnsafeOperations) { dumpRegisters(log, (CONTEXT) context, printLocationInfo, allowJavaHeapAccess, allowUnsafeOperations); diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsStackOverflowSupport.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsStackOverflowSupport.java index 59fe9c63c773..f1c9b0c9b27d 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsStackOverflowSupport.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsStackOverflowSupport.java @@ -24,22 +24,21 @@ */ package com.oracle.svm.core.windows; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.nativeimage.c.type.WordPointer; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.stack.StackOverflowCheck; import com.oracle.svm.core.windows.headers.MemoryAPI; +@AutomaticallyRegisteredImageSingleton(StackOverflowCheck.OSSupport.class) @Platforms({Platform.WINDOWS.class}) class WindowsStackOverflowSupport implements StackOverflowCheck.OSSupport { @@ -104,12 +103,3 @@ public UnsignedWord lookupStackEnd(UnsignedWord requestedStackSize) { return stackEnd; } } - -@Platforms({Platform.WINDOWS.class}) -@AutomaticFeature -class WindowsStackOverflowSupportFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(StackOverflowCheck.OSSupport.class, new WindowsStackOverflowSupport()); - } -} diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSubstrateSegfaultHandler.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSubstrateSegfaultHandler.java index 475e90ffc6ae..f9eb6e76080c 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSubstrateSegfaultHandler.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSubstrateSegfaultHandler.java @@ -28,34 +28,25 @@ import static com.oracle.svm.core.windows.headers.ErrHandlingAPI.EXCEPTION_ACCESS_VIOLATION; import static com.oracle.svm.core.windows.headers.ErrHandlingAPI.EXCEPTION_IN_PAGE_ERROR; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.c.function.CEntryPoint; import org.graalvm.nativeimage.c.function.CEntryPoint.Publish; import org.graalvm.nativeimage.c.function.CEntryPointLiteral; import org.graalvm.nativeimage.c.function.CFunctionPointer; import org.graalvm.nativeimage.c.type.CLongPointer; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.PointerBase; import com.oracle.svm.core.SubstrateSegfaultHandler; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.heap.RestrictHeapAccess; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.function.CEntryPointOptions; import com.oracle.svm.core.c.function.CEntryPointOptions.NoEpilogue; import com.oracle.svm.core.c.function.CEntryPointOptions.NoPrologue; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +import com.oracle.svm.core.heap.RestrictHeapAccess; import com.oracle.svm.core.log.Log; import com.oracle.svm.core.util.VMError; import com.oracle.svm.core.windows.headers.ErrHandlingAPI; -@AutomaticFeature -class WindowsSubstrateSegfaultHandlerFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(SubstrateSegfaultHandler.class, new WindowsSubstrateSegfaultHandler()); - } -} - +@AutomaticallyRegisteredImageSingleton(SubstrateSegfaultHandler.class) class WindowsSubstrateSegfaultHandler extends SubstrateSegfaultHandler { private static final int EX_READ = 0; private static final int EX_WRITE = 1; diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSystemPropertiesSupport.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSystemPropertiesSupport.java index b550005635a3..c68248510ee9 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSystemPropertiesSupport.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsSystemPropertiesSupport.java @@ -38,14 +38,14 @@ import org.graalvm.nativeimage.c.type.CTypeConversion; import org.graalvm.nativeimage.c.type.VoidPointer; import org.graalvm.nativeimage.c.type.WordPointer; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.c.NonmovableArrays; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.headers.LibC; import com.oracle.svm.core.jdk.SystemPropertiesSupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; import com.oracle.svm.core.windows.headers.FileAPI; import com.oracle.svm.core.windows.headers.LibLoaderAPI; @@ -386,8 +386,8 @@ public Pair getOsNameAndVersion() { } @Platforms(Platform.WINDOWS.class) -@AutomaticFeature -class WindowsSystemPropertiesFeature implements Feature { +@AutomaticallyRegisteredFeature +class WindowsSystemPropertiesFeature implements InternalFeature { @Override public void duringSetup(DuringSetupAccess access) { ImageSingletons.add(SystemPropertiesSupport.class, new WindowsSystemPropertiesSupport()); diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsThreadCpuTimeSupport.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsThreadCpuTimeSupport.java index 45dee7f223eb..b04de4dfbd30 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsThreadCpuTimeSupport.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsThreadCpuTimeSupport.java @@ -24,22 +24,19 @@ */ package com.oracle.svm.core.windows; +import org.graalvm.nativeimage.StackValue; +import org.graalvm.word.UnsignedWord; +import org.graalvm.word.WordFactory; + import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.thread.ThreadCpuTimeSupport; import com.oracle.svm.core.thread.VMThreads.OSThreadHandle; import com.oracle.svm.core.windows.headers.Process; import com.oracle.svm.core.windows.headers.WinBase.FILETIME; import com.oracle.svm.core.windows.headers.WinBase.HANDLE; -import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.Platform; -import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.StackValue; -import org.graalvm.nativeimage.hosted.Feature; - -import com.oracle.svm.core.annotate.AutomaticFeature; -import org.graalvm.word.UnsignedWord; -import org.graalvm.word.WordFactory; +@AutomaticallyRegisteredImageSingleton(ThreadCpuTimeSupport.class) final class WindowsThreadCpuTimeSupport implements ThreadCpuTimeSupport { @Override @@ -78,13 +75,3 @@ public long getThreadCpuTime(OSThreadHandle osThreadHandle, boolean includeSyste return total.multiply(100).rawValue(); } } - -@Platforms(Platform.WINDOWS.class) -@AutomaticFeature -class WindowsThreadCpuTimeFeature implements Feature { - - @Override - public void afterRegistration(Feature.AfterRegistrationAccess access) { - ImageSingletons.add(ThreadCpuTimeSupport.class, new WindowsThreadCpuTimeSupport()); - } -} diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsUnmanagedMemorySupportImpl.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsUnmanagedMemorySupportImpl.java index 16725d621b72..7ee93b64d4e7 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsUnmanagedMemorySupportImpl.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsUnmanagedMemorySupportImpl.java @@ -24,19 +24,16 @@ */ package com.oracle.svm.core.windows; -import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.Platform; -import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.UnmanagedMemorySupport; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.headers.LibC; +@AutomaticallyRegisteredImageSingleton(UnmanagedMemorySupport.class) class WindowsUnmanagedMemorySupportImpl implements UnmanagedMemorySupport { @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) @@ -62,12 +59,3 @@ public void free(PointerBase ptr) { LibC.free(ptr); } } - -@AutomaticFeature -@Platforms(Platform.WINDOWS.class) -class UnmanagedMemoryFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(UnmanagedMemorySupport.class, new WindowsUnmanagedMemorySupportImpl()); - } -} diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVMLockSupport.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVMLockSupport.java index 9be8b99e3365..2689143c969d 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVMLockSupport.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVMLockSupport.java @@ -34,17 +34,17 @@ import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.struct.SizeOf; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.heap.RestrictHeapAccess; import com.oracle.svm.core.Uninterruptible; -import com.oracle.svm.core.heap.UnknownObjectField; import com.oracle.svm.core.config.ConfigurationValues; import com.oracle.svm.core.config.ObjectLayout; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.heap.RestrictHeapAccess; +import com.oracle.svm.core.heap.UnknownObjectField; import com.oracle.svm.core.locks.ClassInstanceReplacer; import com.oracle.svm.core.locks.VMCondition; import com.oracle.svm.core.locks.VMLockSupport; @@ -62,9 +62,9 @@ * Support of {@link VMMutex} and {@link VMCondition} in multi-threaded environments. Locking is * implemented via Windows locking primitives. */ -@AutomaticFeature +@AutomaticallyRegisteredFeature @Platforms(Platform.WINDOWS.class) -final class WindowsVMLockFeature implements Feature { +final class WindowsVMLockFeature implements InternalFeature { private final ClassInstanceReplacer mutexReplacer = new ClassInstanceReplacer<>(VMMutex.class) { @Override diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVMThreads.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVMThreads.java index 2716dd0e1e72..1634290efb29 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVMThreads.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVMThreads.java @@ -24,16 +24,12 @@ */ package com.oracle.svm.core.windows; -import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.Platform; -import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.type.CCharPointer; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.headers.LibC; import com.oracle.svm.core.thread.VMThreads; import com.oracle.svm.core.util.VMError; @@ -41,6 +37,7 @@ import com.oracle.svm.core.windows.headers.SynchAPI; import com.oracle.svm.core.windows.headers.WinBase; +@AutomaticallyRegisteredImageSingleton(VMThreads.class) public final class WindowsVMThreads extends VMThreads { @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) @@ -112,12 +109,3 @@ public void failFatally(int code, CCharPointer message) { LibC.exit(code); } } - -@AutomaticFeature -@Platforms(Platform.WINDOWS.class) -class WindowsVMThreadsFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(VMThreads.class, new WindowsVMThreads()); - } -} diff --git a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVirtualMemoryProvider.java b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVirtualMemoryProvider.java index 60ea0c72346c..db600daf3405 100644 --- a/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVirtualMemoryProvider.java +++ b/substratevm/src/com.oracle.svm.core.windows/src/com/oracle/svm/core/windows/WindowsVirtualMemoryProvider.java @@ -26,7 +26,6 @@ import static org.graalvm.nativeimage.c.function.CFunction.Transition.NO_TRANSITION; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.function.CFunctionPointer; import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; @@ -36,18 +35,17 @@ import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CIntPointer; import org.graalvm.nativeimage.c.type.WordPointer; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordBase; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; 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.function.CEntryPointActions; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.os.VirtualMemoryProvider; import com.oracle.svm.core.util.PointerUtils; import com.oracle.svm.core.util.UnsignedUtils; @@ -57,14 +55,7 @@ import com.oracle.svm.core.windows.headers.WinBase; import com.oracle.svm.core.windows.headers.WinBase.HANDLE; -@AutomaticFeature -class WindowsVirtualMemoryProviderFeature implements Feature { - @Override - public void beforeAnalysis(BeforeAnalysisAccess access) { - ImageSingletons.add(VirtualMemoryProvider.class, new WindowsVirtualMemoryProvider()); - } -} - +@AutomaticallyRegisteredImageSingleton(VirtualMemoryProvider.class) public class WindowsVirtualMemoryProvider implements VirtualMemoryProvider { private static final CGlobalData CACHED_PAGE_SIZE = CGlobalDataFactory.createWord(); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/Containers.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/Containers.java index f08f5a0c929a..06b642e493b0 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/Containers.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/Containers.java @@ -33,13 +33,13 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.RuntimeClassInitializationSupport; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.Jvm; import com.oracle.svm.core.option.HostedOptionKey; import com.oracle.svm.core.option.RuntimeOptionKey; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; /** @@ -201,9 +201,9 @@ long getMemoryLimit() { } } -@AutomaticFeature +@AutomaticallyRegisteredFeature @Platforms(Platform.LINUX.class) -class ContainersFeature implements Feature { +class ContainersFeature implements InternalFeature { @Override public void duringSetup(DuringSetupAccess access) { RuntimeClassInitializationSupport classInitSupport = ImageSingletons.lookup(RuntimeClassInitializationSupport.class); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/DumpHeapOnSignalFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/DumpHeapOnSignalFeature.java index 28df3b9af975..f2a4a6f88974 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/DumpHeapOnSignalFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/DumpHeapOnSignalFeature.java @@ -32,17 +32,17 @@ import org.graalvm.nativeimage.ProcessProperties; import org.graalvm.nativeimage.VMRuntime; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.RuntimeSupport; import com.oracle.svm.core.log.Log; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import sun.misc.Signal; import sun.misc.SignalHandler; -@AutomaticFeature -public class DumpHeapOnSignalFeature implements Feature { +@AutomaticallyRegisteredFeature +public class DumpHeapOnSignalFeature implements InternalFeature { @Override public boolean isInConfiguration(IsInConfigurationAccess access) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/DumpRuntimeCompilationOnSignalFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/DumpRuntimeCompilationOnSignalFeature.java index f8db0aba4874..8c03478e68ec 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/DumpRuntimeCompilationOnSignalFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/DumpRuntimeCompilationOnSignalFeature.java @@ -26,20 +26,20 @@ import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platform.WINDOWS; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.deopt.DeoptimizationSupport; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.heap.VMOperationInfos; import com.oracle.svm.core.jdk.RuntimeSupport; import com.oracle.svm.core.log.Log; import com.oracle.svm.core.thread.JavaVMOperation; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import sun.misc.Signal; import sun.misc.SignalHandler; -@AutomaticFeature -public class DumpRuntimeCompilationOnSignalFeature implements Feature { +@AutomaticallyRegisteredFeature +public class DumpRuntimeCompilationOnSignalFeature implements InternalFeature { @Override public boolean isInConfiguration(IsInConfigurationAccess access) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/DumpThreadStacksOnSignalFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/DumpThreadStacksOnSignalFeature.java index 2d0430fc1575..c687f82162d1 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/DumpThreadStacksOnSignalFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/DumpThreadStacksOnSignalFeature.java @@ -28,9 +28,8 @@ import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platform.WINDOWS; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.heap.VMOperationInfos; import com.oracle.svm.core.jdk.RuntimeSupport; import com.oracle.svm.core.log.Log; @@ -40,12 +39,13 @@ import com.oracle.svm.core.thread.JavaVMOperation; import com.oracle.svm.core.thread.PlatformThreads; import com.oracle.svm.core.thread.VMThreads; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import sun.misc.Signal; import sun.misc.SignalHandler; -@AutomaticFeature -public class DumpThreadStacksOnSignalFeature implements Feature { +@AutomaticallyRegisteredFeature +public class DumpThreadStacksOnSignalFeature implements InternalFeature { @Override public boolean isInConfiguration(IsInConfigurationAccess access) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/IsolateArgumentParser.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/IsolateArgumentParser.java index 2c6e42199ed6..7207ee150851 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/IsolateArgumentParser.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/IsolateArgumentParser.java @@ -37,14 +37,13 @@ import org.graalvm.nativeimage.c.type.CCharPointerPointer; import org.graalvm.nativeimage.c.type.CIntPointer; import org.graalvm.nativeimage.c.type.CLongPointer; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.c.CGlobalData; import com.oracle.svm.core.c.CGlobalDataFactory; import com.oracle.svm.core.c.function.CEntryPointCreateIsolateParameters; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.headers.LibC; import com.oracle.svm.core.option.RuntimeOptionKey; import com.oracle.svm.core.util.VMError; @@ -53,6 +52,7 @@ * Parses a small subset of the runtime arguments before the image heap is mapped and before the * isolate is fully started. */ +@AutomaticallyRegisteredImageSingleton public class IsolateArgumentParser { private static final RuntimeOptionKey[] OPTIONS = {SubstrateGCOptions.MinHeapSize, SubstrateGCOptions.MaxHeapSize, SubstrateGCOptions.MaxNewSize, SubstrateOptions.ConcealedOptions.AutomaticReferenceHandling, SubstrateOptions.ConcealedOptions.UsePerfData}; @@ -437,11 +437,3 @@ public static boolean isNumeric(byte optionValueType) { } } } - -@AutomaticFeature -class IsolateArgumentParserFeature implements Feature { - @Override - public void duringSetup(DuringSetupAccess access) { - ImageSingletons.add(IsolateArgumentParser.class, new IsolateArgumentParser()); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/IsolateListenerFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/IsolateListenerFeature.java index 205174a58481..326709604f60 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/IsolateListenerFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/IsolateListenerFeature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,15 +24,21 @@ */ package com.oracle.svm.core; -import org.graalvm.nativeimage.ImageSingletons; +import java.util.List; + import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; -@AutomaticFeature -public class IsolateListenerFeature implements Feature { +/** + * For compatibility with legacy code. + */ +@AutomaticallyRegisteredFeature +@Deprecated +public class IsolateListenerFeature implements InternalFeature { @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(IsolateListenerSupport.class, new IsolateListenerSupport()); + public List> getRequiredFeatures() { + return List.of(IsolateListenerSupportFeature.class); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/IsolateListenerSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/IsolateListenerSupport.java index 607145b96073..0f9a5e51be2f 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/IsolateListenerSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/IsolateListenerSupport.java @@ -32,6 +32,9 @@ import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; + +@AutomaticallyRegisteredImageSingleton public class IsolateListenerSupport { private IsolateListener[] listeners; 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 e8c2848527dc..842fe64bd4c6 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 @@ -34,12 +34,11 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.option.APIOption; import com.oracle.svm.core.option.HostedOptionKey; import com.oracle.svm.core.option.LocatableMultiOptionValue; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.VMError; class RuntimeAssertionsOptionTransformer implements Function { @@ -77,6 +76,7 @@ static class Disable extends RuntimeAssertionsOptionTransformer { } } +@AutomaticallyRegisteredImageSingleton @Platforms(Platform.HOSTED_ONLY.class) public final class RuntimeAssertionsSupport { @@ -192,11 +192,3 @@ public boolean desiredAssertionStatus(Class clazz) { return desiredAssertionStatusImpl(clazz.getName(), clazz.getClassLoader()); } } - -@AutomaticFeature -class RuntimeAssertionsFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(RuntimeAssertionsSupport.class, new RuntimeAssertionsSupport()); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/StaticFieldsSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/StaticFieldsSupport.java index ba8c002572b8..f390af8d1b69 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/StaticFieldsSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/StaticFieldsSupport.java @@ -47,10 +47,11 @@ import org.graalvm.nativeimage.Platforms; import org.graalvm.word.LocationIdentity; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.meta.SharedField; import com.oracle.svm.core.meta.SubstrateObjectConstant; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.VMError; import jdk.vm.ci.meta.JavaConstant; @@ -77,6 +78,7 @@ * the {@link StaticFieldBaseNode} with a {@link ConstantNode} only in the low tier of the compiler * solves this problem. */ +@AutomaticallyRegisteredImageSingleton public final class StaticFieldsSupport { @Platforms(Platform.HOSTED_ONLY.class) // @@ -164,12 +166,8 @@ public void lower(LoweringTool tool) { } } -@AutomaticFeature +@AutomaticallyRegisteredFeature final class StaticFieldsFeature implements InternalFeature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(StaticFieldsSupport.class, new StaticFieldsSupport()); - } @Override public void registerInvocationPlugins(Providers providers, SnippetReflectionProvider snippetReflection, Plugins plugins, ParsingReason reason) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateExitHandlerFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateExitHandlerFeature.java index 77ec9b0cde7d..d1ff3cac988b 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateExitHandlerFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/SubstrateExitHandlerFeature.java @@ -24,15 +24,14 @@ */ package com.oracle.svm.core; -import org.graalvm.nativeimage.hosted.Feature; - import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.annotate.TargetClass; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.RuntimeSupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; -@AutomaticFeature -public class SubstrateExitHandlerFeature implements Feature { +@AutomaticallyRegisteredFeature +public class SubstrateExitHandlerFeature implements InternalFeature { @Override public void beforeAnalysis(BeforeAnalysisAccess access) { if (SubstrateOptions.InstallExitHandlers.getValue()) { 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 9bab3f00fba2..130e57bc4fcf 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 @@ -35,7 +35,6 @@ import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.LogHandler; import org.graalvm.nativeimage.c.function.CodePointer; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.LocationIdentity; import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; @@ -43,14 +42,15 @@ import com.oracle.svm.core.IsolateListenerSupport.IsolateListener; import com.oracle.svm.core.SubstrateSegfaultHandler.SingleIsolateSegfaultSetup; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.heap.RestrictHeapAccess; import com.oracle.svm.core.c.CGlobalData; import com.oracle.svm.core.c.CGlobalDataFactory; import com.oracle.svm.core.c.function.CEntryPointActions; import com.oracle.svm.core.c.function.CEntryPointErrors; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.nodes.WriteCurrentVMThreadNode; import com.oracle.svm.core.graal.snippets.CEntryPointSnippets; +import com.oracle.svm.core.heap.RestrictHeapAccess; import com.oracle.svm.core.jdk.RuntimeSupport; import com.oracle.svm.core.log.Log; import com.oracle.svm.core.option.RuntimeOptionKey; @@ -60,10 +60,10 @@ import com.oracle.svm.core.thread.VMThreads.SafepointBehavior; import com.oracle.svm.core.util.VMError; -@AutomaticFeature -class SubstrateSegfaultHandlerFeature implements Feature { +@AutomaticallyRegisteredFeature +class SubstrateSegfaultHandlerFeature implements InternalFeature { @Override - public void beforeAnalysis(Feature.BeforeAnalysisAccess access) { + public void beforeAnalysis(BeforeAnalysisAccess access) { if (!ImageSingletons.contains(SubstrateSegfaultHandler.class)) { return; /* No segfault handler. */ } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/aarch64/AArch64FrameAccess.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/aarch64/AArch64FrameAccess.java index c06f9cc1880f..ed6e5b445b82 100755 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/aarch64/AArch64FrameAccess.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/aarch64/AArch64FrameAccess.java @@ -24,27 +24,18 @@ */ package com.oracle.svm.core.aarch64; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.compiler.api.replacements.Fold; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.function.CodePointer; import org.graalvm.word.Pointer; import com.oracle.svm.core.FrameAccess; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; -@AutomaticFeature +@AutomaticallyRegisteredImageSingleton(FrameAccess.class) @Platforms(Platform.AARCH64.class) -class AArch64FrameAccessFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(FrameAccess.class, new AArch64FrameAccess()); - } -} - public class AArch64FrameAccess extends FrameAccess { @Override @Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/allocationprofile/AllocationSite.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/allocationprofile/AllocationSite.java index f5356f138174..48b8ba94137e 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/allocationprofile/AllocationSite.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/allocationprofile/AllocationSite.java @@ -33,15 +33,16 @@ import java.util.concurrent.ConcurrentMap; import java.util.concurrent.atomic.AtomicReference; -import com.oracle.svm.core.jdk.RuntimeFeature; import org.graalvm.compiler.options.Option; import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.RuntimeSupport; +import com.oracle.svm.core.jdk.RuntimeSupportFeature; import com.oracle.svm.core.log.Log; import com.oracle.svm.core.option.HostedOptionKey; import com.oracle.svm.core.option.RuntimeOptionKey; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.MetricsLogUtils; public final class AllocationSite { @@ -212,11 +213,11 @@ public static void dumpProfilingResults(final Log log) { } } -@AutomaticFeature -class AllocationProfilingFeature implements Feature { +@AutomaticallyRegisteredFeature +class AllocationProfilingFeature implements InternalFeature { @Override public List> getRequiredFeatures() { - return Collections.singletonList(RuntimeFeature.class); + return Collections.singletonList(RuntimeSupportFeature.class); } @Override diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/amd64/AMD64FrameAccess.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/amd64/AMD64FrameAccess.java index 823e37fb8e3e..740a04cb056b 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/amd64/AMD64FrameAccess.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/amd64/AMD64FrameAccess.java @@ -25,8 +25,6 @@ package com.oracle.svm.core.amd64; import org.graalvm.compiler.api.replacements.Fold; -import org.graalvm.nativeimage.hosted.Feature; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform.AMD64; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.function.CodePointer; @@ -34,18 +32,10 @@ import com.oracle.svm.core.FrameAccess; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; -@AutomaticFeature -@Platforms(AMD64.class) -class AMD64FrameAccessFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(FrameAccess.class, new AMD64FrameAccess()); - } -} - +@AutomaticallyRegisteredImageSingleton(FrameAccess.class) @Platforms(AMD64.class) public final class AMD64FrameAccess extends FrameAccess { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/CTypeConversionSupportImpl.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/CTypeConversionSupportImpl.java index debedba55366..f39e6cabb8cb 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/CTypeConversionSupportImpl.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/CTypeConversionSupportImpl.java @@ -29,12 +29,9 @@ import java.nio.charset.StandardCharsets; import java.util.Arrays; -import com.oracle.svm.core.jdk.Target_java_nio_DirectByteBuffer; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.PinnedObject; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CTypeConversion.CCharPointerHolder; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.CTypeConversionSupport; import org.graalvm.word.Pointer; import org.graalvm.word.PointerBase; @@ -42,9 +39,11 @@ import org.graalvm.word.WordFactory; import com.oracle.svm.core.SubstrateUtil; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.config.ConfigurationValues; +import com.oracle.svm.core.jdk.Target_java_nio_DirectByteBuffer; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +@AutomaticallyRegisteredImageSingleton(CTypeConversionSupport.class) class CTypeConversionSupportImpl implements CTypeConversionSupport { static final CCharPointerHolder NULL_HOLDER = new CCharPointerHolder() { @@ -186,11 +185,3 @@ public void close() { cstring.close(); } } - -@AutomaticFeature -class CTypeConversionFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(CTypeConversionSupport.class, new CTypeConversionSupportImpl()); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/ProjectHeaderFile.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/ProjectHeaderFile.java index 5934eeb5e308..b0617dae28c2 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/ProjectHeaderFile.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/ProjectHeaderFile.java @@ -33,53 +33,46 @@ import java.util.List; import java.util.Optional; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.ImageSingletons; +import org.graalvm.nativeimage.hosted.Feature; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.option.OptionUtils; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.VMError; -public final class ProjectHeaderFile { - - @AutomaticFeature - public static class RegisterSVMTestingResolverFeature extends RegisterFallbackResolverFeature { +@AutomaticallyRegisteredFeature +class RegisterSVMTestingResolverFeature extends ProjectHeaderFile.RegisterFallbackResolverFeature { - @Override - public boolean isInConfiguration(IsInConfigurationAccess access) { - return access.findClassByName("com.oracle.svm.tutorial.CInterfaceTutorial") != null; - } - - @Override - public void afterRegistration(AfterRegistrationAccess access) { - /** - * Search for headers in a directory, relative to the current working directory, that - * contains the Substrate VM projects. Using the "../substratevm*" relative path - * accounts for running SVM from sibling suites. - */ - HeaderResolversRegistry.registerAdditionalResolver(new FallbackHeaderResolver("../../graal/substratevm/src")); - } + @Override + public boolean isInConfiguration(IsInConfigurationAccess access) { + return access.findClassByName("com.oracle.svm.tutorial.CInterfaceTutorial") != null; } - @AutomaticFeature - public static class HeaderResolverRegistrationFeature implements Feature { - - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(HeaderResolversRegistry.class, new HeaderResolversRegistry()); - } + @Override + public void afterRegistration(AfterRegistrationAccess access) { + /** + * Search for headers in a directory, relative to the current working directory, that + * contains the Substrate VM projects. Using the "../substratevm*" relative path accounts + * for running SVM from sibling suites. + */ + ProjectHeaderFile.HeaderResolversRegistry.registerAdditionalResolver(new ProjectHeaderFile.FallbackHeaderResolver("../../graal/substratevm/src")); } +} + +public final class ProjectHeaderFile { /** * Base class for fall back resolvers registration. Extending this class will ensure that the * {@link ProjectHeaderFile} will be added as a dependency. */ - public abstract static class RegisterFallbackResolverFeature implements Feature { + public abstract static class RegisterFallbackResolverFeature implements InternalFeature { @Override public List> getRequiredFeatures() { - return Collections.singletonList(HeaderResolverRegistrationFeature.class); + return Collections.singletonList(ProjectHeaderFileHeaderResolversRegistryFeature.class); } } @@ -95,6 +88,7 @@ public static String resolve(String projectName, String headerFile) { * A registry for all the header resolvers. The search order is important, we want first to * search the location(s) specified by CLibraryPath, then registered fall back locations if any. */ + @AutomaticallyRegisteredImageSingleton public static class HeaderResolversRegistry { /** Register additional resolvers. */ diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/IsolateSupportImpl.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/IsolateSupportImpl.java index 400c51c5d279..3a55e21539a6 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/IsolateSupportImpl.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/c/function/IsolateSupportImpl.java @@ -26,7 +26,6 @@ import java.util.List; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Isolate; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Isolates.CreateIsolateParameters; @@ -37,27 +36,23 @@ import org.graalvm.nativeimage.c.struct.SizeOf; import org.graalvm.nativeimage.c.type.CCharPointerPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.IsolateSupport; import org.graalvm.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.c.function.CEntryPointNativeFunctions.IsolateThreadPointer; import com.oracle.svm.core.option.SubstrateOptionsParser; import com.oracle.svm.core.os.MemoryProtectionProvider; import com.oracle.svm.core.os.MemoryProtectionProvider.UnsupportedDomainException; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +@AutomaticallyRegisteredImageSingleton(IsolateSupport.class) public final class IsolateSupportImpl implements IsolateSupport { private static final String ISOLATES_DISABLED_MESSAGE = "Spawning of multiple isolates is disabled, use " + SubstrateOptionsParser.commandArgument(SubstrateOptions.SpawnIsolates, "+") + " option."; private static final String PROTECTION_DOMAIN_UNSUPPORTED_MESSAGE = "Protection domains are unavailable"; - static void initialize() { - ImageSingletons.add(IsolateSupport.class, new IsolateSupportImpl()); - } - - private IsolateSupportImpl() { + IsolateSupportImpl() { } @Override @@ -165,11 +160,3 @@ private static void throwOnError(int code) { } } } - -@AutomaticFeature -class IsolateSupportFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - IsolateSupportImpl.initialize(); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/CodeInfoMemoryWalker.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/CodeInfoMemoryWalker.java index 670b85e6398f..10e3aa9a2aad 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/CodeInfoMemoryWalker.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/CodeInfoMemoryWalker.java @@ -24,15 +24,14 @@ */ package com.oracle.svm.core.code; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.UnsignedWord; import com.oracle.svm.core.MemoryWalker; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +@AutomaticallyRegisteredImageSingleton final class CodeInfoMemoryWalker implements MemoryWalker.CodeAccess { @Platforms(Platform.HOSTED_ONLY.class) @@ -59,11 +58,3 @@ public String getName(CodeInfo codeInfo) { return CodeInfoAccess.getName(codeInfo); } } - -@AutomaticFeature -class CodeInfoMemoryWalkerFeature implements Feature { - @Override - public void beforeAnalysis(BeforeAnalysisAccess access) { - ImageSingletons.add(CodeInfoMemoryWalker.class, new CodeInfoMemoryWalker()); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/CodeInfoTable.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/CodeInfoTable.java index b211c4d86304..a80887a3e9ac 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/CodeInfoTable.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/CodeInfoTable.java @@ -35,17 +35,18 @@ import org.graalvm.word.Pointer; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.heap.RestrictHeapAccess; -import com.oracle.svm.core.heap.RestrictHeapAccess.Access; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.NonmovableArray; import com.oracle.svm.core.c.NonmovableArrays; import com.oracle.svm.core.deopt.DeoptimizedFrame; import com.oracle.svm.core.deopt.SubstrateInstalledCode; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.heap.CodeReferenceMapDecoder; import com.oracle.svm.core.heap.ObjectReferenceVisitor; import com.oracle.svm.core.heap.ReferenceMapIndex; +import com.oracle.svm.core.heap.RestrictHeapAccess; +import com.oracle.svm.core.heap.RestrictHeapAccess.Access; import com.oracle.svm.core.heap.VMOperationInfos; import com.oracle.svm.core.log.Log; import com.oracle.svm.core.option.HostedOptionKey; @@ -282,8 +283,8 @@ final class CodeInfoTableCounters { final Counter invalidateInstalledCodeCount = new Counter(counters, "invalidateInstalledCode", ""); } -@AutomaticFeature -class CodeInfoFeature implements Feature { +@AutomaticallyRegisteredFeature +class CodeInfoFeature implements InternalFeature { @Override public List> getRequiredFeatures() { return Arrays.asList(CounterFeature.class); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/InstalledCodeObserverFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/InstalledCodeObserverFeature.java deleted file mode 100644 index e62df9930164..000000000000 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/InstalledCodeObserverFeature.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2016, 2017, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.svm.core.code; - -import org.graalvm.nativeimage.hosted.Feature; -import org.graalvm.nativeimage.ImageSingletons; - -import com.oracle.svm.core.annotate.AutomaticFeature; - -@AutomaticFeature -public final class InstalledCodeObserverFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(InstalledCodeObserverSupport.class, new InstalledCodeObserverSupport()); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/InstalledCodeObserverSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/InstalledCodeObserverSupport.java index 4744dca955b0..0cb5153f681f 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/InstalledCodeObserverSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/code/InstalledCodeObserverSupport.java @@ -39,7 +39,9 @@ import com.oracle.svm.core.c.NonmovableArrays; import com.oracle.svm.core.code.InstalledCodeObserver.InstalledCodeObserverHandle; import com.oracle.svm.core.meta.SharedMethod; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +@AutomaticallyRegisteredImageSingleton public final class InstalledCodeObserverSupport { private static final InstalledCodeObserverHandleAction ACTION_ATTACH = h -> getAccessor(h).attachToCurrentIsolate(h); private static final InstalledCodeObserverHandleAction ACTION_DETACH = h -> getAccessor(h).detachFromCurrentIsolate(h); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/cpufeature/RuntimeCPUFeatureCheckImpl.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/cpufeature/RuntimeCPUFeatureCheckImpl.java index e0a211ae0f0b..12c16244b781 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/cpufeature/RuntimeCPUFeatureCheckImpl.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/cpufeature/RuntimeCPUFeatureCheckImpl.java @@ -54,9 +54,11 @@ import com.oracle.svm.core.CPUFeatureAccess; import com.oracle.svm.core.SubstrateTargetDescription; import com.oracle.svm.core.SubstrateUtil; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.config.ConfigurationValues; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.RuntimeSupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.util.ReflectionUtil; import jdk.vm.ci.aarch64.AArch64; @@ -66,13 +68,8 @@ import jdk.vm.ci.meta.MetaAccessProvider; import jdk.vm.ci.meta.ResolvedJavaField; -@AutomaticFeature -class RuntimeCPUFeatureCheckFeature implements Feature { - - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(RuntimeCPUFeatureCheckImpl.class, new RuntimeCPUFeatureCheckImpl()); - } +@AutomaticallyRegisteredFeature +class RuntimeCPUFeatureCheckFeature implements InternalFeature { @Override public void duringSetup(DuringSetupAccess access) { @@ -106,6 +103,7 @@ public void execute(boolean isFirstIsolate) { * native image startup in a global variable, then consulting this global value for each CPU feature * test. */ +@AutomaticallyRegisteredImageSingleton @NodeIntrinsicFactory public final class RuntimeCPUFeatureCheckImpl { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/feature/AutomaticallyRegisteredFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/feature/AutomaticallyRegisteredFeature.java new file mode 100644 index 000000000000..5a862d1b0ab0 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/feature/AutomaticallyRegisteredFeature.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.feature; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + +/** + * {@link InternalFeature} classes with this annotation are automatically registered using an + * annotation processor. + * + * Note that this requires the `SVM_PROCESSOR` to be defined as an annotation processor in the + * suite.py file. + * + * Only classes that are part of the image builder can use this annotation. Even parts of GraalVM + * that are not on the image builder class path, but on the application class path, cannot use this + * annotation. For example, the "driver" or our JVMTI agent implementations are part of the + * application class path and therefore need to use explicit feature registration via a + * native-image.properties file. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE}) +@Platforms(Platform.HOSTED_ONLY.class) +public @interface AutomaticallyRegisteredFeature { + +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ThreadListenerFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/feature/AutomaticallyRegisteredFeatureServiceRegistration.java similarity index 69% rename from substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ThreadListenerFeature.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/feature/AutomaticallyRegisteredFeatureServiceRegistration.java index 0907a7aa41f9..e36d3e22d6a7 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ThreadListenerFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/feature/AutomaticallyRegisteredFeatureServiceRegistration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -22,17 +22,12 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.core.thread; +package com.oracle.svm.core.feature; -import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; - -import com.oracle.svm.core.annotate.AutomaticFeature; - -@AutomaticFeature -public class ThreadListenerFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(ThreadListenerSupport.class, new ThreadListenerSupport()); - } +/** + * Do not implement this interface. It is only used for classes automatically generated by the + * annotation processor for {@link AutomaticallyRegisteredFeature}. + */ +public interface AutomaticallyRegisteredFeatureServiceRegistration { + String getClassName(); } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/feature/AutomaticallyRegisteredImageSingleton.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/feature/AutomaticallyRegisteredImageSingleton.java new file mode 100644 index 000000000000..241a17752dd0 --- /dev/null +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/feature/AutomaticallyRegisteredImageSingleton.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.core.feature; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; +import java.util.function.BooleanSupplier; + +import org.graalvm.nativeimage.ImageSingletons; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; +import org.graalvm.nativeimage.hosted.Feature; + +/** + * Convenience annotation to automatically register a singleton instance of the annotated class in + * {@link ImageSingletons}. + * + * The singleton is allocated and registered in a {@link Feature#afterRegistration} hook, and the + * feature does not have any dependencies on other features. The order in which such features are + * registered is not deterministic and cannot be influenced. This means that the constructor of + * annotated class must not rely on other features being registered already, or other image + * singletons being present already. + * + * The requirements and restrictions of {@link AutomaticallyRegisteredFeature} apply also to this + * annotation. + */ +@Retention(RetentionPolicy.RUNTIME) +@Target({ElementType.TYPE}) +@Platforms(Platform.HOSTED_ONLY.class) +public @interface AutomaticallyRegisteredImageSingleton { + + /** + * The keys under which the singleton is registered in {@link ImageSingletons}. If no keys are + * specified, the annotated class itself is used as the key. + */ + Class[] value() default {}; + + /** + * Register only if all provided {@link BooleanSupplier} objects evaluate to true. If there are + * no suppliers, the singleton is registered unconditionally. + */ + Class[] onlyWith() default {}; +} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/InternalFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/feature/InternalFeature.java similarity index 99% rename from substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/InternalFeature.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/feature/InternalFeature.java index 79b556b4a19c..9d7923c51d51 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/InternalFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/feature/InternalFeature.java @@ -22,7 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ -package com.oracle.svm.core.graal; +package com.oracle.svm.core.feature; import java.util.Map; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/JDKIntrinsicsFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/JDKIntrinsicsFeature.java index 9e8128845736..7658a481a86a 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/JDKIntrinsicsFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/jdk/JDKIntrinsicsFeature.java @@ -36,13 +36,13 @@ import org.graalvm.compiler.replacements.arraycopy.ArrayCopySnippets; import com.oracle.svm.core.ParsingReason; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.meta.RuntimeConfiguration; import com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider; import com.oracle.svm.core.graal.snippets.NodeLoweringProvider; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; -@AutomaticFeature +@AutomaticallyRegisteredFeature final class JDKIntrinsicsFeature implements InternalFeature { @Override @@ -68,5 +68,4 @@ private static void registerSystemPlugins(InvocationPlugins plugins) { Registration r = new Registration(plugins, System.class); ArrayCopySnippets.registerSystemArraycopyPlugin(r); } - } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/CFunctionSnippets.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/CFunctionSnippets.java index 8ff1ef20fc77..b7cc86df385b 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/CFunctionSnippets.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/CFunctionSnippets.java @@ -50,8 +50,7 @@ import com.oracle.svm.core.FrameAccess; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.meta.RuntimeConfiguration; import com.oracle.svm.core.graal.nodes.VerificationMarkerNode; import com.oracle.svm.core.graal.stackvalue.StackValueNode; @@ -64,6 +63,7 @@ import com.oracle.svm.core.stack.JavaFrameAnchors; import com.oracle.svm.core.thread.Safepoint; import com.oracle.svm.core.thread.VMThreads.StatusSupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; /** @@ -137,7 +137,7 @@ private static void epilogueSnippet(@ConstantParameter int oldThreadStatus) { MembarNode.memoryBarrier(MembarNode.FenceKind.NONE, LocationIdentity.ANY_LOCATION); } - private CFunctionSnippets(OptionValues options, Providers providers, Map, NodeLoweringProvider> lowerings) { + CFunctionSnippets(OptionValues options, Providers providers, Map, NodeLoweringProvider> lowerings) { super(options, providers); lowerings.put(CFunctionPrologueNode.class, new CFunctionPrologueLowering()); @@ -241,15 +241,15 @@ private static void matchCallStructure(CFunctionPrologueNode prologueNode) { cur = ((FixedWithNextNode) cur).next(); } } +} - @AutomaticFeature - static class CFunctionSnippetsFeature implements InternalFeature { +@AutomaticallyRegisteredFeature +class CFunctionSnippetsFeature implements InternalFeature { - @Override - @SuppressWarnings("unused") - public void registerLowerings(RuntimeConfiguration runtimeConfig, OptionValues options, Providers providers, - Map, NodeLoweringProvider> lowerings, boolean hosted) { - new CFunctionSnippets(options, providers, lowerings); - } + @Override + @SuppressWarnings("unused") + public void registerLowerings(RuntimeConfiguration runtimeConfig, OptionValues options, Providers providers, + Map, NodeLoweringProvider> lowerings, boolean hosted) { + new CFunctionSnippets(options, providers, lowerings); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/SafepointSnippets.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/SafepointSnippets.java index d9ccac4e0a99..b0b37dab4221 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/SafepointSnippets.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/SafepointSnippets.java @@ -49,9 +49,9 @@ import org.graalvm.word.LocationIdentity; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.meta.RuntimeConfiguration; import com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider; import com.oracle.svm.core.nodes.SafepointCheckNode; @@ -100,7 +100,7 @@ public void lower(SafepointNode node, LoweringTool tool) { } } -@AutomaticFeature +@AutomaticallyRegisteredFeature class SafepointFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/StackOverflowCheckImpl.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/StackOverflowCheckImpl.java index c88408dc1703..72bd048b75c0 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/StackOverflowCheckImpl.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/StackOverflowCheckImpl.java @@ -67,17 +67,17 @@ import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.heap.RestrictHeapAccess; -import com.oracle.svm.core.heap.RestrictHeapAccess.Access; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.code.CodeInfoAccess; import com.oracle.svm.core.code.CodeInfoTable; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.code.SubstrateBackend; import com.oracle.svm.core.graal.meta.RuntimeConfiguration; import com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider; import com.oracle.svm.core.heap.Heap; +import com.oracle.svm.core.heap.RestrictHeapAccess; +import com.oracle.svm.core.heap.RestrictHeapAccess.Access; import com.oracle.svm.core.heap.RestrictHeapAccessCallees; import com.oracle.svm.core.meta.SharedMethod; import com.oracle.svm.core.snippets.ImplicitExceptions; @@ -491,7 +491,7 @@ public void lower(StackOverflowCheckNode node, LoweringTool tool) { } } -@AutomaticFeature +@AutomaticallyRegisteredFeature final class StackOverflowCheckFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/aarch64/AArch64ArithmeticSnippets.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/aarch64/AArch64ArithmeticSnippets.java index 86fa21237fa9..63eeb5f77deb 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/aarch64/AArch64ArithmeticSnippets.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/aarch64/AArch64ArithmeticSnippets.java @@ -44,9 +44,9 @@ import org.graalvm.nativeimage.Platform.AARCH64; import org.graalvm.nativeimage.Platforms; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; -import com.oracle.svm.core.graal.InternalFeature; +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.graal.snippets.ArithmeticSnippets; import com.oracle.svm.core.graal.snippets.NodeLoweringProvider; @@ -300,7 +300,7 @@ public void lower(RemNode node, LoweringTool tool) { } } -@AutomaticFeature +@AutomaticallyRegisteredFeature @Platforms(AARCH64.class) final class AArch64ArithmeticForeignCallsFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/aarch64/AArch64SnippetsFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/aarch64/AArch64SnippetsFeature.java index a709fd03fb24..c1266293d028 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/aarch64/AArch64SnippetsFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/aarch64/AArch64SnippetsFeature.java @@ -34,15 +34,15 @@ import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.meta.RuntimeConfiguration; import com.oracle.svm.core.graal.snippets.NodeLoweringProvider; import com.oracle.svm.core.heap.RestrictHeapAccessCallees; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import jdk.vm.ci.meta.ResolvedJavaMethod; -@AutomaticFeature +@AutomaticallyRegisteredFeature @Platforms(Platform.AARCH64.class) class AArch64SnippetsFeature implements InternalFeature { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/amd64/AMD64SnippetsFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/amd64/AMD64SnippetsFeature.java index fbddacebfe00..63a9ff2c5cfb 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/amd64/AMD64SnippetsFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/snippets/amd64/AMD64SnippetsFeature.java @@ -34,15 +34,15 @@ import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.meta.RuntimeConfiguration; import com.oracle.svm.core.graal.snippets.NodeLoweringProvider; import com.oracle.svm.core.heap.RestrictHeapAccessCallees; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import jdk.vm.ci.meta.ResolvedJavaMethod; -@AutomaticFeature +@AutomaticallyRegisteredFeature @Platforms(Platform.AMD64.class) class AMD64SnippetsFeature implements InternalFeature { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/stackvalue/StackValueFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/stackvalue/StackValueFeature.java index 94b35da4fc27..fab26e8b64a3 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/stackvalue/StackValueFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/graal/stackvalue/StackValueFeature.java @@ -35,10 +35,10 @@ import org.graalvm.compiler.phases.tiers.Suites; import org.graalvm.compiler.phases.util.Providers; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; -@AutomaticFeature +@AutomaticallyRegisteredFeature public class StackValueFeature implements InternalFeature { @Override public void registerGraalPhases(Providers providers, SnippetReflectionProvider snippetReflection, Suites suites, boolean hosted) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/handles/ObjectHandlesFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/handles/ObjectHandlesSupportImpl.java similarity index 81% rename from substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/handles/ObjectHandlesFeature.java rename to substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/handles/ObjectHandlesSupportImpl.java index e30461194eaf..4b0bfb68c827 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/handles/ObjectHandlesFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/handles/ObjectHandlesSupportImpl.java @@ -24,13 +24,12 @@ */ package com.oracle.svm.core.handles; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.ObjectHandles; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.ObjectHandlesSupport; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +@AutomaticallyRegisteredImageSingleton(ObjectHandlesSupport.class) class ObjectHandlesSupportImpl implements ObjectHandlesSupport { final ObjectHandlesImpl globalHandles = new ObjectHandlesImpl(); @@ -44,11 +43,3 @@ public ObjectHandles createHandles() { return new ObjectHandlesImpl(); } } - -@AutomaticFeature -class ObjectHandlesFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(ObjectHandlesSupport.class, new ObjectHandlesSupportImpl()); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/AllocationFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/AllocationFeature.java index f5d30671091c..a10a92d79eb7 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/AllocationFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/AllocationFeature.java @@ -26,12 +26,12 @@ import org.graalvm.nativeimage.ImageSingletons; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.graal.InternalFeature; +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.graal.snippets.SubstrateAllocationSnippets; -@AutomaticFeature +@AutomaticallyRegisteredFeature public class AllocationFeature implements InternalFeature { @Override public void duringSetup(DuringSetupAccess access) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/GCCause.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/GCCause.java index 6eb36dc2244f..44b7c4e7b889 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/GCCause.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/GCCause.java @@ -28,11 +28,11 @@ import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.util.DuplicatedInNativeCode; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.util.DuplicatedInNativeCode; import com.oracle.svm.core.util.VMError; /** @@ -93,8 +93,8 @@ public static void cacheReverseMapping() { } } -@AutomaticFeature -class GCCauseFeature implements Feature { +@AutomaticallyRegisteredFeature +class GCCauseFeature implements InternalFeature { @Override public void beforeCompilation(BeforeCompilationAccess access) { GCCause.cacheReverseMapping(); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/HeapSizeVerifier.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/HeapSizeVerifier.java index edbd2a2045de..1fd17721b1d7 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/HeapSizeVerifier.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/HeapSizeVerifier.java @@ -24,13 +24,13 @@ */ package com.oracle.svm.core.heap; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; import com.oracle.svm.core.SubstrateGCOptions; import com.oracle.svm.core.SubstrateUtil; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.UserError; import com.oracle.svm.core.util.UserError.UserException; @@ -101,8 +101,8 @@ private static String format(UnsignedWord bytes) { } } -@AutomaticFeature -class HostedHeapSizeVerifierFeature implements Feature { +@AutomaticallyRegisteredFeature +class HostedHeapSizeVerifierFeature implements InternalFeature { @Override public void beforeAnalysis(BeforeAnalysisAccess access) { // At build-time, we can do a reasonable GC-independent verification of all the heap size 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 23c995736a96..ec613423bf85 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 @@ -43,7 +43,7 @@ public class PhysicalMemory { /** Implemented by operating-system specific code. */ - protected interface PhysicalMemorySupport { + public interface PhysicalMemorySupport { default boolean hasSize() { throw VMError.shouldNotReachHere("Unused, will be removed"); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceAccessImpl.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceAccessImpl.java index 473e7a7fb13b..48b13f1cbefa 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceAccessImpl.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceAccessImpl.java @@ -30,23 +30,20 @@ import org.graalvm.compiler.word.ObjectAccess; import org.graalvm.compiler.word.Word; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.AlwaysInline; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.config.ConfigurationValues; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +@AutomaticallyRegisteredImageSingleton(ReferenceAccess.class) public final class ReferenceAccessImpl implements ReferenceAccess { - static void initialize() { - ImageSingletons.add(ReferenceAccess.class, new ReferenceAccessImpl()); - } - private ReferenceAccessImpl() { + ReferenceAccessImpl() { } @Override @@ -121,11 +118,3 @@ public UnsignedWord getAddressSpaceSize() { return WordFactory.unsigned((1L << 48) - 1); } } - -@AutomaticFeature -class ReferenceAccessFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ReferenceAccessImpl.initialize(); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceHandlerThread.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceHandlerThread.java index b47d1301bea3..928d713117e2 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceHandlerThread.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/ReferenceHandlerThread.java @@ -30,12 +30,12 @@ import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.thread.ThreadingSupportImpl; import com.oracle.svm.core.thread.VMThreads; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; public final class ReferenceHandlerThread implements Runnable { @@ -104,8 +104,8 @@ static boolean isSupported() { } } -@AutomaticFeature -class ReferenceHandlerThreadFeature implements Feature { +@AutomaticallyRegisteredFeature +class ReferenceHandlerThreadFeature implements InternalFeature { @Override public boolean isInConfiguration(IsInConfigurationAccess access) { return ReferenceHandlerThread.isSupported(); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/VMOperationInfos.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/VMOperationInfos.java index 457c5cdc0e23..c9ee64db009a 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/VMOperationInfos.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heap/VMOperationInfos.java @@ -28,14 +28,15 @@ import java.util.Map.Entry; import java.util.Objects; -import com.oracle.svm.core.thread.VMOperation; import org.graalvm.compiler.api.replacements.Fold; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; +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.thread.VMOperation; import com.oracle.svm.core.thread.VMOperation.SystemEffect; /** @@ -44,6 +45,7 @@ * * The VM operation names are user facing as they are for example used in JFR events. */ +@AutomaticallyRegisteredImageSingleton public final class VMOperationInfos { @Platforms(Platform.HOSTED_ONLY.class) private static final HashMap hostedMap = new HashMap<>(); @UnknownObjectField(types = String[].class) static String[] names = new String[0]; @@ -116,13 +118,8 @@ public int hashCode() { } } -@AutomaticFeature -class VMOperationNamesFeatures implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(VMOperationInfos.class, new VMOperationInfos()); - } - +@AutomaticallyRegisteredFeature +class VMOperationNamesFeatures implements InternalFeature { @Override public void beforeCompilation(BeforeCompilationAccess access) { VMOperationInfos.cacheNames(); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heapdump/HeapDumpFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heapdump/HeapDumpFeature.java index def30346c186..0b0336c6014d 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heapdump/HeapDumpFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heapdump/HeapDumpFeature.java @@ -27,16 +27,23 @@ import java.io.FileOutputStream; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; +import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.impl.HeapDumpSupport; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; -@AutomaticFeature -public final class HeapDumpFeature implements Feature { +@AutomaticallyRegisteredFeature +public final class HeapDumpFeature implements InternalFeature { @Override public void afterRegistration(AfterRegistrationAccess access) { ImageSingletons.add(HeapDumpSupport.class, new HeapDumpSupportImpl()); + ImageSingletons.add(HeapDumpUtils.class, new HeapDumpUtils()); + if (Platform.includedIn(Platform.WINDOWS.class)) { + ImageSingletons.add(HeapDumpWriter.class, new UnimplementedHeapDumpWriter("Currently not supported for " + ImageSingletons.lookup(Platform.class))); + } else { + ImageSingletons.add(HeapDumpWriter.class, new HeapDumpWriterImpl()); + } } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heapdump/HeapDumpUtils.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heapdump/HeapDumpUtils.java index 81c29f51c1cb..2272d3b830ee 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heapdump/HeapDumpUtils.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heapdump/HeapDumpUtils.java @@ -26,7 +26,6 @@ import static com.oracle.svm.core.snippets.KnownIntrinsics.readCallerStackPointer; -import com.oracle.svm.core.heap.VMOperationInfos; import org.graalvm.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.ImageSingletons; @@ -34,22 +33,21 @@ import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.function.CodePointer; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.Pointer; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.NeverInline; -import com.oracle.svm.core.heap.RestrictHeapAccess; -import com.oracle.svm.core.heap.UnknownObjectField; +import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.code.CodeInfo; import com.oracle.svm.core.code.CodeInfoTable; import com.oracle.svm.core.deopt.DeoptimizedFrame; import com.oracle.svm.core.heap.Heap; import com.oracle.svm.core.heap.ObjectReferenceVisitor; import com.oracle.svm.core.heap.ObjectVisitor; +import com.oracle.svm.core.heap.RestrictHeapAccess; +import com.oracle.svm.core.heap.UnknownObjectField; +import com.oracle.svm.core.heap.VMOperationInfos; import com.oracle.svm.core.hub.DynamicHub; import com.oracle.svm.core.hub.InteriorObjRefWalker; import com.oracle.svm.core.hub.LayoutEncoding; @@ -342,12 +340,3 @@ public boolean walkStacks(StacksSlotsVisitor stacksSlotsVisitor) { } } } - -@AutomaticFeature -class HeapDumpUtilsFeature implements Feature { - - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(HeapDumpUtils.class, new HeapDumpUtils()); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heapdump/HeapDumpWriterImpl.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heapdump/HeapDumpWriterImpl.java index 8e6f00f12432..dc7ba6855a94 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heapdump/HeapDumpWriterImpl.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/heapdump/HeapDumpWriterImpl.java @@ -40,13 +40,10 @@ import org.graalvm.nativeimage.CurrentIsolate; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.IsolateThread; -import org.graalvm.nativeimage.Platform; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.Pointer; import org.graalvm.word.WordBase; import com.oracle.svm.core.StaticFieldsSupport; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.code.FrameInfoQueryResult; import com.oracle.svm.core.config.ConfigurationValues; import com.oracle.svm.core.heap.Heap; @@ -1757,17 +1754,3 @@ private static int typeIDFromClass(Class clazz) { } } } - -@AutomaticFeature -class HeapDumpWriterFeature implements Feature { - - @Override - public void afterRegistration(Feature.AfterRegistrationAccess access) { - if (Platform.includedIn(Platform.WINDOWS.class)) { - ImageSingletons.add(HeapDumpWriter.class, new UnimplementedHeapDumpWriter("Currently not supported for " + ImageSingletons.lookup(Platform.class))); - } else { - ImageSingletons.add(HeapDumpWriter.class, new HeapDumpWriterImpl()); - } - } - -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/ClassForNameSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/ClassForNameSupport.java index 18a020e4a3d5..72fc2a7e5e04 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/ClassForNameSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/ClassForNameSupport.java @@ -28,11 +28,11 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.ImageHeapMap; +@AutomaticallyRegisteredImageSingleton public final class ClassForNameSupport { static ClassForNameSupport singleton() { @@ -59,11 +59,3 @@ public static Class forNameOrNull(String className, ClassLoader classLoader) return result; } } - -@AutomaticFeature -final class ClassForNameFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(ClassForNameSupport.class, new ClassForNameSupport()); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/ClassLoadingExceptionSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/ClassLoadingExceptionSupport.java index 604c7a38c814..bc9f8b20712d 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/ClassLoadingExceptionSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/ClassLoadingExceptionSupport.java @@ -29,12 +29,12 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.option.HostedOptionKey; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.ImageHeapMap; +@AutomaticallyRegisteredImageSingleton public class ClassLoadingExceptionSupport { /** The exit code used when terminating abruptly due to missing metadata. */ @@ -73,11 +73,3 @@ private static void terminateUnconfigured(String className) { System.exit(EXIT_CODE); } } - -@AutomaticFeature -final class ClassLoadingExceptionFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(ClassLoadingExceptionSupport.class, new ClassLoadingExceptionSupport()); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHubSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHubSupport.java index ade28a12438f..593f7e334212 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHubSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/hub/DynamicHubSupport.java @@ -27,14 +27,14 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; -import com.oracle.svm.core.heap.UnknownObjectField; import com.oracle.svm.core.c.NonmovableArray; import com.oracle.svm.core.c.NonmovableArrays; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +import com.oracle.svm.core.heap.UnknownObjectField; +@AutomaticallyRegisteredImageSingleton public final class DynamicHubSupport { private int maxTypeId; @@ -64,11 +64,3 @@ public static NonmovableArray getReferenceMapEncoding() { return NonmovableArrays.fromImageHeap(ImageSingletons.lookup(DynamicHubSupport.class).referenceMapEncoding); } } - -@AutomaticFeature -class DynamicHubFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(DynamicHubSupport.class, new DynamicHubSupport()); - } -} 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 4499ab986c0b..1c01c28d52e3 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 @@ -24,11 +24,11 @@ */ package com.oracle.svm.core.identityhashcode; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; -@AutomaticFeature +@AutomaticallyRegisteredFeature final class SubstrateIdentityHashCodeFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ClassLoaderSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ClassLoaderSupport.java index e82e84ee94ca..6a5b606f4a96 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ClassLoaderSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ClassLoaderSupport.java @@ -30,10 +30,9 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.util.GuardedAnnotationAccess; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +import com.oracle.svm.util.GuardedAnnotationAccess; /** * This class stores information about which packages need to be stored within each ClassLoader. @@ -52,6 +51,7 @@ * updated to contain references to all appropriate packages. * */ +@AutomaticallyRegisteredImageSingleton @Platforms(Platform.HOSTED_ONLY.class) public final class ClassLoaderSupport { @@ -88,11 +88,3 @@ public static ConcurrentHashMap getRegisteredPackages(ClassLoad return singleton().registeredPackages.get(classLoader); } } - -@AutomaticFeature -final class ClassLoaderSupportFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(ClassLoaderSupport.class, new ClassLoaderSupport()); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/FileSystemProviderSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/FileSystemProviderSupport.java index 0bcc855c4cc5..7a4905b95cce 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/FileSystemProviderSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/FileSystemProviderSupport.java @@ -34,11 +34,9 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.hosted.FieldValueTransformer; import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.annotate.Delete; import com.oracle.svm.core.annotate.Inject; import com.oracle.svm.core.annotate.InjectAccessors; @@ -47,7 +45,9 @@ import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.annotate.TargetElement; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.option.HostedOptionKey; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; public final class FileSystemProviderSupport { @@ -111,8 +111,8 @@ public static void remove(String scheme) { } } -@AutomaticFeature -final class FileSystemProviderFeature implements Feature { +@AutomaticallyRegisteredFeature +final class FileSystemProviderFeature implements InternalFeature { @Override public void afterRegistration(AfterRegistrationAccess access) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ForkJoinPoolFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ForkJoinPoolFeature.java index 8587966397e1..0b13d3ac036c 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ForkJoinPoolFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/ForkJoinPoolFeature.java @@ -28,13 +28,13 @@ import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; -@AutomaticFeature +@AutomaticallyRegisteredFeature @Platforms(Platform.HOSTED_ONLY.class) -class ForkJoinPoolFeature implements Feature { +class ForkJoinPoolFeature implements InternalFeature { private final DeferredCommonPool commonPool = new DeferredCommonPool(); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JDKVersionSpecificResourceBuilderJDK11OrLater.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JDKVersionSpecificResourceBuilderJDK11OrLater.java index 3f1332ea9d02..ac64ca9bf6b0 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JDKVersionSpecificResourceBuilderJDK11OrLater.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JDKVersionSpecificResourceBuilderJDK11OrLater.java @@ -30,11 +30,9 @@ import java.net.URL; import java.net.URLConnection; -import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; - -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +@AutomaticallyRegisteredImageSingleton(JDKVersionSpecificResourceBuilder.class) public class JDKVersionSpecificResourceBuilderJDK11OrLater implements JDKVersionSpecificResourceBuilder { @Override @@ -70,11 +68,3 @@ public int getContentLength() throws IOException { }; } } - -@AutomaticFeature -final class JDKVersionSpecificResourceBuilderFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(JDKVersionSpecificResourceBuilder.class, new JDKVersionSpecificResourceBuilderJDK11OrLater()); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaNetHttpFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaNetHttpFeature.java index 34923c6d2caa..e3a61efcbb6a 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaNetHttpFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/JavaNetHttpFeature.java @@ -26,16 +26,16 @@ import org.graalvm.compiler.serviceprovider.JavaVersionUtil; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.hosted.RuntimeReflection; import org.graalvm.nativeimage.impl.ConfigurationCondition; import org.graalvm.nativeimage.impl.RuntimeClassInitializationSupport; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.configure.ResourcesRegistry; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; -@AutomaticFeature -public class JavaNetHttpFeature extends JNIRegistrationUtil implements Feature { +@AutomaticallyRegisteredFeature +public class JavaNetHttpFeature extends JNIRegistrationUtil implements InternalFeature { @Override public void duringSetup(DuringSetupAccess access) { @@ -56,8 +56,8 @@ private static void registerInitFiltersAccess(DuringAnalysisAccess a) { } } -@AutomaticFeature -class SimpleWebServerFeature implements Feature { +@AutomaticallyRegisteredFeature +class SimpleWebServerFeature implements InternalFeature { @Override public boolean isInConfiguration(IsInConfigurationAccess access) { 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 28ae331e178e..6bb2e94c8907 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 @@ -39,7 +39,6 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.LocationIdentity; import org.graalvm.word.Pointer; import org.graalvm.word.SignedWord; @@ -47,16 +46,18 @@ import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.annotate.Delete; import com.oracle.svm.core.annotate.InjectAccessors; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.c.CGlobalData; import com.oracle.svm.core.c.CGlobalDataFactory; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.resources.ResourceURLConnection; import com.oracle.svm.core.option.OptionUtils; import com.oracle.svm.core.option.SubstrateOptionsParser; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.VMError; import com.oracle.svm.util.ReflectionUtil; @@ -131,13 +132,8 @@ static boolean ensureInitialized() { } } -@AutomaticFeature -class JavaNetFeature implements Feature { - - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(URLProtocolsSupport.class, new URLProtocolsSupport()); - } +@AutomaticallyRegisteredFeature +class JavaNetFeature implements InternalFeature { @Override public void duringSetup(DuringSetupAccess access) { @@ -178,6 +174,7 @@ private static void printWarning(String warningMessage) { } } +@AutomaticallyRegisteredImageSingleton class URLProtocolsSupport { @Platforms(Platform.HOSTED_ONLY.class) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/NativeLibrarySupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/NativeLibrarySupport.java index 8b2025f39aa1..5e626fd41ab5 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/NativeLibrarySupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/NativeLibrarySupport.java @@ -35,22 +35,14 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform.HOSTED_ONLY; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.PointerBase; import org.graalvm.word.WordFactory; import com.oracle.svm.core.SubstrateUtil; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.jdk.PlatformNativeLibrarySupport.NativeLibrary; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; -@AutomaticFeature -class NativeLibrarySupportFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - NativeLibrarySupport.initialize(); - } -} - +@AutomaticallyRegisteredImageSingleton public final class NativeLibrarySupport { // Essentially a revised implementation of the relevant methods in OpenJDK's ClassLoader @@ -60,10 +52,6 @@ public interface LibraryInitializer { void initialize(NativeLibrary lib); } - static void initialize() { - ImageSingletons.add(NativeLibrarySupport.class, new NativeLibrarySupport()); - } - public static NativeLibrarySupport singleton() { return ImageSingletons.lookup(NativeLibrarySupport.class); } @@ -78,7 +66,7 @@ public static NativeLibrarySupport singleton() { private LibraryInitializer libraryInitializer; - private NativeLibrarySupport() { + NativeLibrarySupport() { } @Platforms(HOSTED_ONLY.class) diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/PlatformNativeLibrarySupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/PlatformNativeLibrarySupport.java index 61c0fb049681..cff55014f11c 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/PlatformNativeLibrarySupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/PlatformNativeLibrarySupport.java @@ -30,12 +30,12 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.InternalPlatform; import org.graalvm.word.PointerBase; import com.oracle.svm.core.Isolates; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; public abstract class PlatformNativeLibrarySupport { @@ -164,8 +164,8 @@ public interface NativeLibrary { public abstract boolean initializeBuiltinLibraries(); } -@AutomaticFeature -class PlatformNativeLibrarySupportFeature implements Feature { +@AutomaticallyRegisteredFeature +class PlatformNativeLibrarySupportFeature implements InternalFeature { @Override public void beforeAnalysis(BeforeAnalysisAccess access) { if (Platform.includedIn(InternalPlatform.PLATFORM_JNI.class)) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RecomputedFields.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RecomputedFields.java index 5f0f6751133b..88521e135e30 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RecomputedFields.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RecomputedFields.java @@ -45,13 +45,11 @@ import java.util.function.Consumer; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.RuntimeClassInitializationSupport; import com.oracle.svm.core.StaticFieldsSupport; import com.oracle.svm.core.SubstrateUtil; import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.annotate.Delete; import com.oracle.svm.core.annotate.InjectAccessors; import com.oracle.svm.core.annotate.RecomputeFieldValue; @@ -59,6 +57,8 @@ import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.annotate.TargetElement; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; import com.oracle.svm.util.ReflectionUtil; @@ -240,8 +240,8 @@ final class Target_java_util_concurrent_atomic_AtomicLongFieldUpdater_LockedUpda * to know about all these fields, so we need to find the original field (the updater only stores * the field offset) and mark it as unsafe accessed. */ -@AutomaticFeature -class AtomicFieldUpdaterFeature implements Feature { +@AutomaticallyRegisteredFeature +class AtomicFieldUpdaterFeature implements InternalFeature { private final ConcurrentMap processedUpdaters = new ConcurrentHashMap<>(); private Consumer markAsUnsafeAccessed; @@ -295,8 +295,8 @@ private void processFieldUpdater(Object updater) { } } -@AutomaticFeature -class InnocuousForkJoinWorkerThreadFeature implements Feature { +@AutomaticallyRegisteredFeature +class InnocuousForkJoinWorkerThreadFeature implements InternalFeature { @Override public void duringSetup(DuringSetupAccess access) { ImageSingletons.lookup(RuntimeClassInitializationSupport.class).rerunInitialization(access.findClassByName("java.util.concurrent.ForkJoinWorkerThread$InnocuousForkJoinWorkerThread"), diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RecordSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RecordSupport.java index 5629f1a37684..a2b990ab4448 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RecordSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RecordSupport.java @@ -27,13 +27,11 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Method; -import org.graalvm.compiler.serviceprovider.JavaVersionUtil; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.VMError; /** @@ -79,6 +77,7 @@ public static RecordSupport singleton() { * Placeholder implementation for JDK versions that do not have Record classes. Since * {@link #isRecord} always returns false, the other methods must never be invoked. */ +@AutomaticallyRegisteredImageSingleton(value = RecordSupport.class, onlyWith = JDK11OrEarlier.class) final class RecordSupportJDK11OrEarlier extends RecordSupport { @Override public boolean isRecord(Class clazz) { @@ -100,16 +99,3 @@ public Constructor getCanonicalRecordConstructor(Class clazz) { throw VMError.shouldNotReachHere(); } } - -@AutomaticFeature -final class RecordFeatureBeforeJDK17 implements Feature { - @Override - public boolean isInConfiguration(IsInConfigurationAccess access) { - return JavaVersionUtil.JAVA_SPEC <= 11; - } - - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(RecordSupport.class, new RecordSupportJDK11OrEarlier()); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Resources.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Resources.java index 6fd8f17d51ac..3596120035e5 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Resources.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Resources.java @@ -40,11 +40,11 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.resources.NativeImageResourcePath; import com.oracle.svm.core.jdk.resources.ResourceStorageEntry; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.ImageHeapMap; import com.oracle.svm.core.util.VMError; @@ -268,8 +268,8 @@ private static void addURLEntries(List resourcesURLs, ResourceStorageEntry } } -@AutomaticFeature -final class ResourcesFeature implements Feature { +@AutomaticallyRegisteredFeature +final class ResourcesFeature implements InternalFeature { @Override public void afterRegistration(AfterRegistrationAccess access) { ImageSingletons.add(Resources.class, new Resources()); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RuntimeFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RuntimeFeature.java index 12ab33452c14..3fcd3191d16a 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RuntimeFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RuntimeFeature.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2017, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,18 +24,21 @@ */ package com.oracle.svm.core.jdk; -import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; -import org.graalvm.nativeimage.impl.VMRuntimeSupport; +import java.util.List; -import com.oracle.svm.core.annotate.AutomaticFeature; +import org.graalvm.nativeimage.hosted.Feature; -@AutomaticFeature -public class RuntimeFeature implements Feature { +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; +/** + * For compatibility with legacy code. + */ +@AutomaticallyRegisteredFeature +@Deprecated +public class RuntimeFeature implements InternalFeature { @Override - public void afterRegistration(AfterRegistrationAccess access) { - RuntimeSupport.initializeRuntimeSupport(); - ImageSingletons.add(VMRuntimeSupport.class, RuntimeSupport.getRuntimeSupport()); + public List> getRequiredFeatures() { + return List.of(RuntimeSupportFeature.class); } } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RuntimeSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RuntimeSupport.java index feab5ebb8559..bec5e6a57e38 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RuntimeSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/RuntimeSupport.java @@ -37,8 +37,10 @@ import com.oracle.svm.core.Isolates; import com.oracle.svm.core.heap.HeapSizeVerifier; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.VMError; +@AutomaticallyRegisteredImageSingleton({VMRuntimeSupport.class, RuntimeSupport.class}) public final class RuntimeSupport implements VMRuntimeSupport { @FunctionalInterface public interface Hook { @@ -63,13 +65,7 @@ public interface Hook { private final AtomicReference tearDownHooks = new AtomicReference<>(); @Platforms(Platform.HOSTED_ONLY.class) - private RuntimeSupport() { - } - - @Platforms(Platform.HOSTED_ONLY.class) - public static void initializeRuntimeSupport() { - assert ImageSingletons.contains(RuntimeSupport.class) == false : "Initializing RuntimeSupport again."; - ImageSingletons.add(RuntimeSupport.class, new RuntimeSupport()); + RuntimeSupport() { } @Fold diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SealedClassSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SealedClassSupport.java index 84a9292bbb9f..bf358836aaf2 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SealedClassSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/SealedClassSupport.java @@ -24,13 +24,11 @@ */ package com.oracle.svm.core.jdk; -import org.graalvm.compiler.serviceprovider.JavaVersionUtil; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; /** * Abstracts the information about sealed classes, which are not available in Java 11 and Java 8. @@ -54,6 +52,7 @@ public static SealedClassSupport singleton() { /** * Placeholder implementation for JDK versions that do not have sealed classes. */ +@AutomaticallyRegisteredImageSingleton(value = SealedClassSupport.class, onlyWith = JDK11OrEarlier.class) final class SealedClassSupportJDK11OrEarlier extends SealedClassSupport { @Override @@ -66,17 +65,3 @@ public Class[] getPermittedSubclasses(Class clazz) { return null; } } - -@AutomaticFeature -final class SealedClassFeatureJDK11OrEarlier implements Feature { - - @Override - public boolean isInConfiguration(IsInConfigurationAccess access) { - return JavaVersionUtil.JAVA_SPEC <= 11; - } - - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(SealedClassSupport.class, new SealedClassSupportJDK11OrEarlier()); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_sun_security_ssl_TrustStoreManager.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_sun_security_ssl_TrustStoreManager.java index cd39ac9822dc..180bf4bde2f6 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_sun_security_ssl_TrustStoreManager.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/Target_sun_security_ssl_TrustStoreManager.java @@ -30,15 +30,15 @@ import java.util.Set; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.RuntimeClassInitializationSupport; import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.annotate.Delete; import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; import com.oracle.svm.util.ReflectionUtil; @@ -60,8 +60,8 @@ * TrustStoreManager managers by invoking them at image build time (using reflection because the * class is non-public) and returning the frozen values using a substitution. */ -@AutomaticFeature -final class TrustStoreManagerFeature implements Feature { +@AutomaticallyRegisteredFeature +final class TrustStoreManagerFeature implements InternalFeature { static final String TRUST_STORE_MANAGER_CLASS_NAME = "sun.security.ssl.TrustStoreManager"; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/TimeZoneSubstitutions.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/TimeZoneSubstitutions.java index b544c13589ed..d1d5d5a45564 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/TimeZoneSubstitutions.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/TimeZoneSubstitutions.java @@ -38,17 +38,17 @@ import org.graalvm.nativeimage.PinnedObject; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.WordFactory; import com.oracle.svm.core.LibCHelper; import com.oracle.svm.core.OS; import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.option.HostedOptionKey; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; /** @@ -121,8 +121,8 @@ public byte[] getTzMappingsContent() { /** * Reads time zone mappings data and stores in the image heap, if necessary. */ -@AutomaticFeature -final class TimeZoneFeature implements Feature { +@AutomaticallyRegisteredFeature +final class TimeZoneFeature implements InternalFeature { static class Options { @Option(help = "When true, all time zones will be pre-initialized in the image.")// public static final HostedOptionKey IncludeAllTimeZones = new HostedOptionKey<>(false) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/VarHandleFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/VarHandleFeature.java index 195dc659bcab..6179df7a68a7 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/VarHandleFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/VarHandleFeature.java @@ -35,11 +35,9 @@ import org.graalvm.compiler.serviceprovider.JavaVersionUtil; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.svm.core.StaticFieldsSupport; import com.oracle.svm.core.annotate.Alias; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.annotate.InjectAccessors; import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.RecomputeFieldValue.Kind; @@ -47,7 +45,9 @@ import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.annotate.TargetElement; import com.oracle.svm.core.fieldvaluetransformer.FieldValueTransformerWithAvailability; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.reflect.target.ReflectionSubstitutionSupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; import com.oracle.svm.util.ReflectionUtil; @@ -91,8 +91,8 @@ * VarHandle access to arrays is the simplest case: we only need field value recomputations for the * array base offset and array index shift. */ -@AutomaticFeature -public class VarHandleFeature implements Feature { +@AutomaticallyRegisteredFeature +public class VarHandleFeature implements InternalFeature { /** The JDK 11 class VarHandleObjects got renamed to VarHandleReferences. */ static final String OBJECT_SUFFIX = JavaVersionUtil.JAVA_SPEC <= 11 ? "Objects" : "References"; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/LocalizationFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/LocalizationFeature.java index bf793b3bf4e9..7b4190e1a9b8 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/LocalizationFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/localization/LocalizationFeature.java @@ -24,19 +24,20 @@ */ package com.oracle.svm.core.jdk.localization; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.configure.ResourcesRegistry; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.ConfigurationCondition; +import com.oracle.svm.core.configure.ResourcesRegistry; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; + /** * This class is just a delegate. The real LocalizationFeature is now in * com.oracle.svm.hosted.jdk.localization. It was created in order to ensure backwards compatibility * for code depending on the location of the feature. */ -@AutomaticFeature -public class LocalizationFeature implements Feature { +@AutomaticallyRegisteredFeature +public class LocalizationFeature implements InternalFeature { /** * @deprecated Use {@link ResourcesRegistry#addResourceBundles(ConfigurationCondition, String)} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/management/ManagementFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/management/ManagementFeature.java index 3115b135ded9..0dc38ef5a691 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/management/ManagementFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jdk/management/ManagementFeature.java @@ -47,21 +47,22 @@ import org.graalvm.nativeimage.hosted.RuntimeClassInitialization; import org.graalvm.nativeimage.hosted.RuntimeReflection; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.JNIRegistrationUtil; -import com.oracle.svm.core.jdk.RuntimeFeature; -import com.oracle.svm.core.thread.ThreadListenerFeature; +import com.oracle.svm.core.jdk.RuntimeSupportFeature; import com.oracle.svm.core.thread.ThreadListenerSupport; +import com.oracle.svm.core.thread.ThreadListenerSupportFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.util.ReflectionUtil; /** See {@link ManagementSupport} for documentation. */ -@AutomaticFeature -public final class ManagementFeature extends JNIRegistrationUtil implements Feature { +@AutomaticallyRegisteredFeature +public final class ManagementFeature extends JNIRegistrationUtil implements InternalFeature { private Map platformManagedObjectReplacements; @Override public List> getRequiredFeatures() { - return Arrays.asList(RuntimeFeature.class, ThreadListenerFeature.class); + return Arrays.asList(RuntimeSupportFeature.class, ThreadListenerSupportFeature.class); } @Override diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrFeature.java index 5fb69e665186..db7736c9981f 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrFeature.java @@ -33,14 +33,15 @@ import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.RuntimeClassInitializationSupport; -import com.oracle.svm.core.VMInspectionOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.VMInspectionOptions; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.RuntimeSupport; import com.oracle.svm.core.jfr.traceid.JfrTraceIdEpoch; import com.oracle.svm.core.jfr.traceid.JfrTraceIdMap; -import com.oracle.svm.core.thread.ThreadListenerFeature; import com.oracle.svm.core.thread.ThreadListenerSupport; +import com.oracle.svm.core.thread.ThreadListenerSupportFeature; import com.oracle.svm.core.util.UserError; import com.oracle.svm.core.util.VMError; import com.oracle.svm.util.ModuleSupport; @@ -92,8 +93,8 @@ * consistent state). * */ -@AutomaticFeature -public class JfrFeature implements Feature { +@AutomaticallyRegisteredFeature +public class JfrFeature implements InternalFeature { /* * Note that we could initialize the native part of JFR at image build time and that the native * code sets the FlightRecorder option as a side effect. Therefore, we must ensure that we check @@ -147,7 +148,7 @@ private static HotSpotDiagnosticMXBean getDiagnosticBean() { @Override public List> getRequiredFeatures() { - return Collections.singletonList(ThreadListenerFeature.class); + return Collections.singletonList(ThreadListenerSupportFeature.class); } @Override diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmstat/PerfDataFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmstat/PerfDataFeature.java index a8b7f0122b7d..f05aae6d5f8a 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmstat/PerfDataFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jvmstat/PerfDataFeature.java @@ -32,12 +32,12 @@ import org.graalvm.nativeimage.hosted.Feature; import com.oracle.svm.core.VMInspectionOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.graal.InternalFeature; -import com.oracle.svm.core.jdk.RuntimeFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.RuntimeSupport; -import com.oracle.svm.core.thread.VMOperationListenerFeature; +import com.oracle.svm.core.jdk.RuntimeSupportFeature; import com.oracle.svm.core.thread.VMOperationListenerSupport; +import com.oracle.svm.core.thread.VMOperationListenerSupportFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; /** * The performance data feature (hsperfdata) provides monitoring data that can be access by external @@ -74,11 +74,11 @@ * {@link ZipFile} * */ -@AutomaticFeature +@AutomaticallyRegisteredFeature public class PerfDataFeature implements InternalFeature { @Override public List> getRequiredFeatures() { - return Arrays.asList(VMOperationListenerFeature.class, RuntimeFeature.class); + return Arrays.asList(VMOperationListenerSupportFeature.class, RuntimeSupportFeature.class); } @Override diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/locks/SingleThreadedVMLockSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/locks/SingleThreadedVMLockSupport.java index d6ef59c310e7..8d6cb8b326cd 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/locks/SingleThreadedVMLockSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/locks/SingleThreadedVMLockSupport.java @@ -27,11 +27,11 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.util.VMError; /** @@ -50,8 +50,8 @@ public VMCondition[] getConditions() { } } -@AutomaticFeature -final class SingleThreadedVMLockFeature implements Feature { +@AutomaticallyRegisteredFeature +final class SingleThreadedVMLockFeature implements InternalFeature { private final ClassInstanceReplacer mutexReplacer = new ClassInstanceReplacer<>(VMMutex.class) { @Override diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/meta/SubstrateObjectConstantEqualityFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/meta/SubstrateObjectConstantEqualityFeature.java index d925fd15d024..869497b5a8a0 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/meta/SubstrateObjectConstantEqualityFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/meta/SubstrateObjectConstantEqualityFeature.java @@ -25,9 +25,9 @@ package com.oracle.svm.core.meta; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; final class SubstrateObjectConstantEquality implements ObjectConstantEquality { @@ -42,8 +42,8 @@ public boolean test(SubstrateObjectConstant x, SubstrateObjectConstant y) { } } -@AutomaticFeature -final class SubstrateObjectConstantEqualityFeature implements Feature { +@AutomaticallyRegisteredFeature +final class SubstrateObjectConstantEqualityFeature implements InternalFeature { @Override public void duringSetup(DuringSetupAccess access) { if (!ImageSingletons.contains(ObjectConstantEquality.class)) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/monitor/MonitorFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/monitor/MonitorFeature.java index 1f0a51e26555..2abafc59190c 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/monitor/MonitorFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/monitor/MonitorFeature.java @@ -32,13 +32,13 @@ import org.graalvm.nativeimage.ImageSingletons; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.meta.RuntimeConfiguration; import com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider; import com.oracle.svm.core.graal.snippets.NodeLoweringProvider; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; -@AutomaticFeature +@AutomaticallyRegisteredFeature public class MonitorFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/RuntimeOptionValues.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/RuntimeOptionValues.java index 5e11751440dc..e4ae3c8c47d1 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/RuntimeOptionValues.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/RuntimeOptionValues.java @@ -41,15 +41,14 @@ import org.graalvm.compiler.options.OptionValues; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.RuntimeOptions.OptionClass; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.RuntimeOptionsSupport; import org.graalvm.options.OptionDescriptors; import org.graalvm.options.OptionType; import com.oracle.svm.core.annotate.AnnotateOriginal; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.heap.RestrictHeapAccess; import com.oracle.svm.core.annotate.TargetClass; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +import com.oracle.svm.core.heap.RestrictHeapAccess; import com.oracle.svm.core.util.VMError; import com.oracle.svm.util.ClassUtil; @@ -77,6 +76,7 @@ public EconomicSet getAllOptionNames() { } } +@AutomaticallyRegisteredImageSingleton(RuntimeOptionsSupport.class) class RuntimeOptionsSupportImpl implements RuntimeOptionsSupport { @Override @@ -187,18 +187,6 @@ private static long parseLong(String v) { } } -/** - * Sets option access. - */ -@AutomaticFeature -class OptionAccessFeature implements Feature { - - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(RuntimeOptionsSupport.class, new RuntimeOptionsSupportImpl()); - } -} - @TargetClass(org.graalvm.compiler.options.OptionKey.class) final class Target_org_graalvm_compiler_options_OptionKey { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/ValidateImageBuildOptionsFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/ValidateImageBuildOptionsFeature.java index c012bed2a0cb..321b7dc52a8c 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/ValidateImageBuildOptionsFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/option/ValidateImageBuildOptionsFeature.java @@ -24,13 +24,14 @@ */ package com.oracle.svm.core.option; -import com.oracle.svm.core.annotate.AutomaticFeature; import org.graalvm.collections.UnmodifiableMapCursor; import org.graalvm.compiler.options.OptionKey; -import org.graalvm.nativeimage.hosted.Feature; -@AutomaticFeature -public class ValidateImageBuildOptionsFeature implements Feature { +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; + +@AutomaticallyRegisteredFeature +public class ValidateImageBuildOptionsFeature implements InternalFeature { @Override public void afterRegistration(AfterRegistrationAccess access) { UnmodifiableMapCursor, Object> cursor = RuntimeOptionValues.singleton().getMap().getEntries(); 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 0971a1521932..cf4d711b2b4d 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 @@ -24,13 +24,13 @@ */ package com.oracle.svm.core.os; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.ImageSingletons; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; -@AutomaticFeature -public class ImageHeapProviderFeature implements Feature { +@AutomaticallyRegisteredFeature +public class ImageHeapProviderFeature implements InternalFeature { @Override public void beforeAnalysis(BeforeAnalysisAccess access) { if (!ImageSingletons.contains(ImageHeapProvider.class)) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/OSCommittedMemoryProvider.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/OSCommittedMemoryProvider.java index cda808ba28d3..a3d791b7ed00 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/OSCommittedMemoryProvider.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/os/OSCommittedMemoryProvider.java @@ -32,16 +32,16 @@ import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.type.WordPointer; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.PointerBase; import com.oracle.svm.core.Isolates; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.c.function.CEntryPointCreateIsolateParameters; import com.oracle.svm.core.c.function.CEntryPointErrors; import com.oracle.svm.core.c.function.CEntryPointSetup; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; public class OSCommittedMemoryProvider extends AbstractCommittedMemoryProvider { @Platforms(Platform.HOSTED_ONLY.class) @@ -73,8 +73,8 @@ public int tearDown() { } } -@AutomaticFeature -class OSCommittedMemoryProviderFeature implements Feature { +@AutomaticallyRegisteredFeature +class OSCommittedMemoryProviderFeature implements InternalFeature { @Override public void beforeAnalysis(BeforeAnalysisAccess access) { if (!ImageSingletons.contains(CommittedMemoryProvider.class)) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionMetadataDecoderImpl.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionMetadataDecoderImpl.java index 7a9a908345ae..31bfba7e1955 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionMetadataDecoderImpl.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionMetadataDecoderImpl.java @@ -46,6 +46,7 @@ import com.oracle.svm.core.hub.DynamicHub; import com.oracle.svm.core.reflect.ReflectionMetadataDecoder; import com.oracle.svm.core.reflect.Target_java_lang_reflect_RecordComponent; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.ByteArrayReader; /** @@ -54,6 +55,7 @@ * * See {@code ReflectionMetadataEncoderImpl} for details about the emission of the metadata. */ +@AutomaticallyRegisteredImageSingleton(ReflectionMetadataDecoder.class) public class ReflectionMetadataDecoderImpl implements ReflectionMetadataDecoder { public static final int NO_METHOD_METADATA = -1; public static final int NULL_OBJECT = -1; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionMetadataEncoding.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionMetadataEncoding.java index bbb4d56ffb5c..e649472dd9d9 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionMetadataEncoding.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/reflect/target/ReflectionMetadataEncoding.java @@ -27,8 +27,10 @@ import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.heap.UnknownObjectField; +@AutomaticallyRegisteredImageSingleton public class ReflectionMetadataEncoding { @UnknownObjectField(types = {byte[].class}) private byte[] encoding; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SubstrateSigprofHandler.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SubstrateSigprofHandler.java index 36b12202803e..687a72c0527d 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SubstrateSigprofHandler.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/sampler/SubstrateSigprofHandler.java @@ -22,7 +22,6 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ - package com.oracle.svm.core.sampler; import java.lang.management.ManagementFactory; @@ -46,12 +45,13 @@ import com.oracle.svm.core.IsolateListenerSupport; import com.oracle.svm.core.RegisterDumper; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.VMInspectionOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.VMInspectionOptions; import com.oracle.svm.core.code.CodeInfo; import com.oracle.svm.core.code.CodeInfoAccess; import com.oracle.svm.core.code.CodeInfoTable; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.nodes.WriteCurrentVMThreadNode; import com.oracle.svm.core.graal.nodes.WriteHeapBaseNode; import com.oracle.svm.core.heap.VMOperationInfos; @@ -64,14 +64,14 @@ import com.oracle.svm.core.stack.JavaFrameAnchors; import com.oracle.svm.core.stack.JavaStackWalker; import com.oracle.svm.core.thread.JavaVMOperation; -import com.oracle.svm.core.thread.ThreadListenerFeature; import com.oracle.svm.core.thread.ThreadListenerSupport; +import com.oracle.svm.core.thread.ThreadListenerSupportFeature; import com.oracle.svm.core.thread.VMThreads; import com.oracle.svm.core.util.VMError; -@AutomaticFeature +@AutomaticallyRegisteredFeature @SuppressWarnings("unused") -class SubstrateSigprofHandlerFeature implements Feature { +class SubstrateSigprofHandlerFeature implements InternalFeature { @Override public boolean isInConfiguration(IsInConfigurationAccess access) { @@ -80,7 +80,7 @@ public boolean isInConfiguration(IsInConfigurationAccess access) { @Override public List> getRequiredFeatures() { - return Arrays.asList(ThreadListenerFeature.class, JfrFeature.class, ManagementFeature.class); + return Arrays.asList(ThreadListenerSupportFeature.class, JfrFeature.class, ManagementFeature.class); } @Override diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ContinuationsFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ContinuationsFeature.java index ac318bf57f4b..457ebb5e7e61 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ContinuationsFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ContinuationsFeature.java @@ -28,20 +28,20 @@ import org.graalvm.compiler.serviceprovider.JavaVersionUtil; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.hosted.RuntimeClassInitialization; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.heap.StoredContinuation; import com.oracle.svm.core.heap.StoredContinuationAccess; import com.oracle.svm.core.option.SubstrateOptionsParser; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.UserError; import com.oracle.svm.core.util.VMError; import com.oracle.svm.util.ReflectionUtil; -@AutomaticFeature -public class ContinuationsFeature implements Feature { +@AutomaticallyRegisteredFeature +public class ContinuationsFeature implements InternalFeature { @Override public void afterRegistration(AfterRegistrationAccess access) { if (!Continuation.isSupported()) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/JavaThreadsFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/JavaThreadsFeature.java index e80338cfff75..e8e7f946b49f 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/JavaThreadsFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/JavaThreadsFeature.java @@ -30,16 +30,16 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.ConcurrentIdentityHashMap; import com.oracle.svm.core.util.UserError; import com.oracle.svm.util.ClassUtil; -@AutomaticFeature +@AutomaticallyRegisteredFeature @Platforms(Platform.HOSTED_ONLY.class) -class JavaThreadsFeature implements Feature { +class JavaThreadsFeature implements InternalFeature { static JavaThreadsFeature singleton() { return ImageSingletons.lookup(JavaThreadsFeature.class); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Safepoint.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Safepoint.java index 8e49f345d6df..ffe0b7dc9ca2 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Safepoint.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/Safepoint.java @@ -42,20 +42,18 @@ import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.LocationIdentity; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; -import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.AlwaysInline; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.util.DuplicatedInNativeCode; import com.oracle.svm.core.NeverInline; -import com.oracle.svm.core.heap.RestrictHeapAccess; +import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.graal.code.StubCallingConvention; import com.oracle.svm.core.heap.Heap; +import com.oracle.svm.core.heap.RestrictHeapAccess; import com.oracle.svm.core.jdk.UninterruptibleUtils; import com.oracle.svm.core.jfr.JfrTicks; import com.oracle.svm.core.jfr.events.SafepointBeginEvent; @@ -80,6 +78,7 @@ import com.oracle.svm.core.threadlocal.FastThreadLocalFactory; import com.oracle.svm.core.threadlocal.FastThreadLocalInt; import com.oracle.svm.core.threadlocal.VMThreadLocalInfos; +import com.oracle.svm.core.util.DuplicatedInNativeCode; import com.oracle.svm.core.util.TimeUtils; import com.oracle.svm.core.util.VMError; @@ -121,7 +120,7 @@ * not be created (or attached) during the safepoint. *

* A safepoint check is implemented as a check of {@link #safepointRequested} <= 0, which, if true, - * triggers a call to {@link #slowPathSafepointCheck}. {@link ThreadingSupportFeature} implements an + * triggers a call to {@link #slowPathSafepointCheck}. {@link ThreadingSupportImpl} implements an * optional per-thread timer on top of the safepoint mechanism. If that timer feature is * {@linkplain ThreadingSupportImpl.Options#SupportRecurringCallback supported in the image}, each * safepoint check decrements {@link #safepointRequested} before the comparison, which will cause it @@ -579,15 +578,12 @@ private static void enterSlowPathTransitionFromVMToJava() { } /** Methods for the thread that brings the system to a safepoint. */ + @AutomaticallyRegisteredImageSingleton public static final class Master { @DuplicatedInNativeCode private static final int NOT_AT_SAFEPOINT = 0; @DuplicatedInNativeCode private static final int SYNCHRONIZING = 1; @DuplicatedInNativeCode private static final int AT_SAFEPOINT = 2; - static void initialize() { - ImageSingletons.add(Master.class, new Master()); - } - @Fold public static Master singleton() { return ImageSingletons.lookup(Master.class); @@ -600,7 +596,7 @@ public static Master singleton() { private volatile IsolateThread requestingThread; @Platforms(Platform.HOSTED_ONLY.class) - private Master() { + Master() { this.safepointState = NOT_AT_SAFEPOINT; } @@ -1129,11 +1125,3 @@ public static Log toLog(Log log, boolean newLine, String prefix) { } } } - -@AutomaticFeature -class SafepointFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - Safepoint.Master.initialize(); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ThreadListenerSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ThreadListenerSupport.java index 952601ba24ec..558e6d41bb2b 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ThreadListenerSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ThreadListenerSupport.java @@ -33,7 +33,9 @@ import org.graalvm.nativeimage.Platforms; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +@AutomaticallyRegisteredImageSingleton public class ThreadListenerSupport { private ThreadListener[] listeners; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ThreadingSupportImpl.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ThreadingSupportImpl.java index 45db23df7299..e0ed7fa9fd85 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ThreadingSupportImpl.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/ThreadingSupportImpl.java @@ -32,16 +32,14 @@ import org.graalvm.compiler.api.replacements.Fold; import org.graalvm.compiler.options.Option; import org.graalvm.nativeimage.CurrentIsolate; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Threading.RecurringCallback; import org.graalvm.nativeimage.Threading.RecurringCallbackAccess; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.ThreadingSupport; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.heap.RestrictHeapAccess; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +import com.oracle.svm.core.heap.RestrictHeapAccess; import com.oracle.svm.core.option.HostedOptionKey; import com.oracle.svm.core.option.SubstrateOptionsParser; import com.oracle.svm.core.thread.Safepoint.SafepointException; @@ -52,6 +50,7 @@ import com.oracle.svm.core.threadlocal.FastThreadLocalObject; import com.oracle.svm.core.util.VMError; +@AutomaticallyRegisteredImageSingleton(ThreadingSupport.class) public class ThreadingSupportImpl implements ThreadingSupport { public static class Options { @Option(help = "Support a per-thread timer that is called at a specific interval.") // @@ -61,10 +60,6 @@ public static class Options { public static final HostedOptionKey CheckRecurringCallbackOnNativeToJavaTransition = new HostedOptionKey<>(false); } - static void initialize() { - ImageSingletons.add(ThreadingSupport.class, new ThreadingSupportImpl()); - } - /** * Implementation of a per-thread timer that uses safepoint check operations to invoke a * callback method in regular (best-effort) time intervals. The timer starts with an initial @@ -371,11 +366,3 @@ private static void throwUnchecked(Throwable exception) th throw (T) exception; // T is inferred as RuntimeException, but doesn't have to be } } - -@AutomaticFeature -class ThreadingSupportFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ThreadingSupportImpl.initialize(); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMOperationControl.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMOperationControl.java index 7cd1285dc119..e21001467146 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMOperationControl.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMOperationControl.java @@ -26,9 +26,6 @@ import static com.oracle.svm.core.SubstrateOptions.MultiThreaded; -import java.util.Collections; -import java.util.List; - import org.graalvm.compiler.api.replacements.Fold; import org.graalvm.compiler.word.Word; import org.graalvm.nativeimage.CurrentIsolate; @@ -36,18 +33,17 @@ import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.UnsignedWord; import org.graalvm.word.WordFactory; +import com.oracle.svm.core.NeverInline; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.SubstrateOptions.ConcealedOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.NeverInline; -import com.oracle.svm.core.heap.RestrictHeapAccess; -import com.oracle.svm.core.heap.RestrictHeapAccess.Access; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.heap.Heap; +import com.oracle.svm.core.heap.RestrictHeapAccess; +import com.oracle.svm.core.heap.RestrictHeapAccess.Access; import com.oracle.svm.core.heap.VMOperationInfos; import com.oracle.svm.core.locks.VMCondition; import com.oracle.svm.core.locks.VMMutex; @@ -95,6 +91,7 @@ * exceptions. * */ +@AutomaticallyRegisteredImageSingleton public final class VMOperationControl { private final VMOperationThread dedicatedVMOperationThread; private final WorkQueues mainQueues; @@ -981,16 +978,3 @@ void print(Log log, boolean allowJavaHeapAccess) { } } } - -@AutomaticFeature -class VMOperationControlFeature implements Feature { - @Override - public List> getRequiredFeatures() { - return Collections.singletonList(SafepointFeature.class); - } - - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(VMOperationControl.class, new VMOperationControl()); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMOperationListenerFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMOperationListenerFeature.java deleted file mode 100644 index eb83c2749566..000000000000 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMOperationListenerFeature.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ -package com.oracle.svm.core.thread; - -import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; - -import com.oracle.svm.core.annotate.AutomaticFeature; - -@AutomaticFeature -public class VMOperationListenerFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(VMOperationListenerSupport.class, new VMOperationListenerSupport()); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMOperationListenerSupport.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMOperationListenerSupport.java index 9e3669193f7b..84adf8ca7fc8 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMOperationListenerSupport.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/thread/VMOperationListenerSupport.java @@ -32,7 +32,9 @@ import org.graalvm.nativeimage.Platforms; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; +@AutomaticallyRegisteredImageSingleton public class VMOperationListenerSupport { private VMOperationListener[] listeners; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/threadlocal/VMThreadLocalInfos.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/threadlocal/VMThreadLocalInfos.java index b2e9c1905ece..c84faae34939 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/threadlocal/VMThreadLocalInfos.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/threadlocal/VMThreadLocalInfos.java @@ -33,17 +33,17 @@ import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.Pointer; import org.graalvm.word.WordBase; import org.graalvm.word.WordFactory; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.heap.ReferenceAccess; import com.oracle.svm.core.log.Log; +@AutomaticallyRegisteredImageSingleton public class VMThreadLocalInfos { private VMThreadLocalInfo[] infos; @@ -123,11 +123,3 @@ public static int getOffset(FastThreadLocal threadLocal) { return -1; } } - -@AutomaticFeature -class VMThreadLocalInfosFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(VMThreadLocalInfos.class, new VMThreadLocalInfos()); - } -} diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/CounterFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/CounterFeature.java index 1337897b942b..8a524426a5e1 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/CounterFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/CounterFeature.java @@ -27,14 +27,14 @@ import java.util.ArrayList; import java.util.List; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.util.Counter.Group; -@AutomaticFeature -public class CounterFeature implements Feature { +@AutomaticallyRegisteredFeature +public class CounterFeature implements InternalFeature { @Override public void afterRegistration(AfterRegistrationAccess access) { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/HostedStringDeduplication.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/HostedStringDeduplication.java index c2122d7caef7..4e8966844b2d 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/HostedStringDeduplication.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/util/HostedStringDeduplication.java @@ -29,13 +29,12 @@ import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import org.graalvm.compiler.core.common.SuppressFBWarnings; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.jdk.StringInternSupport; /** @@ -43,6 +42,7 @@ * {@link String#intern} has negative side effects on the image size because all interned strings * must be maintained in an array in the image heap, see {@link StringInternSupport}. */ +@AutomaticallyRegisteredImageSingleton @Platforms(Platform.HOSTED_ONLY.class) public class HostedStringDeduplication { @@ -117,11 +117,3 @@ public static boolean isInternedString(String str) { return new String(str).intern() == str; } } - -@AutomaticFeature -class HostedStringDeduplicationFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(HostedStringDeduplication.class, new HostedStringDeduplication()); - } -} diff --git a/substratevm/src/com.oracle.svm.driver/resources/META-INF/native-image/com.oracle.substratevm/svm-driver/native-image.properties b/substratevm/src/com.oracle.svm.driver/resources/META-INF/native-image/com.oracle.substratevm/svm-driver/native-image.properties index a597237df010..7b1cf8bd8f4a 100644 --- a/substratevm/src/com.oracle.svm.driver/resources/META-INF/native-image/com.oracle.substratevm/svm-driver/native-image.properties +++ b/substratevm/src/com.oracle.svm.driver/resources/META-INF/native-image/com.oracle.substratevm/svm-driver/native-image.properties @@ -1,4 +1,5 @@ -ImageName = native-image -Args = -H:-ParseRuntimeOptions \ +ImageName=native-image +Args=-H:-ParseRuntimeOptions \ + --features=com.oracle.svm.driver.APIOptionFeature \ --initialize-at-build-time=com.oracle.svm.driver \ --link-at-build-time=com.oracle.svm.driver,com.oracle.svm.driver.metainf \ No newline at end of file diff --git a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/APIOptionHandler.java b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/APIOptionHandler.java index ef90f08000fa..e006ef4e9943 100644 --- a/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/APIOptionHandler.java +++ b/substratevm/src/com.oracle.svm.driver/src/com/oracle/svm/driver/APIOptionHandler.java @@ -47,7 +47,6 @@ import org.graalvm.nativeimage.hosted.Feature; import com.oracle.svm.core.SubstrateUtil; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.option.APIOption; import com.oracle.svm.core.option.APIOption.APIOptionKind; import com.oracle.svm.core.option.APIOptionGroup; @@ -472,7 +471,6 @@ final class APIOptionSupport { } } -@AutomaticFeature final class APIOptionFeature implements Feature { @Override diff --git a/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalFeature.java b/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalFeature.java index 9f5f4f253451..c24cf1b3dfe0 100644 --- a/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalFeature.java +++ b/substratevm/src/com.oracle.svm.graal.hotspot.libgraal/src/com/oracle/svm/graal/hotspot/libgraal/LibGraalFeature.java @@ -50,6 +50,7 @@ import java.util.function.BooleanSupplier; import java.util.stream.Collectors; +import com.oracle.svm.core.feature.InternalFeature; import org.graalvm.collections.EconomicMap; import org.graalvm.compiler.code.DisassemblerProvider; import org.graalvm.compiler.core.GraalServiceThread; @@ -164,7 +165,7 @@ class LibGraalOptions { static final RuntimeOptionKey OnShutdownCallback = new RuntimeOptionKey<>(null); } -public class LibGraalFeature implements com.oracle.svm.core.graal.InternalFeature { +public class LibGraalFeature implements InternalFeature { private HotSpotReplacementsImpl hotSpotSubstrateReplacements; diff --git a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/RuntimeCPUFeatureRegion.java b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/RuntimeCPUFeatureRegion.java index 9cbdc25a5ea2..fcb961389d25 100644 --- a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/RuntimeCPUFeatureRegion.java +++ b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/RuntimeCPUFeatureRegion.java @@ -49,10 +49,10 @@ import org.graalvm.compiler.phases.util.Providers; import com.oracle.svm.core.ParsingReason; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.config.ConfigurationValues; import com.oracle.svm.core.cpufeature.RuntimeCPUFeatureCheck; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.graal.amd64.AMD64CPUFeatureRegionOp; import jdk.vm.ci.amd64.AMD64; @@ -60,7 +60,7 @@ import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.ResolvedJavaMethod; -@AutomaticFeature +@AutomaticallyRegisteredFeature class RuntimeCPUFeatureRegionFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/hosted/DeoptimizationFeature.java b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/hosted/DeoptimizationFeature.java index 051f203db07a..1acae734ac6d 100644 --- a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/hosted/DeoptimizationFeature.java +++ b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/hosted/DeoptimizationFeature.java @@ -41,7 +41,7 @@ import com.oracle.svm.core.deopt.DeoptimizationSupport; import com.oracle.svm.core.deopt.DeoptimizedFrame; import com.oracle.svm.core.deopt.Deoptimizer; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.meta.RuntimeConfiguration; import com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider; import com.oracle.svm.core.graal.snippets.DeoptTestSnippets; diff --git a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/DisableSnippetCountersFeature.java b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/DisableSnippetCountersFeature.java index 389e0cc9507d..e754d85460b9 100644 --- a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/DisableSnippetCountersFeature.java +++ b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/DisableSnippetCountersFeature.java @@ -36,9 +36,9 @@ import com.oracle.svm.core.ParsingReason; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.meta.SubstrateObjectConstant; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import jdk.vm.ci.meta.JavaConstant; import jdk.vm.ci.meta.JavaKind; @@ -73,7 +73,7 @@ public boolean handleLoadField(GraphBuilderContext b, ValueNode object, Resolved * Disables snippet counters because they need a {@link SnippetReflectionProvider} which is not * fully supported for cross-isolate compilations. */ -@AutomaticFeature +@AutomaticallyRegisteredFeature final class DisableSnippetCountersFeature implements InternalFeature { @Override public boolean isInConfiguration(IsInConfigurationAccess access) { diff --git a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/IsolateAwareObjectConstantEqualityFeature.java b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/IsolateAwareObjectConstantEqualityFeature.java index 5dde95703754..bc628e674ace 100644 --- a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/IsolateAwareObjectConstantEqualityFeature.java +++ b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/isolated/IsolateAwareObjectConstantEqualityFeature.java @@ -26,13 +26,13 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.c.function.CEntryPoint; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.meta.DirectSubstrateObjectConstant; import com.oracle.svm.core.meta.ObjectConstantEquality; import com.oracle.svm.core.meta.SubstrateObjectConstant; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; import jdk.vm.ci.meta.Constant; @@ -75,8 +75,8 @@ private static boolean isolatedHandleTargetEqualImageObject(@SuppressWarnings("u } } -@AutomaticFeature -final class IsolateAwareObjectConstantEqualityFeature implements Feature { +@AutomaticallyRegisteredFeature +final class IsolateAwareObjectConstantEqualityFeature implements InternalFeature { @Override public boolean isInConfiguration(IsInConfigurationAccess access) { return SubstrateOptions.supportCompileInIsolates(); diff --git a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/meta/aarch64/AArch64RuntimeCodeInstallerPlatformHelper.java b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/meta/aarch64/AArch64RuntimeCodeInstallerPlatformHelper.java index adf637ad5118..1d32422aaef0 100644 --- a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/meta/aarch64/AArch64RuntimeCodeInstallerPlatformHelper.java +++ b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/meta/aarch64/AArch64RuntimeCodeInstallerPlatformHelper.java @@ -25,37 +25,28 @@ */ package com.oracle.svm.graal.meta.aarch64; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.svm.core.CodeSynchronizationOperations; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.code.AbstractRuntimeCodeInstaller.RuntimeCodeInstallerPlatformHelper; import com.oracle.svm.core.code.CodeInfo; import com.oracle.svm.core.code.CodeInfoAccess; import com.oracle.svm.core.code.RuntimeCodeCache; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.option.RuntimeOptionKey; import com.oracle.svm.core.thread.VMThreads; import com.oracle.svm.core.util.UserError; -@AutomaticFeature +@AutomaticallyRegisteredImageSingleton(RuntimeCodeInstallerPlatformHelper.class) @Platforms(Platform.AARCH64.class) -class AArch64RuntimeCodeInstallerPlatformHelperFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(RuntimeCodeInstallerPlatformHelper.class, new AArch64RuntimeCodeInstallerPlatformHelper()); - } - - @Override - public void duringSetup(DuringSetupAccess access) { +public class AArch64RuntimeCodeInstallerPlatformHelper implements RuntimeCodeInstallerPlatformHelper { + AArch64RuntimeCodeInstallerPlatformHelper() { RuntimeOptionKey writeableCodeOption = RuntimeCodeCache.Options.WriteableCodeCache; - UserError.guarantee(!writeableCodeOption.getValue(), "Enabling " + writeableCodeOption.getName() + " is not supported on this platform."); + if (writeableCodeOption.getValue()) { + throw UserError.abort("Enabling %s is not supported on this platform.", writeableCodeOption.getName()); + } } -} - -public class AArch64RuntimeCodeInstallerPlatformHelper implements RuntimeCodeInstallerPlatformHelper { @Override public void performCodeSynchronization(CodeInfo codeInfo) { diff --git a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/meta/amd64/AMD64RuntimeCodeInstallerPlatformHelper.java b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/meta/amd64/AMD64RuntimeCodeInstallerPlatformHelper.java index c8eb2d85634f..42a4f65e3fb4 100644 --- a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/meta/amd64/AMD64RuntimeCodeInstallerPlatformHelper.java +++ b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/meta/amd64/AMD64RuntimeCodeInstallerPlatformHelper.java @@ -24,24 +24,15 @@ */ package com.oracle.svm.graal.meta.amd64; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.code.AbstractRuntimeCodeInstaller.RuntimeCodeInstallerPlatformHelper; import com.oracle.svm.core.code.CodeInfo; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; -@AutomaticFeature +@AutomaticallyRegisteredImageSingleton(RuntimeCodeInstallerPlatformHelper.class) @Platforms(Platform.AMD64.class) -class AMD64RuntimeCodeInstallerPlatformHelperFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(RuntimeCodeInstallerPlatformHelper.class, new AMD64RuntimeCodeInstallerPlatformHelper()); - } -} - public class AMD64RuntimeCodeInstallerPlatformHelper implements RuntimeCodeInstallerPlatformHelper { @Override diff --git a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/stubs/AArch64StubForeignCallsFeature.java b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/stubs/AArch64StubForeignCallsFeature.java index ee90631c3969..4bd9114f00a2 100644 --- a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/stubs/AArch64StubForeignCallsFeature.java +++ b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/stubs/AArch64StubForeignCallsFeature.java @@ -33,9 +33,9 @@ import org.graalvm.nativeimage.Platform.AARCH64; import org.graalvm.nativeimage.Platforms; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; -@AutomaticFeature +@AutomaticallyRegisteredFeature @Platforms(AARCH64.class) public class AArch64StubForeignCallsFeature extends StubForeignCallsFeatureBase { diff --git a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/stubs/AMD64StubForeignCallsFeature.java b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/stubs/AMD64StubForeignCallsFeature.java index 23e65eb5b7b7..396ef37f49aa 100644 --- a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/stubs/AMD64StubForeignCallsFeature.java +++ b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/stubs/AMD64StubForeignCallsFeature.java @@ -46,11 +46,11 @@ import org.graalvm.nativeimage.Platform.AMD64; import org.graalvm.nativeimage.Platforms; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import jdk.vm.ci.amd64.AMD64.CPUFeature; -@AutomaticFeature +@AutomaticallyRegisteredFeature @Platforms(AMD64.class) public class AMD64StubForeignCallsFeature extends StubForeignCallsFeatureBase { diff --git a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/stubs/StubForeignCallsFeatureBase.java b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/stubs/StubForeignCallsFeatureBase.java index 30c7cae07f37..31b144ea4132 100644 --- a/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/stubs/StubForeignCallsFeatureBase.java +++ b/substratevm/src/com.oracle.svm.graal/src/com/oracle/svm/graal/stubs/StubForeignCallsFeatureBase.java @@ -39,7 +39,7 @@ import com.oracle.svm.core.SubstrateTargetDescription; import com.oracle.svm.core.cpufeature.Stubs; import com.oracle.svm.core.deopt.DeoptimizationSupport; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider; import com.oracle.svm.core.snippets.SnippetRuntime; import com.oracle.svm.hosted.FeatureImpl; diff --git a/substratevm/src/com.oracle.svm.hosted.jdk17/src/com/oracle/svm/hosted/jdk17/JNIRegistrationSupport_JDK17OrLater.java b/substratevm/src/com.oracle.svm.hosted.jdk17/src/com/oracle/svm/hosted/jdk17/JNIRegistrationSupport_JDK17OrLater.java index 8e1a673a0e63..c2c09df37063 100644 --- a/substratevm/src/com.oracle.svm.hosted.jdk17/src/com/oracle/svm/hosted/jdk17/JNIRegistrationSupport_JDK17OrLater.java +++ b/substratevm/src/com.oracle.svm.hosted.jdk17/src/com/oracle/svm/hosted/jdk17/JNIRegistrationSupport_JDK17OrLater.java @@ -31,8 +31,8 @@ import org.graalvm.nativeimage.impl.InternalPlatform; import com.oracle.svm.core.ParsingReason; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.jdk.JNIRegistrationSupport; import jdk.internal.loader.BootLoader; @@ -42,7 +42,7 @@ * jdk.internal.loader.BootLoader */ @Platforms(InternalPlatform.PLATFORM_JNI.class) -@AutomaticFeature +@AutomaticallyRegisteredFeature final class JNIRegistrationSupport_JDK17OrLater implements InternalFeature { @Override public boolean isInConfiguration(IsInConfigurationAccess access) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/AArch64CPUFeatureAccessFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/AArch64CPUFeatureAccessFeature.java index 022cb0e25b6e..362666a3c9ef 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/AArch64CPUFeatureAccessFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/AArch64CPUFeatureAccessFeature.java @@ -29,18 +29,18 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.svm.core.SubstrateTargetDescription; import com.oracle.svm.core.aarch64.AArch64CPUFeatureAccess; import com.oracle.svm.core.aarch64.AArch64LibCHelper; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import jdk.vm.ci.aarch64.AArch64; -@AutomaticFeature +@AutomaticallyRegisteredFeature @Platforms(Platform.AARCH64.class) -class AArch64CPUFeatureAccessFeature extends CPUFeatureAccessFeatureBase implements Feature { +class AArch64CPUFeatureAccessFeature extends CPUFeatureAccessFeatureBase implements InternalFeature { @Override public void beforeAnalysis(BeforeAnalysisAccess arg) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/AMD64CPUFeatureAccessFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/AMD64CPUFeatureAccessFeature.java index 58bcbc01bee1..844e966a0343 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/AMD64CPUFeatureAccessFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/AMD64CPUFeatureAccessFeature.java @@ -29,18 +29,18 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.svm.core.SubstrateTargetDescription; import com.oracle.svm.core.amd64.AMD64CPUFeatureAccess; import com.oracle.svm.core.amd64.AMD64LibCHelper; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import jdk.vm.ci.amd64.AMD64; -@AutomaticFeature +@AutomaticallyRegisteredFeature @Platforms(Platform.AMD64.class) -public class AMD64CPUFeatureAccessFeature extends CPUFeatureAccessFeatureBase implements Feature { +public class AMD64CPUFeatureAccessFeature extends CPUFeatureAccessFeatureBase implements InternalFeature { @Override public void beforeAnalysis(BeforeAnalysisAccess arg) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ClassLoaderFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ClassLoaderFeature.java index f733d1cf358c..2bf320c4e495 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ClassLoaderFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ClassLoaderFeature.java @@ -24,12 +24,11 @@ */ package com.oracle.svm.hosted; -import org.graalvm.nativeimage.hosted.Feature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; -import com.oracle.svm.core.annotate.AutomaticFeature; - -@AutomaticFeature -public class ClassLoaderFeature implements Feature { +@AutomaticallyRegisteredFeature +public class ClassLoaderFeature implements InternalFeature { private static final NativeImageSystemClassLoader nativeImageSystemClassLoader = NativeImageSystemClassLoader.singleton(); 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 286f3b9fd7a0..dd0ef329c7e7 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 @@ -24,13 +24,12 @@ */ package com.oracle.svm.hosted; -import org.graalvm.nativeimage.hosted.Feature; - -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl; -@AutomaticFeature -public class ClassNewInstanceFeature implements Feature { +@AutomaticallyRegisteredFeature +public class ClassNewInstanceFeature implements InternalFeature { @Override public void beforeAnalysis(BeforeAnalysisAccess 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 d858dcef6880..78a76133518a 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 @@ -35,15 +35,15 @@ import java.util.stream.Collectors; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.hosted.RuntimeClassInitialization; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.configure.ConfigurationFile; import com.oracle.svm.core.configure.ConfigurationFiles; import com.oracle.svm.core.configure.PredefinedClassesConfigurationParser; import com.oracle.svm.core.configure.PredefinedClassesRegistry; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.hub.PredefinedClassesSupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.UserError; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl.AfterRegistrationAccessImpl; @@ -52,8 +52,8 @@ import jdk.internal.org.objectweb.asm.ClassReader; import jdk.internal.org.objectweb.asm.ClassWriter; -@AutomaticFeature -public class ClassPredefinitionFeature implements Feature { +@AutomaticallyRegisteredFeature +public class ClassPredefinitionFeature implements InternalFeature { private final Map nameToRecord = new HashMap<>(); private boolean sealed = false; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ClassValueFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ClassValueFeature.java index 15ddea32649a..5ae80d3ba0fc 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ClassValueFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ClassValueFeature.java @@ -29,15 +29,15 @@ import java.util.concurrent.ConcurrentHashMap; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.graal.pointsto.meta.AnalysisType; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.JavaLangSubstitutions.ClassValueSupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.util.ReflectionUtil; -@AutomaticFeature -public final class ClassValueFeature implements Feature { +@AutomaticallyRegisteredFeature +public final class ClassValueFeature implements InternalFeature { private final Map, Map, Object>> values = new ConcurrentHashMap<>(); @Override diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ConcurrentReachabilityHandler.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ConcurrentReachabilityHandler.java index 1183d832c09a..546df85adcce 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ConcurrentReachabilityHandler.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ConcurrentReachabilityHandler.java @@ -32,7 +32,6 @@ import java.util.function.Consumer; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.graal.pointsto.meta.AnalysisElement; import com.oracle.graal.pointsto.meta.AnalysisElement.ElementNotification; @@ -42,12 +41,13 @@ import com.oracle.graal.pointsto.meta.AnalysisMethod; import com.oracle.graal.pointsto.meta.AnalysisType; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.UserError; import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl; -@AutomaticFeature -public class ConcurrentReachabilityHandler implements ReachabilityHandler, Feature { +@AutomaticallyRegisteredFeature +public class ConcurrentReachabilityHandler implements ReachabilityHandler, InternalFeature { private final Map, ElementNotification> reachabilityNotifications = new ConcurrentHashMap<>(); 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 4ad048da5bd3..5c6f16cdfd19 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 @@ -39,13 +39,12 @@ import java.util.Set; import java.util.stream.Collectors; -import org.graalvm.nativeimage.hosted.Feature; - import com.oracle.graal.pointsto.meta.AnalysisMetaAccess; import com.oracle.graal.pointsto.meta.AnalysisMethod; import com.oracle.svm.core.FallbackExecutor; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.UserError; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl.AfterAnalysisAccessImpl; @@ -54,8 +53,8 @@ import jdk.vm.ci.code.BytecodePosition; import jdk.vm.ci.meta.ResolvedJavaMethod; -@AutomaticFeature -public class FallbackFeature implements Feature { +@AutomaticallyRegisteredFeature +public class FallbackFeature implements InternalFeature { private static final String ABORT_MSG_PREFIX = "Aborting stand-alone image build"; private final List reflectionInvocationChecks = new ArrayList<>(); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/FeatureHandler.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/FeatureHandler.java index b74fd8c8ebe1..b20910f6a054 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/FeatureHandler.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/FeatureHandler.java @@ -30,6 +30,7 @@ import java.util.LinkedHashSet; import java.util.List; import java.util.Map; +import java.util.ServiceLoader; import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.Collectors; @@ -43,11 +44,14 @@ import com.oracle.svm.core.ClassLoaderSupport; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeatureServiceRegistration; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.option.APIOption; import com.oracle.svm.core.option.HostedOptionKey; import com.oracle.svm.core.option.LocatableMultiOptionValue; import com.oracle.svm.core.option.OptionUtils; +import com.oracle.svm.core.option.SubstrateOptionsParser; import com.oracle.svm.core.util.UserError; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl.IsInConfigurationAccessImpl; @@ -68,6 +72,9 @@ public static class Options { private static List userEnabledFeatures() { return OptionUtils.flatten(",", Options.Features.getValue()); } + + @Option(help = "Allow using deprecated @AutomaticFeature annotation. If set to false, an error is shown instead of a warning.")// + public static final HostedOptionKey AllowDeprecatedAutomaticFeature = new HostedOptionKey<>(true); } private final ArrayList featureInstances = new ArrayList<>(); @@ -91,7 +98,39 @@ public void forEachGraalFeature(Consumer consumer) { public void registerFeatures(ImageClassLoader loader, DebugContext debug) { IsInConfigurationAccessImpl access = new IsInConfigurationAccessImpl(this, loader, debug); - LinkedHashSet> automaticFeatures = new LinkedHashSet<>(loader.findAnnotatedClasses(AutomaticFeature.class, true)); + LinkedHashSet> automaticFeatures = new LinkedHashSet<>(); + NativeImageSystemClassLoader nativeImageSystemClassLoader = NativeImageSystemClassLoader.singleton(); + for (var serviceRegistration : ServiceLoader.load(AutomaticallyRegisteredFeatureServiceRegistration.class, nativeImageSystemClassLoader.defaultSystemClassLoader)) { + Class annotatedFeatureClass = loader.findClass(serviceRegistration.getClassName()).getOrFail(); + /* + * For simplicity, we do not look at the Platforms annotation ourselves and instead + * check if the ImageClassLoader found that class too. + */ + if (loader.findSubclasses(annotatedFeatureClass, true).contains(annotatedFeatureClass)) { + automaticFeatures.add(annotatedFeatureClass); + } + } + for (Class annotatedFeatureClass : loader.findAnnotatedClasses(AutomaticallyRegisteredFeature.class, true)) { + if (!automaticFeatures.contains(annotatedFeatureClass)) { + throw UserError.abort("Feature " + annotatedFeatureClass + " annotated with @" + AutomaticallyRegisteredFeature.class.getSimpleName() + " was not properly registered as a service. " + + "Either the annotation processor did not run for the project containing the feature, or the class is not on the class path of the image generator. " + + "The annotation is only for internal usage. Applications should register a feature using the option " + + SubstrateOptionsParser.commandArgument(Options.Features, annotatedFeatureClass.getName())); + } + } + + for (var annotatedFeatureClass : loader.findAnnotatedClasses(AutomaticFeature.class, true)) { + String msg = "Feature " + annotatedFeatureClass + " is annotated with the deprecated annotation @" + AutomaticFeature.class.getSimpleName() + ". " + + "Support for this annotation will be removed in a future version of GraalVM. " + + "Applications should register a feature using the option " + SubstrateOptionsParser.commandArgument(Options.Features, annotatedFeatureClass.getName()); + if (Options.AllowDeprecatedAutomaticFeature.getValue()) { + System.out.println("Warning: " + msg); + } else { + throw UserError.abort(msg); + } + automaticFeatures.add(annotatedFeatureClass); + } + Map, Class> specificAutomaticFeatures = new HashMap<>(); for (Class automaticFeature : automaticFeatures) { @@ -106,7 +145,7 @@ public void registerFeatures(ImageClassLoader loader, DebugContext debug) { } else { if (featureSubclasses.size() > 1) { String candidates = featureSubclasses.stream().map(Class::getName).collect(Collectors.joining(" ")); - VMError.shouldNotReachHere("Ambiguous @AutomaticFeature extension. Conflicting candidates: " + candidates); + VMError.shouldNotReachHere("Ambiguous @AutomaticallyRegisteredFeature / @AutomaticFeature extension. Conflicting candidates: " + candidates); } mostSpecific = (Class) featureSubclasses.get(0); } 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 cda6f1dd6c72..53e5fcc9e25f 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 @@ -24,27 +24,26 @@ */ package com.oracle.svm.hosted; -import java.io.InputStream; import java.io.IOException; +import java.io.InputStream; import java.lang.reflect.Method; import java.net.URISyntaxException; import java.net.URL; -import java.nio.file.Files; import java.nio.file.FileSystem; import java.nio.file.FileSystems; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.security.CodeSource; +import java.security.ProtectionDomain; import java.util.HashSet; -import java.util.Set; import java.util.Optional; import java.util.Properties; +import java.util.Set; import java.util.stream.Stream; -import java.security.CodeSource; -import java.security.ProtectionDomain; - -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; /** * A feature that detects whether a native image may be vulnerable to Log4Shell. @@ -53,8 +52,8 @@ * If a vulnerable version is detected, the feature will then check whether any vulnerable methods * are reachable. */ -@AutomaticFeature -public class Log4ShellFeature implements Feature { +@AutomaticallyRegisteredFeature +public class Log4ShellFeature implements InternalFeature { private static final String log4jClassName = "org.apache.logging.log4j.Logger"; private static final String log4jVulnerableErrorMessage = "Warning: A vulnerable version of log4j has been detected. Please update to log4j version 2.17.1 or later.%nVulnerable Method(s):"; private static final String log4jUnknownVersion = "Warning: The log4j library has been detected, but the version is unavailable. Due to Log4Shell, please ensure log4j is at version 2.17.1 or later."; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/LoggingFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/LoggingFeature.java index cb47747277c0..0386d4aef530 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/LoggingFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/LoggingFeature.java @@ -29,17 +29,17 @@ import org.graalvm.compiler.options.Option; import org.graalvm.compiler.options.OptionType; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.hosted.RuntimeReflection; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.option.HostedOptionKey; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl; import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl; -@AutomaticFeature -public class LoggingFeature implements Feature { +@AutomaticallyRegisteredFeature +public class LoggingFeature implements InternalFeature { public static class Options { @Option(help = "Enable the feature that provides support for logging.")// diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ModuleLayerFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ModuleLayerFeature.java index ad78c7e234ca..3f82d61e4607 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ModuleLayerFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ModuleLayerFeature.java @@ -51,14 +51,12 @@ import java.util.stream.Stream; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.Platform; -import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.graal.pointsto.meta.AnalysisUniverse; import com.oracle.svm.core.SubstrateUtil; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.BootModuleLayerSupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; import com.oracle.svm.util.ModuleSupport; import com.oracle.svm.util.ReflectionUtil; @@ -94,9 +92,8 @@ * but that cannot be known in advance). *

*/ -@AutomaticFeature -@Platforms(Platform.HOSTED_ONLY.class) -public final class ModuleLayerFeature implements Feature { +@AutomaticallyRegisteredFeature +public final class ModuleLayerFeature implements InternalFeature { private Constructor moduleLayerConstructor; private Field moduleLayerNameToModuleField; private Field moduleLayerParentsField; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeSecureRandomFilesCloser.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeSecureRandomFilesCloser.java index 1ab5928dda88..ca641eec8956 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeSecureRandomFilesCloser.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/NativeSecureRandomFilesCloser.java @@ -28,11 +28,11 @@ import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.svm.core.PosixSunSecuritySubstitutions; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.RuntimeSupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl; /** @@ -44,9 +44,9 @@ * As of Java 11, there is only a dummy implementation of {@code NativePRNG} on Windows which does * not open file descriptors that would need to be closed. */ -@AutomaticFeature +@AutomaticallyRegisteredFeature @Platforms({Platform.LINUX.class, Platform.DARWIN.class}) -public class NativeSecureRandomFilesCloser implements Feature { +public class NativeSecureRandomFilesCloser implements InternalFeature { @Override public void beforeAnalysis(BeforeAnalysisAccess access) { access.registerReachabilityHandler(this::registerShutdownHook, sun.security.provider.NativePRNG.class); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporter.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporter.java index a851bb4fe2cd..58e40b9df34c 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporter.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProgressReporter.java @@ -73,13 +73,14 @@ import com.oracle.svm.core.OS; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.VM; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.code.CodeInfoTable; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.heap.Heap; import com.oracle.svm.core.jdk.Resources; import com.oracle.svm.core.jdk.resources.ResourceStorageEntry; import com.oracle.svm.core.option.HostedOptionValues; import com.oracle.svm.core.reflect.ReflectionMetadataDecoder; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.ProgressReporterJsonHelper.AnalysisResults; import com.oracle.svm.hosted.ProgressReporterJsonHelper.GeneralInfo; @@ -860,16 +861,6 @@ private static GCStats getCurrent() { } } - @AutomaticFeature - public static class ProgressReporterFeature implements Feature { - private final ProgressReporter reporter = ProgressReporter.singleton(); - - @Override - public void duringAnalysis(DuringAnalysisAccess access) { - reporter.reportStageProgress(); - } - } - public abstract static class ReporterClosable implements AutoCloseable { @Override public void close() { @@ -1408,3 +1399,13 @@ private static class ANSI { static final String MAGENTA_BOLD = ESCAPE + "[1;35m"; } } + +@AutomaticallyRegisteredFeature +class ProgressReporterFeature implements InternalFeature { + private final ProgressReporter reporter = ProgressReporter.singleton(); + + @Override + public void duringAnalysis(DuringAnalysisAccess access) { + reporter.reportStageProgress(); + } +} diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProtectionDomainFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProtectionDomainFeature.java index 6c319001779e..c65d1b765c4c 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProtectionDomainFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ProtectionDomainFeature.java @@ -30,16 +30,16 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.ProtectionDomainSupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl; import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl; import com.oracle.svm.util.ReflectionUtil; -@AutomaticFeature -final class ProtectionDomainFeature implements Feature { +@AutomaticallyRegisteredFeature +final class ProtectionDomainFeature implements InternalFeature { private Field executableURLSupplierField; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ReachabilityHandlerFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ReachabilityHandlerFeature.java index c9f2ae885af5..a1e8c65b810f 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ReachabilityHandlerFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ReachabilityHandlerFeature.java @@ -36,21 +36,21 @@ import java.util.function.Consumer; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.graal.pointsto.meta.AnalysisField; import com.oracle.graal.pointsto.meta.AnalysisMetaAccess; import com.oracle.graal.pointsto.meta.AnalysisMethod; import com.oracle.graal.pointsto.meta.AnalysisType; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.UserError; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl; import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl; -@AutomaticFeature -public class ReachabilityHandlerFeature implements Feature, ReachabilityHandler { +@AutomaticallyRegisteredFeature +public class ReachabilityHandlerFeature implements InternalFeature, ReachabilityHandler { private final IdentityHashMap> activeHandlers = new IdentityHashMap<>(); private final IdentityHashMap>> triggeredHandlers = new IdentityHashMap<>(); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ResourcesFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ResourcesFeature.java index a86289998875..f9fb8dda78e8 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ResourcesFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ResourcesFeature.java @@ -42,18 +42,17 @@ import org.graalvm.compiler.options.Option; import org.graalvm.compiler.options.OptionType; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.ConfigurationCondition; import org.graalvm.nativeimage.impl.RuntimeResourceSupport; import com.oracle.svm.core.ClassLoaderSupport; import com.oracle.svm.core.ClassLoaderSupport.ResourceCollector; import com.oracle.svm.core.SubstrateUtil; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.configure.ConfigurationFile; import com.oracle.svm.core.configure.ConfigurationFiles; import com.oracle.svm.core.configure.ResourceConfigurationParser; import com.oracle.svm.core.configure.ResourcesRegistry; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.Resources; import com.oracle.svm.core.jdk.resources.NativeImageResourceFileAttributes; import com.oracle.svm.core.jdk.resources.NativeImageResourceFileAttributesView; @@ -61,6 +60,7 @@ import com.oracle.svm.core.jdk.resources.NativeImageResourceFileSystemProvider; import com.oracle.svm.core.option.HostedOptionKey; import com.oracle.svm.core.option.LocatableMultiOptionValue; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.UserError; import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl; import com.oracle.svm.hosted.config.ConfigurationParserUtils; @@ -94,8 +94,8 @@ * @see NativeImageResourceFileAttributes * @see NativeImageResourceFileAttributesView */ -@AutomaticFeature -public final class ResourcesFeature implements Feature { +@AutomaticallyRegisteredFeature +public final class ResourcesFeature implements InternalFeature { static final String MODULE_NAME_ALL_UNNAMED = "ALL-UNNAMED"; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SecurityServicesFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SecurityServicesFeature.java index aa832ba569ec..c4312bf066b2 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SecurityServicesFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SecurityServicesFeature.java @@ -87,7 +87,6 @@ import org.graalvm.compiler.options.Option; import org.graalvm.compiler.serviceprovider.JavaVersionUtil; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.hosted.RuntimeJNIAccess; import org.graalvm.nativeimage.hosted.RuntimeReflection; import org.graalvm.nativeimage.impl.RuntimeClassInitializationSupport; @@ -96,7 +95,8 @@ import com.oracle.graal.pointsto.reports.ReportUtils; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.TypeResult; -import com.oracle.svm.core.annotate.AutomaticFeature; +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.jdk.NativeLibrarySupport; import com.oracle.svm.core.jdk.PlatformNativeLibrarySupport; @@ -116,8 +116,8 @@ import sun.security.provider.NativePRNG; import sun.security.x509.OIDMap; -@AutomaticFeature -public class SecurityServicesFeature extends JNIRegistrationUtil implements Feature, SecurityProvidersFilter { +@AutomaticallyRegisteredFeature +public class SecurityServicesFeature extends JNIRegistrationUtil implements InternalFeature, SecurityProvidersFilter { public static class Options { @Option(help = "Enable automatic registration of security services.")// diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ServiceLoaderFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ServiceLoaderFeature.java index eae3fc72bba7..0fd1e90f8659 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ServiceLoaderFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/ServiceLoaderFeature.java @@ -47,17 +47,17 @@ import org.graalvm.compiler.debug.DebugContext; import org.graalvm.compiler.options.Option; import org.graalvm.compiler.options.OptionType; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.hosted.RuntimeReflection; import com.oracle.graal.pointsto.constraints.UnsupportedFeatureException; import com.oracle.graal.pointsto.meta.AnalysisType; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.Resources; import com.oracle.svm.core.option.HostedOptionKey; import com.oracle.svm.core.option.LocatableMultiOptionValue; import com.oracle.svm.core.option.OptionUtils; import com.oracle.svm.core.option.SubstrateOptionsParser; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.UserError; import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl; import com.oracle.svm.hosted.analysis.Inflation; @@ -94,8 +94,8 @@ * not be possible for us to deliver services in the exact same order with "flat" single loader * approach. */ -@AutomaticFeature -public class ServiceLoaderFeature implements Feature { +@AutomaticallyRegisteredFeature +public class ServiceLoaderFeature implements InternalFeature { public static class Options { @Option(help = "Automatically register services for run-time lookup using ServiceLoader", type = OptionType.Expert) // diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SubstitutionReportFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SubstitutionReportFeature.java index f8c24dc87c11..e50bd780f9f7 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SubstitutionReportFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SubstitutionReportFeature.java @@ -31,7 +31,6 @@ import java.util.function.Function; import org.graalvm.compiler.options.Option; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.graal.pointsto.infrastructure.OriginalClassProvider; import com.oracle.graal.pointsto.meta.AnalysisField; @@ -40,8 +39,9 @@ import com.oracle.graal.pointsto.reports.ReportUtils; import com.oracle.graal.pointsto.util.GraalAccess; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.option.HostedOptionKey; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.substitute.SubstitutionField; import com.oracle.svm.hosted.substitute.SubstitutionMethod; import com.oracle.svm.hosted.substitute.SubstitutionType; @@ -50,8 +50,8 @@ import jdk.vm.ci.meta.ResolvedJavaMethod; import jdk.vm.ci.meta.ResolvedJavaType; -@AutomaticFeature -public class SubstitutionReportFeature implements Feature { +@AutomaticallyRegisteredFeature +public class SubstitutionReportFeature implements InternalFeature { static class Options { @Option(help = "Report performed substitutions")// diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SubstrateDiagnosticFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SubstrateDiagnosticFeature.java index 95a1a89f5085..d7d5bb95a8fa 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SubstrateDiagnosticFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SubstrateDiagnosticFeature.java @@ -26,20 +26,21 @@ import java.lang.reflect.Field; -import com.oracle.svm.core.SubstrateDiagnostics; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.hosted.Feature; import com.oracle.graal.pointsto.meta.AnalysisField; +import com.oracle.svm.core.SubstrateDiagnostics; import com.oracle.svm.core.SubstrateDiagnostics.DiagnosticThunkRegistry; import com.oracle.svm.core.SubstrateDiagnostics.FatalErrorState; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl; -@AutomaticFeature -class SubstrateDiagnosticFeature implements Feature { +@AutomaticallyRegisteredFeature +class SubstrateDiagnosticFeature implements InternalFeature { @Override public void duringSetup(DuringSetupAccess access) { ImageSingletons.add(FatalErrorState.class, new FatalErrorState()); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SystemInOutErrFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SystemInOutErrFeature.java index ee2fc6ad5950..0127c6623ca6 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SystemInOutErrFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SystemInOutErrFeature.java @@ -31,9 +31,10 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.annotate.RecomputeFieldValue; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.SystemInOutErrSupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; /** * We use an {@link Feature.DuringSetupAccess#registerObjectReplacer object replacer} because the @@ -41,8 +42,8 @@ * {@link System}. We do not know all these places, so we do now know where to place * {@link RecomputeFieldValue} annotations. */ -@AutomaticFeature -public class SystemInOutErrFeature implements Feature { +@AutomaticallyRegisteredFeature +public class SystemInOutErrFeature implements InternalFeature { private final InputStream hostedIn; private final PrintStream hostedOut; private final PrintStream hostedErr; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/VMFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/VMFeature.java index 0b162205c7ee..ea76ccd53d14 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/VMFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/VMFeature.java @@ -29,23 +29,23 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.PointerBase; import org.graalvm.word.WordFactory; import com.oracle.graal.pointsto.reports.ReportUtils; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.VM; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.c.CGlobalData; import com.oracle.svm.core.c.CGlobalDataFactory; import com.oracle.svm.core.c.libc.LibCBase; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.c.CGlobalDataFeature; import com.oracle.svm.hosted.c.NativeLibraries; import com.oracle.svm.hosted.c.codegen.CCompilerInvoker; -@AutomaticFeature -public class VMFeature implements Feature { +@AutomaticallyRegisteredFeature +public class VMFeature implements InternalFeature { private NativeLibraries nativeLibraries; private static final String STATIC_BINARY_MARKER_SYMBOL_NAME = "__svm_vm_is_static_binary"; 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 f15233ae6225..0f3b5d96a8b5 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 @@ -24,16 +24,15 @@ */ package com.oracle.svm.hosted.ameta; -import org.graalvm.nativeimage.hosted.Feature; - import com.oracle.graal.pointsto.meta.AnalysisMetaAccess; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.hub.DynamicHub; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl; import com.oracle.svm.hosted.SVMHost; -@AutomaticFeature -public class HostedDynamicHubFeature implements Feature { +@AutomaticallyRegisteredFeature +public class HostedDynamicHubFeature implements InternalFeature { private AnalysisMetaAccess metaAccess; private SVMHost hostVM; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/annotation/AnnotationSupport.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/annotation/AnnotationSupport.java index 957db293011a..1968b516e84b 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/annotation/AnnotationSupport.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/annotation/AnnotationSupport.java @@ -60,17 +60,17 @@ import org.graalvm.compiler.nodes.java.LoadFieldNode; import org.graalvm.compiler.replacements.nodes.MacroNode.MacroParams; import org.graalvm.compiler.serviceprovider.JavaVersionUtil; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.graal.pointsto.constraints.UnsupportedFeatureException; import com.oracle.graal.pointsto.infrastructure.OriginalClassProvider; import com.oracle.graal.pointsto.meta.HostedProviders; import com.oracle.graal.pointsto.util.GraalAccess; import com.oracle.svm.core.SubstrateAnnotationInvocationHandler; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.jdk.SubstrateObjectCloneWithExceptionNode; import com.oracle.svm.core.jdk.AnnotationSupportConfig; import com.oracle.svm.core.meta.SubstrateObjectConstant; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.analysis.NativeImagePointsToAnalysis; import com.oracle.svm.hosted.phases.HostedGraphKit; @@ -652,8 +652,8 @@ static boolean isAnnotationMarkerInterface(ResolvedJavaType type, MetaAccessProv } -@AutomaticFeature -class AnnotationSupportFeature implements Feature { +@AutomaticallyRegisteredFeature +class AnnotationSupportFeature implements InternalFeature { @Override public void duringSetup(DuringSetupAccess access) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/annotation/AnnotationTypeFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/annotation/AnnotationTypeFeature.java index 3ca17516116c..fb225b0dca07 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/annotation/AnnotationTypeFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/annotation/AnnotationTypeFeature.java @@ -24,15 +24,14 @@ */ package com.oracle.svm.hosted.annotation; -import org.graalvm.nativeimage.hosted.Feature; - import com.oracle.graal.pointsto.meta.AnalysisType; import com.oracle.graal.pointsto.meta.AnalysisUniverse; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl; -@AutomaticFeature -public class AnnotationTypeFeature implements Feature { +@AutomaticallyRegisteredFeature +public class AnnotationTypeFeature implements InternalFeature { @Override public void duringAnalysis(DuringAnalysisAccess access) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/CGlobalDataFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/CGlobalDataFeature.java index 93a5bf5c5bde..c8f3e17bdad5 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/CGlobalDataFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/CGlobalDataFeature.java @@ -71,15 +71,15 @@ import com.oracle.graal.pointsto.meta.AnalysisType; import com.oracle.svm.core.ParsingReason; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.c.CGlobalData; import com.oracle.svm.core.c.CGlobalDataImpl; import com.oracle.svm.core.c.CGlobalDataNonConstantRegistry; import com.oracle.svm.core.config.ConfigurationValues; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.code.CGlobalDataInfo; import com.oracle.svm.core.graal.nodes.CGlobalDataLoadAddressNode; import com.oracle.svm.core.meta.SubstrateObjectConstant; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.image.RelocatableBuffer; import com.oracle.svm.util.ReflectionUtil; @@ -88,7 +88,7 @@ import jdk.vm.ci.meta.ResolvedJavaMethod; import jdk.vm.ci.meta.ResolvedJavaType; -@AutomaticFeature +@AutomaticallyRegisteredFeature public class CGlobalDataFeature implements InternalFeature { private final Method getCGlobalDataInfoMethod = ReflectionUtil.lookupMethod(CGlobalDataNonConstantRegistry.class, "getCGlobalDataInfo", CGlobalDataImpl.class); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/function/CEntryPointSupport.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/function/CEntryPointSupport.java index 7b19bf0c9e42..646276448e0a 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/function/CEntryPointSupport.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/c/function/CEntryPointSupport.java @@ -46,11 +46,10 @@ import com.oracle.svm.core.FrameAccess; import com.oracle.svm.core.ParsingReason; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.c.function.CEntryPointActions; import com.oracle.svm.core.c.function.CEntryPointCreateIsolateParameters; import com.oracle.svm.core.c.function.CEntryPointSetup; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.nodes.CEntryPointEnterNode; import com.oracle.svm.core.graal.nodes.CEntryPointLeaveNode; import com.oracle.svm.core.graal.nodes.CEntryPointLeaveNode.LeaveAction; @@ -58,11 +57,12 @@ import com.oracle.svm.core.graal.nodes.CEntryPointUtilityNode.UtilityAction; import com.oracle.svm.core.graal.nodes.LoweredDeadEndNode; import com.oracle.svm.core.graal.nodes.ReadReservedRegister; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.ResolvedJavaMethod; -@AutomaticFeature +@AutomaticallyRegisteredFeature public class CEntryPointSupport implements InternalFeature { @Override public void registerInvocationPlugins(Providers providers, SnippetReflectionProvider snippetReflection, Plugins plugins, ParsingReason reason) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/classinitialization/ClassInitializationFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/classinitialization/ClassInitializationFeature.java index 76cd8fdda63e..0f49c396fa3e 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/classinitialization/ClassInitializationFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/classinitialization/ClassInitializationFeature.java @@ -49,20 +49,20 @@ import com.oracle.graal.pointsto.util.Timer; import com.oracle.graal.pointsto.util.TimerCollection; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.classinitialization.EnsureClassInitializedSnippets; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.meta.RuntimeConfiguration; import com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider; import com.oracle.svm.core.graal.snippets.NodeLoweringProvider; import com.oracle.svm.core.option.OptionOrigin; import com.oracle.svm.core.option.SubstrateOptionsParser; import com.oracle.svm.core.snippets.SnippetRuntime; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.UserError; import com.oracle.svm.hosted.FeatureImpl; import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl; -@AutomaticFeature +@AutomaticallyRegisteredFeature public class ClassInitializationFeature implements InternalFeature { private static final String NATIVE_IMAGE_CLASS_REASON = "Native Image classes are always initialized at build time"; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CEntryPointCallStubSupport.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CEntryPointCallStubSupport.java index 202bb768eb8e..5d42dc96d4ff 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CEntryPointCallStubSupport.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CEntryPointCallStubSupport.java @@ -31,15 +31,15 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.c.function.CFunctionPointer; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.graal.pointsto.BigBang; import com.oracle.graal.pointsto.meta.AnalysisMethod; import com.oracle.svm.core.SubstrateUtil; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.c.BoxedRelocatedPointer; import com.oracle.svm.core.code.IsolateLeaveStub; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.meta.MethodPointer; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl; import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl; import com.oracle.svm.hosted.c.NativeLibraries; @@ -134,8 +134,8 @@ public BoxedRelocatedPointer getBoxedRelocatedPointer(CFunctionPointer cFunction } } -@AutomaticFeature -class CEntryPointCallStubFeature implements Feature { +@AutomaticallyRegisteredFeature +class CEntryPointCallStubFeature implements InternalFeature { @Override public void duringSetup(DuringSetupAccess arg) { DuringSetupAccessImpl access = (DuringSetupAccessImpl) arg; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CEntryPointLiteralFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CEntryPointLiteralFeature.java index 108e4190480e..82157ab018d7 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CEntryPointLiteralFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CEntryPointLiteralFeature.java @@ -31,14 +31,14 @@ import org.graalvm.nativeimage.c.function.CEntryPoint; import org.graalvm.nativeimage.c.function.CEntryPointLiteral; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.CEntryPointLiteralCodePointer; import com.oracle.graal.pointsto.BigBang; import com.oracle.graal.pointsto.infrastructure.UniverseMetaAccess; import com.oracle.graal.pointsto.meta.AnalysisMethod; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.meta.MethodPointer; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.UserError; import com.oracle.svm.hosted.FeatureImpl.CompilationAccessImpl; import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl; @@ -46,8 +46,8 @@ import jdk.vm.ci.meta.ResolvedJavaMethod; -@AutomaticFeature -public class CEntryPointLiteralFeature implements Feature { +@AutomaticallyRegisteredFeature +public class CEntryPointLiteralFeature implements InternalFeature { class CEntryPointLiteralObjectReplacer implements Function { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CFunctionLinkages.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CFunctionLinkages.java index a91067e8325b..7072611b1cd2 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CFunctionLinkages.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CFunctionLinkages.java @@ -32,16 +32,16 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.c.function.CFunction; import org.graalvm.nativeimage.c.function.CFunctionPointer; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.c.CGlobalData; import com.oracle.svm.core.c.CGlobalDataFactory; import com.oracle.svm.core.graal.code.CGlobalDataInfo; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.hosted.c.CGlobalDataFeature; import jdk.vm.ci.meta.ResolvedJavaMethod; +@AutomaticallyRegisteredImageSingleton public final class CFunctionLinkages { public static CFunctionLinkages singleton() { return ImageSingletons.lookup(CFunctionLinkages.class); @@ -78,11 +78,3 @@ private static String getLinkageNameFromAnnotation(ResolvedJavaMethod method) { return null; } } - -@AutomaticFeature -class CFunctionLinkagesFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(CFunctionLinkages.class, new CFunctionLinkages()); - } -} diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CFunctionPointerCallStubSupport.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CFunctionPointerCallStubSupport.java index a8c0f28b110e..a2c6fa97f48e 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CFunctionPointerCallStubSupport.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CFunctionPointerCallStubSupport.java @@ -27,12 +27,12 @@ import java.util.Map; import java.util.concurrent.ConcurrentHashMap; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.ImageSingletons; import com.oracle.graal.pointsto.meta.AnalysisMethod; import com.oracle.graal.pointsto.meta.AnalysisUniverse; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl; public final class CFunctionPointerCallStubSupport { @@ -66,8 +66,8 @@ public AnalysisMethod getOrCreateStubForMethod(AnalysisMethod method) { } } -@AutomaticFeature -class CFunctionPointerCallStubSupportFeature implements Feature { +@AutomaticallyRegisteredFeature +class CFunctionPointerCallStubSupportFeature implements InternalFeature { @Override public void duringSetup(DuringSetupAccess arg) { DuringSetupAccessImpl access = (DuringSetupAccessImpl) arg; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CompilationInfoSupport.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CompilationInfoSupport.java index dfc93eadf627..f4e2ebcce8ec 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CompilationInfoSupport.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/CompilationInfoSupport.java @@ -32,11 +32,10 @@ import org.graalvm.compiler.nodes.FrameState; import org.graalvm.compiler.nodes.ValueNode; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.graal.pointsto.meta.AnalysisMethod; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.code.FrameInfoEncoder; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.image.NativeImageCodeCache; import com.oracle.svm.hosted.meta.HostedMethod; @@ -44,6 +43,7 @@ import jdk.vm.ci.meta.JavaKind; import jdk.vm.ci.meta.ResolvedJavaMethod; +@AutomaticallyRegisteredImageSingleton public class CompilationInfoSupport { /** @@ -230,11 +230,3 @@ private boolean seal() { return true; } } - -@AutomaticFeature -class CompilationInfoFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(CompilationInfoSupport.class, new CompilationInfoSupport()); - } -} diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/FactoryMethodSupport.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/FactoryMethodSupport.java index 1d238d07fbcd..ec1fe49cd04c 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/FactoryMethodSupport.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/FactoryMethodSupport.java @@ -30,16 +30,15 @@ import org.graalvm.compiler.nodes.java.AbstractNewObjectNode; import org.graalvm.compiler.nodes.java.NewInstanceNode; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.graal.pointsto.infrastructure.UniverseMetaAccess; import com.oracle.graal.pointsto.meta.AnalysisMetaAccess; import com.oracle.graal.pointsto.meta.AnalysisMethod; import com.oracle.graal.pointsto.meta.AnalysisType; import com.oracle.graal.pointsto.meta.AnalysisUniverse; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.code.FactoryMethodHolder; import com.oracle.svm.core.code.FactoryThrowMethodHolder; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.meta.HostedMetaAccess; import com.oracle.svm.hosted.meta.HostedMethod; @@ -51,6 +50,7 @@ import jdk.vm.ci.meta.ResolvedJavaType; import jdk.vm.ci.meta.Signature; +@AutomaticallyRegisteredImageSingleton public class FactoryMethodSupport { public static FactoryMethodSupport singleton() { @@ -104,11 +104,3 @@ protected AbstractNewObjectNode createNewInstance(HostedGraphKit kit, ResolvedJa return kit.append(new NewInstanceNode(type, fillContents)); } } - -@AutomaticFeature -final class FactoryMethodFeature implements Feature { - @Override - public void beforeAnalysis(BeforeAnalysisAccess arg) { - ImageSingletons.add(FactoryMethodSupport.class, new FactoryMethodSupport()); - } -} diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/RestrictHeapAccessCalleesImpl.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/RestrictHeapAccessCalleesImpl.java index 71c528302ffc..13c69d9c774c 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/RestrictHeapAccessCalleesImpl.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/RestrictHeapAccessCalleesImpl.java @@ -33,13 +33,13 @@ import java.util.Map; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.graal.pointsto.meta.AnalysisMethod; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.heap.RestrictHeapAccess; import com.oracle.svm.core.heap.RestrictHeapAccess.Access; -import com.oracle.svm.core.Uninterruptible; import com.oracle.svm.core.heap.RestrictHeapAccessCallees; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl; @@ -252,8 +252,8 @@ public AnalysisMethod getMethod() { } } -@AutomaticFeature -class RestrictHeapAccessCalleesFeature implements Feature { +@AutomaticallyRegisteredFeature +class RestrictHeapAccessCalleesFeature implements InternalFeature { /** This is called early, to register in the VMConfiguration. */ @Override diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/SubstrateLIRBackendFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/SubstrateLIRBackendFeature.java index 41487c26a7f1..0e0a6ba514ab 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/SubstrateLIRBackendFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/SubstrateLIRBackendFeature.java @@ -33,21 +33,20 @@ import org.graalvm.compiler.phases.util.Providers; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.meta.RuntimeConfiguration; import com.oracle.svm.core.graal.snippets.ExceptionSnippets; import com.oracle.svm.core.graal.snippets.NodeLoweringProvider; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.image.LIRNativeImageCodeCache; import com.oracle.svm.hosted.image.NativeImageCodeCache; import com.oracle.svm.hosted.image.NativeImageCodeCacheFactory; import com.oracle.svm.hosted.image.NativeImageHeap; -@AutomaticFeature -class SubstrateLIRBackendFeature implements Feature, InternalFeature { +@AutomaticallyRegisteredFeature +class SubstrateLIRBackendFeature implements InternalFeature { @Override public boolean isInConfiguration(IsInConfigurationAccess access) { return !SubstrateOptions.useLLVMBackend(); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/UninterruptibleAnnotationChecker.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/UninterruptibleAnnotationChecker.java index bac0b6936d1e..b17abb94fd63 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/UninterruptibleAnnotationChecker.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/UninterruptibleAnnotationChecker.java @@ -38,10 +38,9 @@ import org.graalvm.nativeimage.c.function.CFunction; import org.graalvm.nativeimage.c.function.CFunction.Transition; import org.graalvm.nativeimage.c.function.InvokeCFunctionPointer; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.option.HostedOptionKey; import com.oracle.svm.core.util.UserError; import com.oracle.svm.hosted.meta.HostedMethod; @@ -49,6 +48,7 @@ import jdk.vm.ci.meta.ResolvedJavaMethod; /** Checks that {@linkplain Uninterruptible} has been used consistently. */ +@AutomaticallyRegisteredImageSingleton public final class UninterruptibleAnnotationChecker { public static class Options { @@ -263,11 +263,3 @@ private static void printDotGraphEdge(HostedMethod caller, HostedMethod callee) System.out.println("/* DOT */ " + caller.format("<%h.%n>") + " -> " + callee.format("<%h.%n>") + calleeColor); } } - -@AutomaticFeature -final class UninterruptibleAnnotationCheckerFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(UninterruptibleAnnotationChecker.class, new UninterruptibleAnnotationChecker()); - } -} diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/aarch64/AArch64HostedPatcher.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/aarch64/AArch64HostedPatcherFeature.java similarity index 98% rename from substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/aarch64/AArch64HostedPatcher.java rename to substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/aarch64/AArch64HostedPatcherFeature.java index b08425f7e01f..f7fe795f6e90 100755 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/aarch64/AArch64HostedPatcher.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/aarch64/AArch64HostedPatcherFeature.java @@ -34,11 +34,11 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.objectfile.ObjectFile.RelocationKind; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.code.CGlobalDataReference; import com.oracle.svm.core.graal.code.PatchConsumerFactory; import com.oracle.svm.core.meta.MethodPointer; @@ -53,9 +53,9 @@ import jdk.vm.ci.code.site.Reference; import jdk.vm.ci.meta.VMConstant; -@AutomaticFeature +@AutomaticallyRegisteredFeature @Platforms({Platform.AARCH64.class}) -public class AArch64HostedPatcher implements Feature { +public class AArch64HostedPatcherFeature implements InternalFeature { @Override public void afterRegistration(AfterRegistrationAccess access) { ImageSingletons.add(PatchConsumerFactory.HostedPatchConsumerFactory.class, new PatchConsumerFactory.HostedPatchConsumerFactory() { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/aarch64/AArch64HostedTrampolineSupport.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/aarch64/AArch64HostedTrampolineSupport.java index 80c2732ffe2c..5197a9685399 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/aarch64/AArch64HostedTrampolineSupport.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/aarch64/AArch64HostedTrampolineSupport.java @@ -30,14 +30,12 @@ import org.graalvm.compiler.asm.aarch64.AArch64MacroAssembler; import org.graalvm.compiler.code.CompilationResult; import org.graalvm.compiler.core.common.NumUtil; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.graal.code.PatchConsumerFactory; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.code.HostedDirectCallTrampolineSupport; import com.oracle.svm.hosted.code.HostedPatcher; @@ -46,6 +44,8 @@ import jdk.vm.ci.code.Register; import jdk.vm.ci.code.TargetDescription; +@AutomaticallyRegisteredImageSingleton(HostedDirectCallTrampolineSupport.class) +@Platforms(Platform.AARCH64.class) public class AArch64HostedTrampolineSupport implements HostedDirectCallTrampolineSupport { private static final int INSTRUCTION_SIZE = 4 * Byte.BYTES; @@ -106,13 +106,3 @@ public byte[] createTrampoline(TargetDescription td, HostedMethod target, int tr return code; } } - -@AutomaticFeature -@Platforms({Platform.AARCH64.class}) -class HostedTrampolineFeature implements Feature { - - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(HostedDirectCallTrampolineSupport.class, new AArch64HostedTrampolineSupport()); - } -} diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/amd64/AMD64HostedPatcher.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/amd64/AMD64HostedPatcherFeature.java similarity index 94% rename from substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/amd64/AMD64HostedPatcher.java rename to substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/amd64/AMD64HostedPatcherFeature.java index c82157b7ea2c..47a654fba80a 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/amd64/AMD64HostedPatcher.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/amd64/AMD64HostedPatcherFeature.java @@ -33,11 +33,11 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.objectfile.ObjectFile; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.Uninterruptible; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.code.CGlobalDataReference; import com.oracle.svm.core.graal.code.PatchConsumerFactory; import com.oracle.svm.core.meta.MethodPointer; @@ -54,9 +54,9 @@ import jdk.vm.ci.code.site.Reference; import jdk.vm.ci.meta.VMConstant; -@AutomaticFeature +@AutomaticallyRegisteredFeature @Platforms({Platform.AMD64.class}) -class AMD64HostedPatcherFeature implements Feature { +class AMD64HostedPatcherFeature implements InternalFeature { @Override public void afterRegistration(AfterRegistrationAccess access) { ImageSingletons.add(PatchConsumerFactory.HostedPatchConsumerFactory.class, new PatchConsumerFactory.HostedPatchConsumerFactory() { @@ -79,10 +79,10 @@ public void accept(Assembler.CodeAnnotation annotation) { } } -public class AMD64HostedPatcher extends CompilationResult.CodeAnnotation implements HostedPatcher { +class AMD64HostedPatcher extends CompilationResult.CodeAnnotation implements HostedPatcher { private final OperandDataAnnotation annotation; - public AMD64HostedPatcher(OperandDataAnnotation annotation) { + AMD64HostedPatcher(OperandDataAnnotation annotation) { super(annotation.instructionPosition); this.annotation = annotation; } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/amd64/AMD64HostedTrampolineSupport.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/amd64/AMD64HostedTrampolineSupport.java index 7b7faa57fb44..2056060b5d7a 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/amd64/AMD64HostedTrampolineSupport.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/code/amd64/AMD64HostedTrampolineSupport.java @@ -31,14 +31,12 @@ import org.graalvm.compiler.asm.amd64.AMD64MacroAssembler; import org.graalvm.compiler.code.CompilationResult; import org.graalvm.compiler.core.common.NumUtil; -import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.graal.code.PatchConsumerFactory; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.code.HostedDirectCallTrampolineSupport; import com.oracle.svm.hosted.code.HostedPatcher; @@ -47,6 +45,8 @@ import jdk.vm.ci.amd64.AMD64; import jdk.vm.ci.code.TargetDescription; +@AutomaticallyRegisteredImageSingleton(HostedDirectCallTrampolineSupport.class) +@Platforms(Platform.AMD64.class) public class AMD64HostedTrampolineSupport implements HostedDirectCallTrampolineSupport { @Override @@ -116,13 +116,3 @@ public byte[] createTrampoline(TargetDescription td, HostedMethod target, int tr return code; } } - -@AutomaticFeature -@Platforms({Platform.AMD64.class}) -class HostedTrampolineFeature implements Feature { - - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(HostedDirectCallTrampolineSupport.class, new AMD64HostedTrampolineSupport()); - } -} diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/dashboard/DashboardDumpFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/dashboard/DashboardDumpFeature.java index 995de51dfb0b..a4a10dbbcde7 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/dashboard/DashboardDumpFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/dashboard/DashboardDumpFeature.java @@ -24,29 +24,30 @@ */ package com.oracle.svm.hosted.dashboard; -import com.oracle.graal.pointsto.reports.ReportUtils; -import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.hosted.FeatureImpl.AfterCompilationAccessImpl; -import com.oracle.svm.hosted.FeatureImpl.AfterHeapLayoutAccessImpl; -import com.oracle.svm.hosted.FeatureImpl.OnAnalysisExitAccessImpl; -import org.graalvm.nativeimage.hosted.Feature; -import org.graalvm.graphio.GraphOutput; -import org.graalvm.graphio.GraphStructure; - import java.io.File; import java.io.IOException; import java.io.PrintWriter; +import java.nio.channels.Channels; import java.nio.file.Path; import java.util.Collection; import java.util.Collections; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; -import java.nio.channels.Channels; -@AutomaticFeature -public class DashboardDumpFeature implements Feature { +import org.graalvm.graphio.GraphOutput; +import org.graalvm.graphio.GraphStructure; + +import com.oracle.graal.pointsto.reports.ReportUtils; +import com.oracle.svm.core.SubstrateOptions; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.hosted.FeatureImpl.AfterCompilationAccessImpl; +import com.oracle.svm.hosted.FeatureImpl.AfterHeapLayoutAccessImpl; +import com.oracle.svm.hosted.FeatureImpl.OnAnalysisExitAccessImpl; + +@AutomaticallyRegisteredFeature +public class DashboardDumpFeature implements InternalFeature { private static boolean isHeapBreakdownDumped() { return DashboardOptions.DashboardAll.getValue() || DashboardOptions.DashboardHeap.getValue(); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/diagnostic/HostedHeapDumpFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/diagnostic/HostedHeapDumpFeature.java index f13e94161cc0..df2176f6bbd8 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/diagnostic/HostedHeapDumpFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/diagnostic/HostedHeapDumpFeature.java @@ -36,20 +36,20 @@ import java.util.stream.Stream; import org.graalvm.compiler.options.Option; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.graal.pointsto.reports.ReportUtils; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.option.HostedOptionKey; import com.oracle.svm.core.option.LocatableMultiOptionValue; import com.oracle.svm.core.option.OptionUtils; import com.oracle.svm.core.option.SubstrateOptionsParser; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.UserError; import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl; -@AutomaticFeature -public class HostedHeapDumpFeature implements Feature { +@AutomaticallyRegisteredFeature +public class HostedHeapDumpFeature implements InternalFeature { static class Options { @Option(help = "Dump the heap at a specific time during image building." + diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/fieldfolding/StaticFinalFieldFoldingFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/fieldfolding/StaticFinalFieldFoldingFeature.java index 72dcc2d469fb..6b384ebef3c2 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/fieldfolding/StaticFinalFieldFoldingFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/fieldfolding/StaticFinalFieldFoldingFeature.java @@ -70,13 +70,13 @@ import com.oracle.graal.pointsto.meta.AnalysisField; import com.oracle.graal.pointsto.meta.AnalysisMethod; import com.oracle.svm.core.ParsingReason; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.classinitialization.EnsureClassInitializedNode; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.meta.ReadableJavaField; import com.oracle.svm.core.meta.SubstrateObjectConstant; import com.oracle.svm.core.option.HostedOptionKey; import com.oracle.svm.core.option.SubstrateOptionsParser; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl; import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl; import com.oracle.svm.hosted.meta.HostedField; @@ -127,7 +127,7 @@ * {@link EnsureClassInitializedNode} necessary in the method that performs the field access. * */ -@AutomaticFeature +@AutomaticallyRegisteredFeature final class StaticFinalFieldFoldingFeature implements InternalFeature { public static class Options { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/HeapDumpHostedUtils.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/HeapDumpFieldsMapFeature.java similarity index 96% rename from substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/HeapDumpHostedUtils.java rename to substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/HeapDumpFieldsMapFeature.java index 369eab19993a..aaff568446ad 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/HeapDumpHostedUtils.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/HeapDumpFieldsMapFeature.java @@ -33,17 +33,18 @@ import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.heapdump.HeapDumpUtils; import com.oracle.svm.core.meta.SharedField; import com.oracle.svm.core.meta.SharedType; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.ByteArrayReader; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl.AfterCompilationAccessImpl; import jdk.vm.ci.meta.ResolvedJavaField; -public class HeapDumpHostedUtils { +class HeapDumpHostedUtils { @Platforms(Platform.HOSTED_ONLY.class) public static byte[] dumpFieldsMap(Collection types) { @@ -143,8 +144,8 @@ private static void writeString(UnsafeArrayTypeWriter writeBuffer, String name) } } -@AutomaticFeature -class HeapDumpFieldsMapFeature implements Feature { +@AutomaticallyRegisteredFeature +class HeapDumpFieldsMapFeature implements InternalFeature { /** * Write out fields info and their offsets. diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/ImageHeapMapFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/ImageHeapMapFeature.java index 44d8549ac5da..dc72fd415591 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/ImageHeapMapFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/ImageHeapMapFeature.java @@ -30,16 +30,16 @@ import org.graalvm.collections.EconomicMap; import org.graalvm.collections.MapCursor; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.svm.core.BuildPhaseProvider; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.ImageHeapMap.HostedImageHeapMap; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl; -@AutomaticFeature -final class ImageHeapMapFeature implements Feature { +@AutomaticallyRegisteredFeature +final class ImageHeapMapFeature implements InternalFeature { private final Set> allInstances = ConcurrentHashMap.newKeySet(); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/PodSupport.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/PodSupport.java index 3348b35d0122..809248eac9a1 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/PodSupport.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/heap/PodSupport.java @@ -48,8 +48,9 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.deopt.DeoptTest; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.heap.Pod; import com.oracle.svm.core.heap.Pod.Builder; import com.oracle.svm.core.heap.Pod.RuntimeSupport.PodFactory; @@ -97,8 +98,8 @@ static PodSupport singleton() { boolean mustReserveLengthField(Class clazz); } -@AutomaticFeature -final class PodFeature implements PodSupport, Feature { +@AutomaticallyRegisteredFeature +final class PodFeature implements PodSupport, InternalFeature { private static final AtomicInteger GENERATED_COUNTER = new AtomicInteger(); private final Map pods = new ConcurrentHashMap<>(); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/DisallowedImageHeapObjectFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/DisallowedImageHeapObjectFeature.java index c45dfe07fd1a..d34bd7b0d50a 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/DisallowedImageHeapObjectFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/DisallowedImageHeapObjectFeature.java @@ -41,11 +41,12 @@ import com.oracle.graal.pointsto.constraints.UnsupportedFeatureException; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.image.DisallowedImageHeapObjects; import com.oracle.svm.core.jdk.management.ManagementFeature; import com.oracle.svm.core.jdk.management.ManagementSupport; import com.oracle.svm.core.option.SubstrateOptionsParser; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.FeatureImpl; import com.oracle.svm.hosted.classinitialization.ClassInitializationOptions; import com.oracle.svm.hosted.classinitialization.ClassInitializationSupport; @@ -54,8 +55,8 @@ /** * Complain if there are types that can not move from the image generator heap to the image heap. */ -@AutomaticFeature -public class DisallowedImageHeapObjectFeature implements Feature { +@AutomaticallyRegisteredFeature +public class DisallowedImageHeapObjectFeature implements InternalFeature { private ClassInitializationSupport classInitialization; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/ImageHeapFillerObjectsFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/ImageHeapFillerObjectsFeature.java index b97221a6c451..ec867f6353c6 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/ImageHeapFillerObjectsFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/ImageHeapFillerObjectsFeature.java @@ -24,15 +24,14 @@ */ package com.oracle.svm.hosted.image; -import org.graalvm.nativeimage.hosted.Feature; - -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.heap.FillerObject; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl; import com.oracle.svm.util.ReflectionUtil; -@AutomaticFeature -class ImageHeapFillerObjectsFeature implements Feature { +@AutomaticallyRegisteredFeature +class ImageHeapFillerObjectsFeature implements InternalFeature { @Override public void beforeAnalysis(BeforeAnalysisAccess arg) { BeforeAnalysisAccessImpl access = (BeforeAnalysisAccessImpl) arg; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImage.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImage.java index 4d9d577d8b2a..986429afb891 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImage.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/NativeImage.java @@ -60,7 +60,6 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.c.function.CEntryPoint.Publish; import org.graalvm.nativeimage.c.function.CFunctionPointer; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.graal.pointsto.meta.AnalysisMethod; import com.oracle.graal.pointsto.meta.AnalysisType; @@ -85,7 +84,6 @@ import com.oracle.svm.core.OS; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.SubstrateUtil; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.c.CConst; import com.oracle.svm.core.c.CGlobalDataImpl; import com.oracle.svm.core.c.CHeader; @@ -94,6 +92,7 @@ import com.oracle.svm.core.c.CUnsigned; import com.oracle.svm.core.c.function.GraalIsolateHeader; import com.oracle.svm.core.config.ConfigurationValues; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.code.CGlobalDataInfo; import com.oracle.svm.core.graal.code.CGlobalDataReference; import com.oracle.svm.core.image.ImageHeapLayoutInfo; @@ -101,6 +100,7 @@ import com.oracle.svm.core.meta.MethodPointer; import com.oracle.svm.core.meta.SubstrateObjectConstant; import com.oracle.svm.core.option.HostedOptionValues; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.UserError; import com.oracle.svm.hosted.FeatureImpl; import com.oracle.svm.hosted.NativeImageOptions; @@ -988,8 +988,8 @@ protected NativeTextSectionImpl(RelocatableBuffer relocatableBuffer, ObjectFile } } -@AutomaticFeature -final class MethodPointerInvalidHandlerFeature implements Feature { +@AutomaticallyRegisteredFeature +final class MethodPointerInvalidHandlerFeature implements InternalFeature { @Override public void beforeAnalysis(BeforeAnalysisAccess a) { FeatureImpl.BeforeAnalysisAccessImpl access = (FeatureImpl.BeforeAnalysisAccessImpl) a; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/StringInternFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/StringInternFeature.java index 739b59476a12..c52dfb8fc254 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/StringInternFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/StringInternFeature.java @@ -29,18 +29,18 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.graal.pointsto.meta.AnalysisMetaAccess; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.StringInternSupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl; import jdk.vm.ci.meta.MetaAccessProvider; import jdk.vm.ci.meta.ResolvedJavaField; -@AutomaticFeature -class StringInternFeature implements Feature { +@AutomaticallyRegisteredFeature +class StringInternFeature implements InternalFeature { @Platforms(Platform.HOSTED_ONLY.class) public static ResolvedJavaField getInternedStringsField(MetaAccessProvider metaAccess) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/sources/SourceCache.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/sources/SourceCache.java index 909957ed682e..cb1b8c476063 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/sources/SourceCache.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/image/sources/SourceCache.java @@ -23,7 +23,6 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ - package com.oracle.svm.hosted.image.sources; import java.io.File; @@ -40,11 +39,10 @@ import java.util.HashMap; import java.util.List; -import org.graalvm.nativeimage.hosted.Feature; - import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.option.OptionUtils; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl; import com.oracle.svm.hosted.ImageClassLoader; @@ -501,7 +499,7 @@ protected static void ensureTargetDirs(Path targetDir) { * * @param path The path to add. */ - private static void addClassPathEntry(Path path) { + static void addClassPathEntry(Path path) { classPathEntries.add(path); } @@ -510,29 +508,29 @@ private static void addClassPathEntry(Path path) { * * @param path The path to add. */ - private static void addSourcePathEntry(String path) { + static void addSourcePathEntry(String path) { sourcePathEntries.add(path); } +} - /** - * An automatic feature class which acquires the image loader class path via the afterAnalysis - * callback. - */ - @AutomaticFeature - @SuppressWarnings("unused") - public static class SourceCacheFeature implements Feature { - @Override - public void afterAnalysis(AfterAnalysisAccess access) { - FeatureImpl.AfterAnalysisAccessImpl accessImpl = (FeatureImpl.AfterAnalysisAccessImpl) access; - ImageClassLoader loader = accessImpl.getImageClassLoader(); - for (Path entry : loader.classpath()) { - addClassPathEntry(entry); - } - // also add any necessary source path entries - if (SubstrateOptions.DebugInfoSourceSearchPath.getValue() != null) { - for (String searchPathEntry : OptionUtils.flatten(",", SubstrateOptions.DebugInfoSourceSearchPath.getValue())) { - addSourcePathEntry(searchPathEntry); - } +/** + * An automatic feature class which acquires the image loader class path via the afterAnalysis + * callback. + */ +@AutomaticallyRegisteredFeature +@SuppressWarnings("unused") +class SourceCacheFeature implements InternalFeature { + @Override + public void afterAnalysis(AfterAnalysisAccess access) { + FeatureImpl.AfterAnalysisAccessImpl accessImpl = (FeatureImpl.AfterAnalysisAccessImpl) access; + ImageClassLoader loader = accessImpl.getImageClassLoader(); + for (Path entry : loader.classpath()) { + SourceCache.addClassPathEntry(entry); + } + // also add any necessary source path entries + if (SubstrateOptions.DebugInfoSourceSearchPath.getValue() != null) { + for (String searchPathEntry : OptionUtils.flatten(",", SubstrateOptions.DebugInfoSourceSearchPath.getValue())) { + SourceCache.addSourcePathEntry(searchPathEntry); } } } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/AccessControlContextReplacerFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/AccessControlContextReplacerFeature.java index c16bc134832e..98b2d064125a 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/AccessControlContextReplacerFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/AccessControlContextReplacerFeature.java @@ -32,16 +32,16 @@ import java.util.Map; import org.graalvm.compiler.serviceprovider.JavaVersionUtil; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.AccessControllerUtil; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; import com.oracle.svm.util.ReflectionUtil; -@AutomaticFeature +@AutomaticallyRegisteredFeature @SuppressWarnings({"unused"}) -class AccessControlContextReplacerFeature implements Feature { +class AccessControlContextReplacerFeature implements InternalFeature { static Map allowedContexts = new HashMap<>(); 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 49b87c3069e6..aaf2acda92fa 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 @@ -27,13 +27,13 @@ import org.graalvm.compiler.serviceprovider.JavaVersionUtil; import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.RuntimeClassInitializationSupport; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; -@AutomaticFeature -public class JDKInitializationFeature implements Feature { +@AutomaticallyRegisteredFeature +public class JDKInitializationFeature implements InternalFeature { private static final String JDK_CLASS_REASON = "Core JDK classes are initialized at build time"; @Override 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 ef07e5e908a0..010cabcda22f 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 @@ -26,11 +26,11 @@ import org.graalvm.compiler.serviceprovider.JavaVersionUtil; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.JNIRegistrationUtil; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; -@AutomaticFeature +@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 e285fce256a8..358329c2e2e6 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 @@ -26,14 +26,14 @@ import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.FeatureImpl.BeforeImageWriteAccessImpl; @Platforms(Platform.WINDOWS.class) -@AutomaticFeature -public class JNIRegistrationAWTSupport implements Feature { +@AutomaticallyRegisteredFeature +public class JNIRegistrationAWTSupport implements InternalFeature { @Override public void afterAnalysis(AfterAnalysisAccess access) { JNIRegistrationSupport jniRegistrationSupport = JNIRegistrationSupport.singleton(); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationAwt.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationAwt.java index e8c8dba99a07..3c823411b12a 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationAwt.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JNIRegistrationAwt.java @@ -29,14 +29,14 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.hosted.RuntimeJNIAccess; import org.graalvm.nativeimage.impl.ConfigurationCondition; import org.graalvm.nativeimage.impl.InternalPlatform; import org.graalvm.nativeimage.impl.RuntimeResourceSupport; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; +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.jdk.NativeLibrarySupport; import com.oracle.svm.core.jdk.PlatformNativeLibrarySupport; @@ -44,9 +44,9 @@ import com.oracle.svm.hosted.c.NativeLibraries; @Platforms({InternalPlatform.PLATFORM_JNI.class}) -@AutomaticFeature +@AutomaticallyRegisteredFeature @SuppressWarnings({"unused"}) -public class JNIRegistrationAwt extends JNIRegistrationUtil implements Feature { +public class JNIRegistrationAwt extends JNIRegistrationUtil implements InternalFeature { @Override public void beforeAnalysis(BeforeAnalysisAccess access) { 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 4c97e236cb28..875d3aab924e 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 @@ -31,11 +31,11 @@ import java.util.function.Consumer; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.hosted.RuntimeJNIAccess; import org.graalvm.nativeimage.impl.InternalPlatform; -import com.oracle.svm.core.annotate.AutomaticFeature; +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.jdk.PlatformNativeLibrarySupport; import com.oracle.svm.hosted.FeatureImpl; @@ -44,8 +44,8 @@ * Registration of classes, methods, and fields accessed via JNI by C code of the JDK. */ @Platforms(InternalPlatform.PLATFORM_JNI.class) -@AutomaticFeature -class JNIRegistrationJava extends JNIRegistrationUtil implements Feature { +@AutomaticallyRegisteredFeature +class JNIRegistrationJava extends JNIRegistrationUtil implements InternalFeature { private static final Consumer CORESERVICES_LINKER = (duringAnalysisAccess -> { FeatureImpl.DuringAnalysisAccessImpl accessImpl = (FeatureImpl.DuringAnalysisAccessImpl) duringAnalysisAccess; 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 bd22bd78970a..876fdcd559a5 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 @@ -33,12 +33,12 @@ import org.graalvm.compiler.serviceprovider.JavaVersionUtil; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.hosted.RuntimeJNIAccess; import org.graalvm.nativeimage.hosted.RuntimeReflection; import org.graalvm.nativeimage.impl.InternalPlatform; -import com.oracle.svm.core.annotate.AutomaticFeature; +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.util.VMError; import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl; @@ -48,8 +48,8 @@ * Registration of classes, methods, and fields accessed via JNI by C code of the JDK. */ @Platforms({InternalPlatform.PLATFORM_JNI.class}) -@AutomaticFeature -class JNIRegistrationJavaNet extends JNIRegistrationUtil implements Feature { +@AutomaticallyRegisteredFeature +class JNIRegistrationJavaNet extends JNIRegistrationUtil implements InternalFeature { private boolean hasExtendedOptionsImpl; 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 5ab1d9679f32..93ea4a9f32e1 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 @@ -31,20 +31,20 @@ import org.graalvm.compiler.serviceprovider.JavaVersionUtil; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.hosted.RuntimeJNIAccess; import org.graalvm.nativeimage.hosted.RuntimeReflection; import org.graalvm.nativeimage.impl.InternalPlatform; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.JNIRegistrationUtil; /** * Registration of classes, methods, and fields accessed via JNI by C code of the JDK. */ @Platforms({InternalPlatform.PLATFORM_JNI.class}) -@AutomaticFeature -public class JNIRegistrationJavaNio extends JNIRegistrationUtil implements Feature { +@AutomaticallyRegisteredFeature +public class JNIRegistrationJavaNio extends JNIRegistrationUtil implements InternalFeature { @Override public void duringSetup(DuringSetupAccess a) { 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 512a9493541e..90dc6d3ca7d7 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,21 +28,21 @@ import org.graalvm.nativeimage.IsolateThread; import org.graalvm.nativeimage.c.type.CCharPointer; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; +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.jdk.PlatformNativeLibrarySupport; import com.oracle.svm.core.jdk.management.LibManagementExtSupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl; import com.oracle.svm.hosted.c.NativeLibraries; import com.oracle.svm.hosted.code.CEntryPointCallStubSupport; import com.oracle.svm.hosted.code.CEntryPointData; import com.oracle.svm.util.ReflectionUtil; -@AutomaticFeature -public class JNIRegistrationManagementExt extends JNIRegistrationUtil implements Feature { +@AutomaticallyRegisteredFeature +public class JNIRegistrationManagementExt extends JNIRegistrationUtil implements InternalFeature { private NativeLibraries nativeLibraries; @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 9ada029016f3..d0bca3c0b761 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 @@ -27,11 +27,11 @@ import java.util.ArrayList; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.hosted.RuntimeJNIAccess; import org.graalvm.nativeimage.impl.InternalPlatform; -import com.oracle.svm.core.annotate.AutomaticFeature; +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.jdk.NativeLibrarySupport; import com.oracle.svm.core.util.VMError; @@ -39,8 +39,8 @@ import com.oracle.svm.hosted.c.NativeLibraries; @Platforms({InternalPlatform.PLATFORM_JNI.class}) -@AutomaticFeature -public class JNIRegistrationPrefs extends JNIRegistrationUtil implements Feature { +@AutomaticallyRegisteredFeature +public class JNIRegistrationPrefs extends JNIRegistrationUtil implements InternalFeature { @Override public void beforeAnalysis(BeforeAnalysisAccess access) { 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 33ee03a5d2e7..f91074725eb2 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 @@ -59,11 +59,11 @@ import com.oracle.svm.core.BuildArtifacts; import com.oracle.svm.core.ParsingReason; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.graal.InternalFeature; +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.meta.SubstrateObjectConstant; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.InterruptImageBuilding; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl.AfterImageWriteAccessImpl; @@ -77,7 +77,7 @@ /** Registration of native JDK libraries. */ @Platforms(InternalPlatform.PLATFORM_JNI.class) -@AutomaticFeature +@AutomaticallyRegisteredFeature public final class JNIRegistrationSupport extends JNIRegistrationUtil implements InternalFeature { private final ConcurrentMap registeredLibraries = new ConcurrentHashMap<>(); 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 d8337a868b1a..f41339e93b07 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 @@ -25,16 +25,16 @@ package com.oracle.svm.hosted.jdk; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.hosted.RuntimeJNIAccess; import org.graalvm.nativeimage.impl.InternalPlatform; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.JNIRegistrationUtil; @Platforms(InternalPlatform.PLATFORM_JNI.class) -@AutomaticFeature -class JNIRegistrationsJavaZip extends JNIRegistrationUtil implements Feature { +@AutomaticallyRegisteredFeature +class JNIRegistrationsJavaZip extends JNIRegistrationUtil implements InternalFeature { @Override public void duringSetup(DuringSetupAccess a) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JRTFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JRTFeature.java index b1e65b891cd7..425aab252ba1 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JRTFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/JRTFeature.java @@ -24,13 +24,12 @@ */ package com.oracle.svm.hosted.jdk; -import org.graalvm.nativeimage.hosted.Feature; - -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.FeatureImpl; -@AutomaticFeature -public class JRTFeature implements Feature { +@AutomaticallyRegisteredFeature +public class JRTFeature implements InternalFeature { @Override public void beforeAnalysis(BeforeAnalysisAccess access) { 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 15d2773d6202..0d54073ac9ba 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 @@ -25,14 +25,14 @@ package com.oracle.svm.hosted.jdk.localization; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.ConfigurationCondition; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.configure.ResourcesRegistry; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; -@AutomaticFeature -class CharsetSubstitutionsFeature implements Feature { +@AutomaticallyRegisteredFeature +class CharsetSubstitutionsFeature implements InternalFeature { @Override public void beforeAnalysis(BeforeAnalysisAccess access) { ImageSingletons.lookup(ResourcesRegistry.class).addResources(ConfigurationCondition.create("java.lang.CharacterName"), "java/lang/uniName.dat"); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/localization/LocalizationFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/localization/LocalizationFeature.java index fb668bde76b9..bf2e4644815b 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/localization/LocalizationFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jdk/localization/LocalizationFeature.java @@ -68,12 +68,11 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.Platform; import org.graalvm.nativeimage.Platforms; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.RuntimeClassInitializationSupport; import com.oracle.svm.core.ClassLoaderSupport; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.annotate.Substitute; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.localization.BundleContentSubstitutedLocalizationSupport; import com.oracle.svm.core.jdk.localization.LocalizationSupport; import com.oracle.svm.core.jdk.localization.OptimizedLocalizationSupport; @@ -82,6 +81,7 @@ import com.oracle.svm.core.option.HostedOptionKey; import com.oracle.svm.core.option.LocatableMultiOptionValue; import com.oracle.svm.core.option.OptionUtils; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.UserError; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl; @@ -128,8 +128,8 @@ * @see OptimizedLocalizationSupport * @see BundleContentSubstitutedLocalizationSupport */ -@AutomaticFeature -public class LocalizationFeature implements Feature { +@AutomaticallyRegisteredFeature +public class LocalizationFeature implements InternalFeature { protected final boolean optimizedMode = Options.LocalizationOptimizedMode.getValue(); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jfr/JfrEventFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jfr/JfrEventFeature.java index 100c5e954175..f4c488879b92 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jfr/JfrEventFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jfr/JfrEventFeature.java @@ -35,13 +35,14 @@ import org.graalvm.nativeimage.hosted.RuntimeClassInitialization; import org.graalvm.nativeimage.hosted.RuntimeReflection; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.hub.DynamicHub; import com.oracle.svm.core.hub.DynamicHubSupport; import com.oracle.svm.core.jfr.JfrFeature; import com.oracle.svm.core.jfr.traceid.JfrTraceId; import com.oracle.svm.core.jfr.traceid.JfrTraceIdMap; import com.oracle.svm.core.meta.SharedType; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl; import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl; @@ -54,8 +55,8 @@ * Support for Java-level JFR events. This feature is only present if the {@link JfrFeature} is used * as well but it needs functionality that is only available in com.oracle.svm.hosted. */ -@AutomaticFeature -public class JfrEventFeature implements Feature { +@AutomaticallyRegisteredFeature +public class JfrEventFeature implements InternalFeature { @Override public boolean isInConfiguration(IsInConfigurationAccess access) { return JfrFeature.isInConfiguration(false); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jni/JNIAutomaticFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jni/JNIAutomaticFeature.java index 61a7db346bfc..1726f3e94d9c 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jni/JNIAutomaticFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/jni/JNIAutomaticFeature.java @@ -30,13 +30,14 @@ import org.graalvm.nativeimage.hosted.Feature; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; /** * Automatically enables {@link JNIFeature} when specific options are set. */ -@AutomaticFeature -public class JNIAutomaticFeature implements Feature { +@AutomaticallyRegisteredFeature +public class JNIAutomaticFeature implements InternalFeature { @Override public boolean isInConfiguration(IsInConfigurationAccess access) { return SubstrateOptions.JNI.getValue(); 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 9af5d1e910df..9871356dec63 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 @@ -24,22 +24,23 @@ */ package com.oracle.svm.hosted.lambda; -import org.graalvm.compiler.java.LambdaUtils; import java.util.HashSet; import java.util.List; import java.util.Set; +import org.graalvm.compiler.java.LambdaUtils; + import com.oracle.graal.pointsto.meta.AnalysisType; import com.oracle.svm.core.SubstrateUtil; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.FeatureImpl.AfterAnalysisAccessImpl; import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl; /** * @see LambdaProxyRenamingSubstitutionProcessor */ -@AutomaticFeature +@AutomaticallyRegisteredFeature final class StableLambdaProxyNameFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/KnownOffsetsFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/KnownOffsetsFeature.java index 564c7a5ee86e..fe6287a0a1c7 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/KnownOffsetsFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/KnownOffsetsFeature.java @@ -32,13 +32,14 @@ import org.graalvm.nativeimage.hosted.Feature; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.code.ImageCodeInfo; import com.oracle.svm.core.config.ConfigurationValues; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.meta.KnownOffsets; import com.oracle.svm.core.hub.DynamicHub; import com.oracle.svm.core.stack.JavaFrameAnchor; import com.oracle.svm.core.thread.VMThreads; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.FeatureImpl.BeforeCompilationAccessImpl; import com.oracle.svm.hosted.c.info.AccessorInfo; import com.oracle.svm.hosted.c.info.StructFieldInfo; @@ -46,8 +47,9 @@ import com.oracle.svm.hosted.thread.VMThreadMTFeature; import com.oracle.svm.util.ReflectionUtil; -@AutomaticFeature -public final class KnownOffsetsFeature implements Feature { +@AutomaticallyRegisteredFeature +public final class KnownOffsetsFeature implements InternalFeature { + @Override public List> getRequiredFeatures() { if (SubstrateOptions.MultiThreaded.getValue()) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/MaterializedConstantFields.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/MaterializedConstantFields.java index f9a65c8157ca..075b3fd6cef6 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/MaterializedConstantFields.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/MaterializedConstantFields.java @@ -28,11 +28,11 @@ import java.util.Set; import java.util.concurrent.ConcurrentHashMap; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.ImageSingletons; import com.oracle.graal.pointsto.meta.AnalysisField; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; /** * Tracks fields with constant values which could be inlined, but which must exist in memory -- for @@ -69,8 +69,8 @@ void seal() { } } -@AutomaticFeature -class MaterializedConstantFieldsFeature implements Feature { +@AutomaticallyRegisteredFeature +class MaterializedConstantFieldsFeature implements InternalFeature { @Override public void afterRegistration(AfterRegistrationAccess access) { MaterializedConstantFields.initialize(); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/UniverseBuilder.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/UniverseBuilder.java index 3dbb405883fa..5f0a22b99b6f 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/UniverseBuilder.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/meta/UniverseBuilder.java @@ -40,7 +40,6 @@ import java.util.Set; import java.util.concurrent.ForkJoinTask; -import com.oracle.svm.core.heap.StoredContinuation; import org.graalvm.collections.Pair; import org.graalvm.compiler.core.common.NumUtil; import org.graalvm.compiler.debug.DebugContext; @@ -49,7 +48,6 @@ import org.graalvm.nativeimage.c.function.CEntryPointLiteral; import org.graalvm.nativeimage.c.function.CFunction; import org.graalvm.nativeimage.c.function.CFunctionPointer; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.graal.pointsto.BigBang; import com.oracle.graal.pointsto.constraints.UnsupportedFeatures; @@ -67,16 +65,18 @@ import com.oracle.svm.core.StaticFieldsSupport; import com.oracle.svm.core.SubstrateOptions; import com.oracle.svm.core.SubstrateUtil; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.heap.ExcludeFromReferenceMap; import com.oracle.svm.core.c.BoxedRelocatedPointer; import com.oracle.svm.core.c.function.CFunctionOptions; import com.oracle.svm.core.config.ConfigurationValues; import com.oracle.svm.core.config.ObjectLayout; import com.oracle.svm.core.deopt.DeoptimizedFrame; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.heap.ExcludeFromReferenceMap; import com.oracle.svm.core.heap.FillerObject; import com.oracle.svm.core.heap.InstanceReferenceMapEncoder; import com.oracle.svm.core.heap.ReferenceMapEncoder; +import com.oracle.svm.core.heap.StoredContinuation; import com.oracle.svm.core.heap.SubstrateReferenceMap; import com.oracle.svm.core.hub.DynamicHub; import com.oracle.svm.core.hub.DynamicHubSupport; @@ -992,8 +992,8 @@ private void processFieldLocations() { } } -@AutomaticFeature -final class InvalidVTableEntryFeature implements Feature { +@AutomaticallyRegisteredFeature +final class InvalidVTableEntryFeature implements InternalFeature { @Override public void beforeAnalysis(BeforeAnalysisAccess a) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/methodhandles/MethodHandleFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/methodhandles/MethodHandleFeature.java index 71157595266f..849af0f99cd5 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/methodhandles/MethodHandleFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/methodhandles/MethodHandleFeature.java @@ -36,12 +36,12 @@ import java.util.concurrent.ConcurrentHashMap; import org.graalvm.compiler.serviceprovider.JavaVersionUtil; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.hosted.RuntimeReflection; import com.oracle.svm.core.BuildPhaseProvider; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.invoke.MethodHandleIntrinsic; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl; import com.oracle.svm.util.ReflectionUtil; @@ -74,9 +74,9 @@ * calls into the JDK internals with equivalent implementations (see * {@code Target_java_lang_invoke_MethodHandleNatives}). */ -@AutomaticFeature +@AutomaticallyRegisteredFeature @SuppressWarnings("unused") -public class MethodHandleFeature implements Feature { +public class MethodHandleFeature implements InternalFeature { private Set seenMethodHandles; private Class directMethodHandleClass; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/option/RuntimeOptionFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/option/RuntimeOptionFeature.java index 0a7ee2eeece0..13dd9f68460a 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/option/RuntimeOptionFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/option/RuntimeOptionFeature.java @@ -27,15 +27,15 @@ import org.graalvm.compiler.options.OptionDescriptor; import org.graalvm.compiler.options.OptionKey; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.option.HostedOptionKey; import com.oracle.svm.core.option.RuntimeOptionParser; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; -@AutomaticFeature -public class RuntimeOptionFeature implements Feature { +@AutomaticallyRegisteredFeature +public class RuntimeOptionFeature implements InternalFeature { private RuntimeOptionParser runtimeOptionParser; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/EnumSwitchPlugin.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/EnumSwitchPlugin.java index 020bd98a193d..b0b100cab4f0 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/EnumSwitchPlugin.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/phases/EnumSwitchPlugin.java @@ -42,9 +42,9 @@ import com.oracle.graal.pointsto.BigBang; import com.oracle.graal.pointsto.meta.AnalysisMethod; import com.oracle.svm.core.ParsingReason; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.classinitialization.EnsureClassInitializedNode; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.FeatureImpl.DuringSetupAccessImpl; import com.oracle.svm.hosted.snippets.IntrinsificationPluginRegistry; import com.oracle.svm.hosted.snippets.ReflectionPlugins; @@ -129,7 +129,7 @@ public boolean handleInvoke(GraphBuilderContext b, ResolvedJavaMethod method, Va final class EnumSwitchPluginRegistry extends IntrinsificationPluginRegistry { } -@AutomaticFeature +@AutomaticallyRegisteredFeature final class EnumSwitchFeature implements InternalFeature { BigBang bb; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionFeature.java index 3d374425d83a..f47c6784358f 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionFeature.java @@ -47,14 +47,13 @@ import com.oracle.graal.pointsto.meta.AnalysisUniverse; import com.oracle.svm.core.ParsingReason; import com.oracle.svm.core.SubstrateUtil; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.annotate.Delete; import com.oracle.svm.core.configure.ConditionalElement; import com.oracle.svm.core.configure.ConfigurationFile; import com.oracle.svm.core.configure.ConfigurationFiles; import com.oracle.svm.core.configure.ReflectionConfigurationParser; import com.oracle.svm.core.fieldvaluetransformer.FieldValueTransformerWithAvailability; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.meta.KnownOffsets; import com.oracle.svm.core.hub.DynamicHub; import com.oracle.svm.core.meta.MethodPointer; @@ -64,6 +63,7 @@ import com.oracle.svm.core.reflect.SubstrateConstructorAccessor; import com.oracle.svm.core.reflect.SubstrateMethodAccessor; import com.oracle.svm.core.reflect.target.ReflectionSubstitutionSupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FallbackFeature; import com.oracle.svm.hosted.FeatureImpl; @@ -87,7 +87,7 @@ import jdk.vm.ci.meta.ResolvedJavaField; import jdk.vm.ci.meta.ResolvedJavaMethod; -@AutomaticFeature +@AutomaticallyRegisteredFeature public class ReflectionFeature implements InternalFeature, ReflectionSubstitutionSupport { private AnnotationSubstitutionProcessor annotationSubstitutions; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionMetadata.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionMetadata.java index 18a2410efd79..bac68ca92609 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionMetadata.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionMetadata.java @@ -26,31 +26,13 @@ import static com.oracle.svm.core.meta.SharedField.LOC_UNINITIALIZED; -import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; - -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.reflect.ReflectionMetadataDecoder; -import com.oracle.svm.core.reflect.target.ReflectionMetadataDecoderImpl; -import com.oracle.svm.core.reflect.target.ReflectionMetadataEncoding; import com.oracle.svm.hosted.annotation.AnnotationMemberValue; import com.oracle.svm.hosted.annotation.AnnotationValue; import com.oracle.svm.hosted.annotation.TypeAnnotationValue; -import com.oracle.svm.hosted.image.NativeImageCodeCache.ReflectionMetadataEncoderFactory; import com.oracle.svm.hosted.meta.HostedType; import jdk.vm.ci.meta.JavaConstant; -@AutomaticFeature -class ReflectionMetadataFeature implements Feature { - @Override - public void afterRegistration(AfterRegistrationAccess access) { - ImageSingletons.add(ReflectionMetadataEncoderFactory.class, new ReflectionMetadataEncoderImpl.Factory()); - ImageSingletons.add(ReflectionMetadataDecoder.class, new ReflectionMetadataDecoderImpl()); - ImageSingletons.add(ReflectionMetadataEncoding.class, new ReflectionMetadataEncoding()); - } -} - public class ReflectionMetadata { static class AnnotatedElementMetadata { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionMetadataEncoderImpl.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionMetadataEncoderImpl.java index 7536191ee546..477dcc29c746 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionMetadataEncoderImpl.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/ReflectionMetadataEncoderImpl.java @@ -80,6 +80,7 @@ import com.oracle.svm.core.reflect.target.ReflectionMetadataDecoderImpl; import com.oracle.svm.core.reflect.target.ReflectionMetadataEncoding; import com.oracle.svm.core.reflect.target.Target_sun_reflect_annotation_AnnotationParser; +import com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton; import com.oracle.svm.core.util.ByteArrayReader; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.annotation.AnnotationMemberValue; @@ -122,6 +123,7 @@ */ public class ReflectionMetadataEncoderImpl implements ReflectionMetadataEncoder { + @AutomaticallyRegisteredImageSingleton(ReflectionMetadataEncoderFactory.class) static class Factory implements ReflectionMetadataEncoderFactory { @Override public ReflectionMetadataEncoder create(CodeInfoEncoder.Encoders encoders) { diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy/DynamicProxyFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy/DynamicProxyFeature.java index a2628d3650fb..f41d82e818c8 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy/DynamicProxyFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/proxy/DynamicProxyFeature.java @@ -32,12 +32,13 @@ import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.impl.RuntimeProxyCreationSupport; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.configure.ConfigurationFile; import com.oracle.svm.core.configure.ConfigurationFiles; import com.oracle.svm.core.configure.ProxyConfigurationParser; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.proxy.DynamicProxyRegistry; import com.oracle.svm.core.reflect.proxy.DynamicProxySupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.ConfigurationTypeResolver; import com.oracle.svm.hosted.FallbackFeature; import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl; @@ -46,8 +47,8 @@ import com.oracle.svm.hosted.config.ConfigurationParserUtils; import com.oracle.svm.hosted.reflect.ReflectionFeature; -@AutomaticFeature -public final class DynamicProxyFeature implements Feature { +@AutomaticallyRegisteredFeature +public final class DynamicProxyFeature implements InternalFeature { private int loadedConfigurations; private Field proxyCacheField; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/serialize/SerializationFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/serialize/SerializationFeature.java index c5ee7022c9b7..f9957515b3da 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/serialize/SerializationFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/reflect/serialize/SerializationFeature.java @@ -66,14 +66,15 @@ import com.oracle.graal.pointsto.phases.NoClassInitializationPlugin; import com.oracle.graal.pointsto.util.GraalAccess; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.configure.ConditionalElement; import com.oracle.svm.core.configure.ConfigurationFile; import com.oracle.svm.core.configure.ConfigurationFiles; import com.oracle.svm.core.configure.SerializationConfigurationParser; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.RecordSupport; import com.oracle.svm.core.reflect.serialize.SerializationRegistry; import com.oracle.svm.core.reflect.serialize.SerializationSupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.UserError; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.ConditionalConfigurationRegistry; @@ -97,8 +98,8 @@ import jdk.vm.ci.meta.ResolvedJavaMethod; import jdk.vm.ci.meta.ResolvedJavaType; -@AutomaticFeature -public class SerializationFeature implements Feature { +@AutomaticallyRegisteredFeature +public class SerializationFeature implements InternalFeature { static final HashSet> capturingClasses = new HashSet<>(); private SerializationBuilder serializationBuilder; private int loadedConfigurations; 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 bba200674f92..96d11a3588f0 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 @@ -26,16 +26,16 @@ import com.oracle.graal.pointsto.meta.AnalysisMethod; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider; import com.oracle.svm.core.graal.snippets.NonSnippetLowerings; import com.oracle.svm.core.snippets.ExceptionUnwind; import com.oracle.svm.core.snippets.ImplicitExceptions; import com.oracle.svm.core.snippets.SnippetRuntime.SubstrateForeignCallDescriptor; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl; -@AutomaticFeature +@AutomaticallyRegisteredFeature final class ImplicitExceptionsFeature implements InternalFeature { @Override diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/substitute/UnsafeAutomaticSubstitutionProcessor.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/substitute/UnsafeAutomaticSubstitutionProcessor.java index c2143f5baecb..1647dc8b41da 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/substitute/UnsafeAutomaticSubstitutionProcessor.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/substitute/UnsafeAutomaticSubstitutionProcessor.java @@ -70,7 +70,6 @@ import org.graalvm.compiler.phases.common.CanonicalizerPhase; import org.graalvm.compiler.phases.tiers.HighTierContext; import org.graalvm.compiler.serviceprovider.JavaVersionUtil; -import org.graalvm.nativeimage.hosted.Feature; import com.oracle.graal.pointsto.infrastructure.SubstitutionProcessor; import com.oracle.graal.pointsto.meta.AnalysisType; @@ -78,11 +77,12 @@ import com.oracle.graal.pointsto.util.GraalAccess; import com.oracle.svm.core.ParsingReason; import com.oracle.svm.core.SubstrateUtil; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.annotate.RecomputeFieldValue; import com.oracle.svm.core.annotate.RecomputeFieldValue.Kind; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.RecordSupport; import com.oracle.svm.core.option.HostedOptionKey; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl; import com.oracle.svm.hosted.ImageClassLoader; @@ -97,8 +97,8 @@ import jdk.vm.ci.meta.ResolvedJavaMethod; import jdk.vm.ci.meta.ResolvedJavaType; -@AutomaticFeature -class AutomaticSubstitutionFeature implements Feature { +@AutomaticallyRegisteredFeature +class AutomaticSubstitutionFeature implements InternalFeature { @Override public void duringAnalysis(DuringAnalysisAccess access) { @@ -106,7 +106,6 @@ public void duringAnalysis(DuringAnalysisAccess access) { UnsafeAutomaticSubstitutionProcessor automaticSubstitutions = accessImpl.getHostVM().getAutomaticSubstitutionProcessor(); automaticSubstitutions.processComputedValueFields(accessImpl); } - } /** diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/thread/CEntryPointFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/thread/CEntryPointFeature.java index f333d84ef47f..5f66ef2d9b23 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/thread/CEntryPointFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/thread/CEntryPointFeature.java @@ -36,14 +36,14 @@ import org.graalvm.nativeimage.hosted.Feature; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.meta.RuntimeConfiguration; import com.oracle.svm.core.graal.meta.SubstrateForeignCallsProvider; import com.oracle.svm.core.graal.snippets.CEntryPointSnippets; import com.oracle.svm.core.graal.snippets.NodeLoweringProvider; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; -@AutomaticFeature +@AutomaticallyRegisteredFeature public class CEntryPointFeature implements InternalFeature { private int vmThreadSize = -1; diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/thread/VMThreadMTFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/thread/VMThreadMTFeature.java index fdaa590a35e6..689579e371d5 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/thread/VMThreadMTFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/thread/VMThreadMTFeature.java @@ -42,10 +42,9 @@ import com.oracle.svm.core.ParsingReason; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.c.NonmovableArray; import com.oracle.svm.core.c.NonmovableArrays; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.nodes.ReadReservedRegister; import com.oracle.svm.core.graal.thread.AddressOfVMThreadLocalNode; import com.oracle.svm.core.graal.thread.CompareAndSetVMThreadLocalNode; @@ -59,6 +58,7 @@ import com.oracle.svm.core.threadlocal.VMThreadLocalInfo; import com.oracle.svm.core.threadlocal.VMThreadLocalInfos; import com.oracle.svm.core.threadlocal.VMThreadLocalMTSupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl; @@ -68,7 +68,7 @@ * Collects all VM thread local variables during native image generation and assigns them their * offset in the {@link IsolateThread} data structure. */ -@AutomaticFeature +@AutomaticallyRegisteredFeature public class VMThreadMTFeature implements InternalFeature { private final VMThreadLocalCollector threadLocalCollector = new VMThreadLocalCollector(); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/thread/VMThreadSTFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/thread/VMThreadSTFeature.java index 40c6e78849b2..d4652f9e4a02 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/thread/VMThreadSTFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/thread/VMThreadSTFeature.java @@ -42,10 +42,9 @@ import com.oracle.svm.core.ParsingReason; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.config.ConfigurationValues; import com.oracle.svm.core.config.ObjectLayout; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.graal.thread.AddressOfVMThreadLocalNode; import com.oracle.svm.core.graal.thread.CompareAndSetVMThreadLocalNode; import com.oracle.svm.core.graal.thread.LoadVMThreadLocalNode; @@ -57,6 +56,7 @@ import com.oracle.svm.core.threadlocal.VMThreadLocalInfo; import com.oracle.svm.core.threadlocal.VMThreadLocalInfos; import com.oracle.svm.core.threadlocal.VMThreadLocalSTSupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.hosted.FeatureImpl.DuringAnalysisAccessImpl; import jdk.vm.ci.meta.JavaKind; @@ -66,7 +66,7 @@ * Collects all VM thread local variables during native image generation and assigns them their * offset in the Object[] and byte[] array that hold the values. */ -@AutomaticFeature +@AutomaticallyRegisteredFeature public class VMThreadSTFeature implements InternalFeature { private final VMThreadLocalCollector threadLocalCollector = new VMThreadLocalCollector(); diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/xml/JavaxXmlClassAndResourcesLoaderFeature.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/xml/JavaxXmlClassAndResourcesLoaderFeature.java index 1edcfb9f55f9..3d5bf3476c4e 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/xml/JavaxXmlClassAndResourcesLoaderFeature.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/xml/JavaxXmlClassAndResourcesLoaderFeature.java @@ -25,10 +25,6 @@ package com.oracle.svm.hosted.xml; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.jdk.JNIRegistrationUtil; -import org.graalvm.nativeimage.hosted.Feature; - import static com.oracle.svm.hosted.xml.XMLParsersRegistration.BuiltinSchemaGrammarClasses; import static com.oracle.svm.hosted.xml.XMLParsersRegistration.DOMImplementationRegistryClasses; import static com.oracle.svm.hosted.xml.XMLParsersRegistration.DOMParserClasses; @@ -38,8 +34,12 @@ import static com.oracle.svm.hosted.xml.XMLParsersRegistration.StAXParserClasses; import static com.oracle.svm.hosted.xml.XMLParsersRegistration.TransformerClassesAndResources; -@AutomaticFeature -public class JavaxXmlClassAndResourcesLoaderFeature extends JNIRegistrationUtil implements Feature { +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.jdk.JNIRegistrationUtil; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; + +@AutomaticallyRegisteredFeature +public class JavaxXmlClassAndResourcesLoaderFeature extends JNIRegistrationUtil implements InternalFeature { @Override public void beforeAnalysis(BeforeAnalysisAccess access) { diff --git a/substratevm/src/com.oracle.svm.polyglot/src/META-INF/native-image/com.oracle.svm/polyglot/native-image.properties b/substratevm/src/com.oracle.svm.polyglot/src/META-INF/native-image/com.oracle.svm/polyglot/native-image.properties new file mode 100644 index 000000000000..fd4482c095d1 --- /dev/null +++ b/substratevm/src/com.oracle.svm.polyglot/src/META-INF/native-image/com.oracle.svm/polyglot/native-image.properties @@ -0,0 +1 @@ +Args = --features=com.oracle.svm.polyglot.groovy.GroovyIndyInterfaceFeature,com.oracle.svm.polyglot.scala.ScalaFeature diff --git a/substratevm/src/com.oracle.svm.polyglot/src/com/oracle/svm/polyglot/groovy/GroovySubstitutions.java b/substratevm/src/com.oracle.svm.polyglot/src/com/oracle/svm/polyglot/groovy/GroovySubstitutions.java index e08654a274ad..694dc25581f7 100644 --- a/substratevm/src/com.oracle.svm.polyglot/src/com/oracle/svm/polyglot/groovy/GroovySubstitutions.java +++ b/substratevm/src/com.oracle.svm.polyglot/src/com/oracle/svm/polyglot/groovy/GroovySubstitutions.java @@ -29,12 +29,10 @@ import org.graalvm.nativeimage.ImageSingletons; import org.graalvm.nativeimage.hosted.Feature; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.annotate.Substitute; import com.oracle.svm.core.annotate.TargetClass; import com.oracle.svm.core.util.VMError; -@AutomaticFeature final class GroovyIndyInterfaceFeature implements Feature { static final class IsEnabled implements BooleanSupplier { diff --git a/substratevm/src/com.oracle.svm.polyglot/src/com/oracle/svm/polyglot/scala/ScalaFeature.java b/substratevm/src/com.oracle.svm.polyglot/src/com/oracle/svm/polyglot/scala/ScalaFeature.java index 7a2cd0e7d7f6..6e73b66f75c4 100644 --- a/substratevm/src/com.oracle.svm.polyglot/src/com/oracle/svm/polyglot/scala/ScalaFeature.java +++ b/substratevm/src/com.oracle.svm.polyglot/src/com/oracle/svm/polyglot/scala/ScalaFeature.java @@ -37,13 +37,11 @@ import com.oracle.svm.core.ParsingReason; import com.oracle.svm.core.SubstrateOptions; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.graal.InternalFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.util.UserError; import com.oracle.svm.hosted.FeatureImpl.BeforeAnalysisAccessImpl; import com.oracle.svm.util.ModuleSupport; -@AutomaticFeature public class ScalaFeature implements InternalFeature { public static final String UNSUPPORTED_SCALA_VERSION = "This is not a supported Scala version. native-image supports Scala 2.11.x and onwards."; diff --git a/substratevm/src/com.oracle.svm.processor/src/META-INF/services/javax.annotation.processing.Processor b/substratevm/src/com.oracle.svm.processor/src/META-INF/services/javax.annotation.processing.Processor new file mode 100644 index 000000000000..43e591af1f6c --- /dev/null +++ b/substratevm/src/com.oracle.svm.processor/src/META-INF/services/javax.annotation.processing.Processor @@ -0,0 +1,2 @@ +com.oracle.svm.processor.AutomaticallyRegisteredFeatureProcessor +com.oracle.svm.processor.AutomaticallyRegisteredImageSingletonProcessor diff --git a/substratevm/src/com.oracle.svm.processor/src/com/oracle/svm/processor/AutomaticallyRegisteredFeatureProcessor.java b/substratevm/src/com.oracle.svm.processor/src/com/oracle/svm/processor/AutomaticallyRegisteredFeatureProcessor.java new file mode 100644 index 000000000000..dd1c5de49303 --- /dev/null +++ b/substratevm/src/com.oracle.svm.processor/src/com/oracle/svm/processor/AutomaticallyRegisteredFeatureProcessor.java @@ -0,0 +1,129 @@ +/* + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.processor; + +import java.io.PrintWriter; +import java.util.HashSet; +import java.util.Set; + +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.lang.model.element.Element; +import javax.lang.model.element.TypeElement; +import javax.tools.Diagnostic.Kind; + +import org.graalvm.compiler.processor.AbstractProcessor; + +// Checkstyle: allow Class.getSimpleName + +/** + * Annotation processor for the @AutomaticallyRegistredFeature annotation. We need to generate some + * textual listing of all annotated feature classes that can be easily loaded in the image builder. + * Standard Java ServiceLoader descriptors are the easiest, because mx already has the support to + * aggregate service descriptors for multiple projects that end up in the same module. + * + * But ServiceLoader has one big downside: the implementation classes that are loaded must be + * public. We have many feature classes that are small and just "at the end" of other source files + * and therefore cannot be public. But there is an easy workaround: we do not register the feature + * classes as services, but automatically generate a "service registration" class in this annotation + * processor too. + */ +@SupportedAnnotationTypes(AutomaticallyRegisteredFeatureProcessor.ANNOTATION_CLASS_NAME) +public class AutomaticallyRegisteredFeatureProcessor extends AbstractProcessor { + + static final String ANNOTATION_CLASS_NAME = "com.oracle.svm.core.feature.AutomaticallyRegisteredFeature"; + static final String FEATURE_INTERFACE_CLASS_NAME = "com.oracle.svm.core.feature.InternalFeature"; + static final String SERVICE_REGISTRATION_INTERFACE_NAME = "com.oracle.svm.core.feature.AutomaticallyRegisteredFeatureServiceRegistration"; + + private final Set processed = new HashSet<>(); + + private void processElement(TypeElement annotatedType) { + if (!processingEnv.getTypeUtils().isSubtype(annotatedType.asType(), getType(FEATURE_INTERFACE_CLASS_NAME))) { + String msg = String.format("Class %s annotated with %s must implement interface %s", annotatedType.getSimpleName(), ANNOTATION_CLASS_NAME, FEATURE_INTERFACE_CLASS_NAME); + processingEnv.getMessager().printMessage(Kind.ERROR, msg, annotatedType); + return; + } + if (annotatedType.getNestingKind().isNested()) { + /* + * This is a simplifying constraint that means we do not have to process the qualified + * name to insert '$' characters at the relevant positions. + */ + String msg = String.format("Class %s annotated with %s must be a top level class", annotatedType.getSimpleName(), ANNOTATION_CLASS_NAME); + processingEnv.getMessager().printMessage(Kind.ERROR, msg, annotatedType); + return; + } + + String featureImplementationClassName = annotatedType.getQualifiedName().toString(); + String serviceRegistrationImplClassName = annotatedType.getSimpleName() + "_ServiceRegistration"; + String packageName = getPackage(annotatedType).getQualifiedName().toString(); + + /* + * Generate the "service registration" class. This class is public and can therefore + * registered as standard Java service. Its only purpose is to return the + * featureImplementationClassName. + */ + try (PrintWriter out = createSourceFile(packageName, serviceRegistrationImplClassName, processingEnv.getFiler(), annotatedType)) { + out.println("// CheckStyle: stop header check"); + out.println("// CheckStyle: stop line length check"); + out.println("package " + packageName + ";"); + out.println(""); + out.println("// GENERATED CONTENT - DO NOT EDIT"); + out.println("// Annotated type: " + annotatedType); + out.println("// Annotation: " + ANNOTATION_CLASS_NAME); + out.println("// Annotation processor: " + getClass().getName()); + out.println(""); + out.println("import " + SERVICE_REGISTRATION_INTERFACE_NAME + ";"); + out.println("import org.graalvm.nativeimage.Platform;"); + out.println("import org.graalvm.nativeimage.Platforms;"); + out.println(""); + out.println("@Platforms(Platform.HOSTED_ONLY.class)"); + out.println("public final class " + serviceRegistrationImplClassName + " implements " + getSimpleName(SERVICE_REGISTRATION_INTERFACE_NAME) + " {"); + out.println(" @Override"); + out.println(" public String getClassName() {"); + out.println(" return \"" + featureImplementationClassName + "\";"); + out.println(" }"); + out.println("}"); + } + + /* Register the "service registration" class as a service provider. */ + createProviderFile(packageName + "." + serviceRegistrationImplClassName, SERVICE_REGISTRATION_INTERFACE_NAME, annotatedType); + } + + @Override + public boolean doProcess(Set annotations, RoundEnvironment roundEnv) { + if (roundEnv.processingOver()) { + return true; + } + + TypeElement serviceProviderTypeElement = getTypeElement(ANNOTATION_CLASS_NAME); + for (Element element : roundEnv.getElementsAnnotatedWith(serviceProviderTypeElement)) { + assert element.getKind().isClass(); + if (processed.add(element)) { + processElement((TypeElement) element); + } + } + return true; + } +} diff --git a/substratevm/src/com.oracle.svm.processor/src/com/oracle/svm/processor/AutomaticallyRegisteredImageSingletonProcessor.java b/substratevm/src/com.oracle.svm.processor/src/com/oracle/svm/processor/AutomaticallyRegisteredImageSingletonProcessor.java new file mode 100644 index 000000000000..cce7abcdb186 --- /dev/null +++ b/substratevm/src/com.oracle.svm.processor/src/com/oracle/svm/processor/AutomaticallyRegisteredImageSingletonProcessor.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2022, 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package com.oracle.svm.processor; + +import java.io.PrintWriter; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.lang.model.element.AnnotationMirror; +import javax.lang.model.element.Element; +import javax.lang.model.element.TypeElement; +import javax.lang.model.type.TypeMirror; + +import org.graalvm.compiler.processor.AbstractProcessor; + +// Checkstyle: allow Class.getSimpleName + +/** + * Annotation processor for the @AutomaticallyRegisteredImageSingleton annotation. + */ +@SupportedAnnotationTypes(AutomaticallyRegisteredImageSingletonProcessor.ANNOTATION_CLASS_NAME) +public class AutomaticallyRegisteredImageSingletonProcessor extends AbstractProcessor { + + static final String ANNOTATION_CLASS_NAME = "com.oracle.svm.core.feature.AutomaticallyRegisteredImageSingleton"; + + private final Set processed = new HashSet<>(); + + private void processElement(TypeElement annotatedType) { + String featureClassName = getTypeNameWithEnclosingClasses(annotatedType, "Feature"); + String packageName = getPackage(annotatedType).getQualifiedName().toString(); + + AnnotationMirror singletonAnnotation = getAnnotation(annotatedType, getType(ANNOTATION_CLASS_NAME)); + AnnotationMirror platformsAnnotation = getAnnotation(annotatedType, getType("org.graalvm.nativeimage.Platforms")); + + try (PrintWriter out = createSourceFile(packageName, featureClassName, processingEnv.getFiler(), annotatedType)) { + out.println("// CheckStyle: stop header check"); + out.println("// CheckStyle: stop line length check"); + out.println("package " + packageName + ";"); + out.println(""); + out.println("// GENERATED CONTENT - DO NOT EDIT"); + out.println("// Annotated type: " + annotatedType); + out.println("// Annotation: " + ANNOTATION_CLASS_NAME); + out.println("// Annotation processor: " + getClass().getName()); + out.println(""); + out.println("import org.graalvm.nativeimage.ImageSingletons;"); + out.println("import " + AutomaticallyRegisteredFeatureProcessor.ANNOTATION_CLASS_NAME + ";"); + out.println("import " + AutomaticallyRegisteredFeatureProcessor.FEATURE_INTERFACE_CLASS_NAME + ";"); + if (platformsAnnotation != null) { + out.println("import org.graalvm.nativeimage.Platforms;"); + } + out.println(""); + + if (platformsAnnotation != null) { + String platforms = getAnnotationValueList(platformsAnnotation, "value", TypeMirror.class).stream().map(type -> type.toString() + ".class").collect(Collectors.joining(", ")); + out.println("@Platforms({" + platforms + "})"); + } + out.println("@" + getSimpleName(AutomaticallyRegisteredFeatureProcessor.ANNOTATION_CLASS_NAME)); + out.println("public final class " + featureClassName + " implements " + getSimpleName(AutomaticallyRegisteredFeatureProcessor.FEATURE_INTERFACE_CLASS_NAME) + " {"); + out.println(" @Override"); + out.println(" public void afterRegistration(AfterRegistrationAccess access) {"); + + List onlyWithList = getAnnotationValueList(singletonAnnotation, "onlyWith", TypeMirror.class); + if (!onlyWithList.isEmpty()) { + for (var onlyWith : onlyWithList) { + out.println(" if (!new " + onlyWith + "().getAsBoolean()) {"); + out.println(" return;"); + out.println(" }"); + } + } + + out.println(" var singleton = new " + annotatedType + "();"); + List keysFromAnnotation = getAnnotationValueList(singletonAnnotation, "value", TypeMirror.class); + if (keysFromAnnotation.isEmpty()) { + out.println(" ImageSingletons.add(" + annotatedType + ".class, singleton);"); + } else { + for (var keyFromAnnotation : keysFromAnnotation) { + out.println(" ImageSingletons.add(" + keyFromAnnotation.toString() + ".class, singleton);"); + } + } + out.println(" }"); + out.println("}"); + } + } + + /** + * We allow inner classes to be annotated. To make the generated service name unique, we need to + * concatenate the simple names of all outer classes. + */ + static String getTypeNameWithEnclosingClasses(TypeElement annotatedType, String suffix) { + String result = suffix; + for (Element cur = annotatedType; cur instanceof TypeElement; cur = cur.getEnclosingElement()) { + result = cur.getSimpleName().toString() + result; + } + return result; + } + + @Override + public boolean doProcess(Set annotations, RoundEnvironment roundEnv) { + if (roundEnv.processingOver()) { + return true; + } + + for (Element element : roundEnv.getElementsAnnotatedWith(getTypeElement(ANNOTATION_CLASS_NAME))) { + assert element.getKind().isClass(); + if (processed.add(element)) { + processElement((TypeElement) element); + } + } + return true; + } +} diff --git a/substratevm/src/com.oracle.svm.test/.checkstyle_checks.xml b/substratevm/src/com.oracle.svm.test/.checkstyle_checks.xml index 7523497dbf42..d054b5424d01 100644 --- a/substratevm/src/com.oracle.svm.test/.checkstyle_checks.xml +++ b/substratevm/src/com.oracle.svm.test/.checkstyle_checks.xml @@ -44,6 +44,12 @@ + + + + + + diff --git a/substratevm/src/com.oracle.svm.thirdparty/src/META-INF/native-image/com.oracle.svm/thirdparty/native-image.properties b/substratevm/src/com.oracle.svm.thirdparty/src/META-INF/native-image/com.oracle.svm/thirdparty/native-image.properties new file mode 100644 index 000000000000..cfcc4d09ac3e --- /dev/null +++ b/substratevm/src/com.oracle.svm.thirdparty/src/META-INF/native-image/com.oracle.svm/thirdparty/native-image.properties @@ -0,0 +1 @@ +Args = --features=com.oracle.svm.thirdparty.gson.GsonFeature diff --git a/substratevm/src/com.oracle.svm.thirdparty/src/com/oracle/svm/thirdparty/gson/GsonFeature.java b/substratevm/src/com.oracle.svm.thirdparty/src/com/oracle/svm/thirdparty/gson/GsonFeature.java index 12200c9e2935..65f559b183b0 100644 --- a/substratevm/src/com.oracle.svm.thirdparty/src/com/oracle/svm/thirdparty/gson/GsonFeature.java +++ b/substratevm/src/com.oracle.svm.thirdparty/src/com/oracle/svm/thirdparty/gson/GsonFeature.java @@ -27,7 +27,6 @@ import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.hosted.RuntimeReflection; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.util.VMError; /** @@ -40,7 +39,6 @@ * This feature registers parts of {@link sun.misc.Unsafe} as reflectively accessible. Gson uses it * internally to instantiate classes that do not have a no-argument constructor. */ -@AutomaticFeature public final class GsonFeature implements Feature { @Override diff --git a/substratevm/src/com.oracle.svm.truffle.nfi.posix/src/com/oracle/svm/truffle/nfi/posix/PosixTruffleNFIFeature.java b/substratevm/src/com.oracle.svm.truffle.nfi.posix/src/com/oracle/svm/truffle/nfi/posix/PosixTruffleNFIFeature.java index b1a3f08f8b92..5866f93a9804 100644 --- a/substratevm/src/com.oracle.svm.truffle.nfi.posix/src/com/oracle/svm/truffle/nfi/posix/PosixTruffleNFIFeature.java +++ b/substratevm/src/com.oracle.svm.truffle.nfi.posix/src/com/oracle/svm/truffle/nfi/posix/PosixTruffleNFIFeature.java @@ -32,13 +32,12 @@ import org.graalvm.nativeimage.StackValue; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.PointerBase; import org.graalvm.word.WordFactory; import com.oracle.svm.core.SubstrateUtil; -import com.oracle.svm.core.annotate.AutomaticFeature; import com.oracle.svm.core.c.libc.LibCBase; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.PlatformNativeLibrarySupport; import com.oracle.svm.core.posix.PosixUtils; import com.oracle.svm.core.posix.headers.Dlfcn; @@ -46,15 +45,16 @@ import com.oracle.svm.core.posix.headers.Dlfcn.GNUExtensions.Lmid_tPointer; import com.oracle.svm.core.posix.headers.PosixLibC; import com.oracle.svm.core.posix.linux.libc.GLibC; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.util.VMError; import com.oracle.svm.truffle.nfi.Target_com_oracle_truffle_nfi_backend_libffi_NFIUnsatisfiedLinkError; import com.oracle.svm.truffle.nfi.TruffleNFISupport; import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.exception.AbstractTruffleException; -@AutomaticFeature +@AutomaticallyRegisteredFeature @Platforms({Platform.LINUX.class, Platform.DARWIN.class}) -public final class PosixTruffleNFIFeature implements Feature { +public final class PosixTruffleNFIFeature implements InternalFeature { @Override public void duringSetup(DuringSetupAccess access) { @@ -70,6 +70,7 @@ final class PosixTruffleNFISupport extends TruffleNFISupport { static int isolatedNamespaceFlag = ISOLATED_NAMESPACE_NOT_SUPPORTED_FLAG; static void initialize() { + if (Platform.includedIn(Platform.LINUX.class)) { isolatedNamespaceFlag = LibCBase.singleton().hasIsolatedNamespaces() ? ISOLATED_NAMESPACE_FLAG : ISOLATED_NAMESPACE_NOT_SUPPORTED_FLAG; } diff --git a/substratevm/src/com.oracle.svm.truffle.nfi.windows/src/com/oracle/svm/truffle/nfi/windows/WindowsTruffleNFIFeature.java b/substratevm/src/com.oracle.svm.truffle.nfi.windows/src/com/oracle/svm/truffle/nfi/windows/WindowsTruffleNFIFeature.java index cf54b9469c63..81d96914ae6b 100644 --- a/substratevm/src/com.oracle.svm.truffle.nfi.windows/src/com/oracle/svm/truffle/nfi/windows/WindowsTruffleNFIFeature.java +++ b/substratevm/src/com.oracle.svm.truffle.nfi.windows/src/com/oracle/svm/truffle/nfi/windows/WindowsTruffleNFIFeature.java @@ -29,13 +29,13 @@ import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.type.CCharPointer; import org.graalvm.nativeimage.c.type.CTypeConversion; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.word.PointerBase; import org.graalvm.word.WordFactory; import com.oracle.svm.core.SubstrateUtil; -import com.oracle.svm.core.annotate.AutomaticFeature; +import com.oracle.svm.core.feature.InternalFeature; import com.oracle.svm.core.jdk.PlatformNativeLibrarySupport; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.core.windows.WindowsUtils; import com.oracle.svm.core.windows.headers.LibLoaderAPI; import com.oracle.svm.core.windows.headers.WinBase.HMODULE; @@ -45,9 +45,9 @@ import com.oracle.truffle.api.CompilerDirectives; import com.oracle.truffle.api.exception.AbstractTruffleException; -@AutomaticFeature +@AutomaticallyRegisteredFeature @Platforms(Platform.WINDOWS.class) -public final class WindowsTruffleNFIFeature implements Feature { +public final class WindowsTruffleNFIFeature implements InternalFeature { @Override public void duringSetup(DuringSetupAccess access) { diff --git a/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/TruffleNFIFeature.java b/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/TruffleNFIFeature.java index e577fe91dc14..b1c4d79c13de 100644 --- a/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/TruffleNFIFeature.java +++ b/substratevm/src/com.oracle.svm.truffle.nfi/src/com/oracle/svm/truffle/nfi/TruffleNFIFeature.java @@ -24,14 +24,15 @@ */ package com.oracle.svm.truffle.nfi; -import com.oracle.svm.core.annotate.AutomaticFeature; import java.util.Arrays; import java.util.List; import java.util.function.BooleanSupplier; -import org.graalvm.nativeimage.hosted.Feature; import org.graalvm.nativeimage.ImageSingletons; +import org.graalvm.nativeimage.hosted.Feature; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; import com.oracle.svm.truffle.TruffleBaseFeature; /** @@ -41,8 +42,8 @@ * re-implementations of the original NFI functions with the C interface of Substrate VM. If this * feature is enabled, the image is statically linked with libffi. */ -@AutomaticFeature -public final class TruffleNFIFeature implements Feature { +@AutomaticallyRegisteredFeature +public final class TruffleNFIFeature implements InternalFeature { public static class IsEnabled implements BooleanSupplier { @Override diff --git a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleBaseFeature.java b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleBaseFeature.java index 155c00cf0df7..afc447579914 100644 --- a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleBaseFeature.java +++ b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleBaseFeature.java @@ -47,6 +47,7 @@ import java.util.function.BiConsumer; import java.util.function.BooleanSupplier; +import com.oracle.svm.core.feature.InternalFeature; import org.graalvm.collections.Pair; import org.graalvm.compiler.api.replacements.SnippetReflectionProvider; import org.graalvm.compiler.nodes.ConstantNode; @@ -130,7 +131,7 @@ * {@link TruffleFeature}'s dependency), then {@link TruffleRuntime} must be set to the * {@link DefaultTruffleRuntime}. */ -public final class TruffleBaseFeature implements com.oracle.svm.core.graal.InternalFeature { +public final class TruffleBaseFeature implements InternalFeature { @Override public String getURL() { diff --git a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleFeature.java b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleFeature.java index 4f7905623725..e619ac2994e0 100644 --- a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleFeature.java +++ b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleFeature.java @@ -99,6 +99,7 @@ import java.util.function.UnaryOperator; import java.util.stream.Collectors; +import com.oracle.svm.core.feature.InternalFeature; import org.graalvm.compiler.api.replacements.SnippetReflectionProvider; import org.graalvm.compiler.core.phases.HighTier; import org.graalvm.compiler.graph.Node; @@ -175,7 +176,7 @@ * Feature that enables compilation of Truffle ASTs to machine code. This feature requires * {@link SubstrateTruffleRuntime} to be set as {@link TruffleRuntime}. */ -public class TruffleFeature implements com.oracle.svm.core.graal.InternalFeature { +public class TruffleFeature implements InternalFeature { @Override public String getURL() { diff --git a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleJFRFeature.java b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleJFRFeature.java index 380ef72631c9..815d60a45e78 100644 --- a/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleJFRFeature.java +++ b/substratevm/src/com.oracle.svm.truffle/src/com/oracle/svm/truffle/TruffleJFRFeature.java @@ -24,20 +24,21 @@ */ package com.oracle.svm.truffle; -import com.oracle.svm.core.annotate.AutomaticFeature; -import com.oracle.svm.core.jfr.JfrFeature; -import com.oracle.svm.core.util.UserError; +import java.util.Iterator; + import org.graalvm.compiler.serviceprovider.JavaVersionUtil; import org.graalvm.compiler.truffle.jfr.EventFactory; import org.graalvm.compiler.truffle.jfr.EventFactory.Provider; import org.graalvm.compiler.truffle.runtime.serviceprovider.TruffleRuntimeServices; import org.graalvm.nativeimage.ImageSingletons; -import org.graalvm.nativeimage.hosted.Feature; -import java.util.Iterator; +import com.oracle.svm.core.feature.InternalFeature; +import com.oracle.svm.core.jfr.JfrFeature; +import com.oracle.svm.core.feature.AutomaticallyRegisteredFeature; +import com.oracle.svm.core.util.UserError; -@AutomaticFeature -public class TruffleJFRFeature implements Feature { +@AutomaticallyRegisteredFeature +public class TruffleJFRFeature implements InternalFeature { @Override public void afterRegistration(AfterRegistrationAccess access) {