diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/Alias.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/Alias.java index 66c44189fad4..0932acadb3a1 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/Alias.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/Alias.java @@ -24,6 +24,9 @@ */ package com.oracle.svm.core.annotate; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -51,5 +54,6 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD}) +@Platforms(Platform.HOSTED_ONLY.class) public @interface Alias { } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/AlwaysInline.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/AlwaysInline.java index 1a18a4273399..9aa8fa67fe44 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/AlwaysInline.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/AlwaysInline.java @@ -24,6 +24,9 @@ */ package com.oracle.svm.core.annotate; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -34,6 +37,7 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) +@Platforms(Platform.HOSTED_ONLY.class) public @interface AlwaysInline { /** diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/AnnotateOriginal.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/AnnotateOriginal.java index 587d8db0ebfd..991e98ce5024 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/AnnotateOriginal.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/AnnotateOriginal.java @@ -24,6 +24,9 @@ */ package com.oracle.svm.core.annotate; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -38,5 +41,6 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) +@Platforms(Platform.HOSTED_ONLY.class) public @interface AnnotateOriginal { } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/AutomaticFeature.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/AutomaticFeature.java index 9709081eee07..05d56460ec8b 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/AutomaticFeature.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/AutomaticFeature.java @@ -24,6 +24,9 @@ */ package com.oracle.svm.core.annotate; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -35,5 +38,6 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) +@Platforms(Platform.HOSTED_ONLY.class) public @interface AutomaticFeature { } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/Delete.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/Delete.java index 4e74ca72cc7b..ee169e7ff883 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/Delete.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/Delete.java @@ -24,6 +24,9 @@ */ package com.oracle.svm.core.annotate; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -37,6 +40,7 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD}) +@Platforms(Platform.HOSTED_ONLY.class) public @interface Delete { /** diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/DeoptTest.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/DeoptTest.java index 1dd1498cc4bf..616702ebf08c 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/DeoptTest.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/DeoptTest.java @@ -24,6 +24,9 @@ */ package com.oracle.svm.core.annotate; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -37,6 +40,7 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) +@Platforms(Platform.HOSTED_ONLY.class) public @interface DeoptTest { } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/DuplicatedInNativeCode.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/DuplicatedInNativeCode.java index c77ad21c1e3c..45e59eb92684 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/DuplicatedInNativeCode.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/DuplicatedInNativeCode.java @@ -24,6 +24,9 @@ */ package com.oracle.svm.core.annotate; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -35,5 +38,6 @@ */ @Retention(RetentionPolicy.SOURCE) @Target(value = {ElementType.METHOD, ElementType.TYPE, ElementType.FIELD}) +@Platforms(Platform.HOSTED_ONLY.class) public @interface DuplicatedInNativeCode { } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/ExcludeFromReferenceMap.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/ExcludeFromReferenceMap.java index da6577e836b2..45ee23901502 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/ExcludeFromReferenceMap.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/ExcludeFromReferenceMap.java @@ -39,6 +39,7 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) +@Platforms(Platform.HOSTED_ONLY.class) public @interface ExcludeFromReferenceMap { /** diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/Inject.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/Inject.java index c90cfc5aa3a7..85f82ee56ca1 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/Inject.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/Inject.java @@ -24,6 +24,9 @@ */ package com.oracle.svm.core.annotate; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -38,5 +41,6 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) +@Platforms(Platform.HOSTED_ONLY.class) public @interface Inject { } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/InjectAccessors.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/InjectAccessors.java index 8b0ab371c183..457c7a0e4699 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/InjectAccessors.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/InjectAccessors.java @@ -24,6 +24,9 @@ */ package com.oracle.svm.core.annotate; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -57,6 +60,7 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) +@Platforms(Platform.HOSTED_ONLY.class) public @interface InjectAccessors { Class value(); diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/InvokeJavaFunctionPointer.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/InvokeJavaFunctionPointer.java index 06774e7fcef8..5a27cccce650 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/InvokeJavaFunctionPointer.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/InvokeJavaFunctionPointer.java @@ -29,6 +29,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; import org.graalvm.nativeimage.c.function.CFunctionPointer; /** @@ -38,5 +40,6 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD}) +@Platforms(Platform.HOSTED_ONLY.class) public @interface InvokeJavaFunctionPointer { } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/KeepOriginal.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/KeepOriginal.java index 06dc4b65373e..8768c98b277f 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/KeepOriginal.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/KeepOriginal.java @@ -24,6 +24,9 @@ */ package com.oracle.svm.core.annotate; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -41,5 +44,6 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD, ElementType.TYPE}) +@Platforms(Platform.HOSTED_ONLY.class) public @interface KeepOriginal { } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/NeverInlineTrivial.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/NeverInlineTrivial.java index bda1e3b5ebfa..ed5e211b2f24 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/NeverInlineTrivial.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/NeverInlineTrivial.java @@ -24,6 +24,9 @@ */ package com.oracle.svm.core.annotate; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -35,6 +38,7 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) +@Platforms(Platform.HOSTED_ONLY.class) public @interface NeverInlineTrivial { /** diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/RecomputeFieldValue.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/RecomputeFieldValue.java index c12b3bdcaf60..9c6b8574ac12 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/RecomputeFieldValue.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/RecomputeFieldValue.java @@ -34,6 +34,8 @@ import jdk.vm.ci.meta.MetaAccessProvider; import jdk.vm.ci.meta.ResolvedJavaField; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; /** * Mechanism to change the value of a field. Normally, field values in the native image heap of the @@ -45,6 +47,7 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) +@Platforms(Platform.HOSTED_ONLY.class) public @interface RecomputeFieldValue { enum Kind { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/RestrictHeapAccess.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/RestrictHeapAccess.java index 9aa51b6642a7..b885e493eba1 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/RestrictHeapAccess.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/RestrictHeapAccess.java @@ -24,6 +24,9 @@ */ package com.oracle.svm.core.annotate; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -35,6 +38,7 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD, ElementType.CONSTRUCTOR}) +@Platforms(Platform.HOSTED_ONLY.class) public @interface RestrictHeapAccess { enum Access { UNRESTRICTED, diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/Specialize.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/Specialize.java index e78a3999ef31..f3eb5cbf7956 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/Specialize.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/Specialize.java @@ -24,6 +24,9 @@ */ package com.oracle.svm.core.annotate; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -42,6 +45,7 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) +@Platforms(Platform.HOSTED_ONLY.class) public @interface Specialize { } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/StubCallingConvention.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/StubCallingConvention.java index 81a03e3c10f0..7e46df4033c1 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/StubCallingConvention.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/StubCallingConvention.java @@ -29,6 +29,8 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; import org.graalvm.util.GuardedAnnotationAccess; import com.oracle.svm.core.CalleeSavedRegisters; @@ -45,6 +47,7 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.METHOD) +@Platforms(Platform.HOSTED_ONLY.class) public @interface StubCallingConvention { class Utils { diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/Substitute.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/Substitute.java index 7d6aa5b3346e..ad28b219339f 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/Substitute.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/Substitute.java @@ -24,6 +24,9 @@ */ package com.oracle.svm.core.annotate; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -52,6 +55,7 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE, ElementType.FIELD}) +@Platforms(Platform.HOSTED_ONLY.class) public @interface Substitute { boolean polymorphicSignature() default false; } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/SubstituteTarget.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/SubstituteTarget.java index 32226c798206..e61645498b4b 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/SubstituteTarget.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/SubstituteTarget.java @@ -24,6 +24,9 @@ */ package com.oracle.svm.core.annotate; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -37,5 +40,6 @@ */ @Retention(RetentionPolicy.CLASS) @Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.TYPE, ElementType.FIELD}) +@Platforms(Platform.HOSTED_ONLY.class) public @interface SubstituteTarget { } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/TargetClass.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/TargetClass.java index ad15de9c662b..a4365a8bceda 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/TargetClass.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/TargetClass.java @@ -24,6 +24,9 @@ */ package com.oracle.svm.core.annotate; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -71,6 +74,7 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) +@Platforms(Platform.HOSTED_ONLY.class) public @interface TargetClass { /** diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/TargetElement.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/TargetElement.java index 378a0930a605..376d738041c9 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/TargetElement.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/TargetElement.java @@ -24,6 +24,9 @@ */ package com.oracle.svm.core.annotate; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -39,6 +42,7 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.FIELD}) +@Platforms(Platform.HOSTED_ONLY.class) public @interface TargetElement { String CONSTRUCTOR_NAME = ""; diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/UnknownClass.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/UnknownClass.java index 23e9e284c3e9..6c526ec5c4fe 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/UnknownClass.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/UnknownClass.java @@ -24,6 +24,9 @@ */ package com.oracle.svm.core.annotate; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -37,6 +40,7 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD, ElementType.TYPE}) +@Platforms(Platform.HOSTED_ONLY.class) public @interface UnknownClass { } diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/UnknownObjectField.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/UnknownObjectField.java index 0f2463895000..808a248410fe 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/UnknownObjectField.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/UnknownObjectField.java @@ -24,6 +24,9 @@ */ package com.oracle.svm.core.annotate; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -37,6 +40,7 @@ */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) +@Platforms(Platform.HOSTED_ONLY.class) public @interface UnknownObjectField { /** diff --git a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/UnknownPrimitiveField.java b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/UnknownPrimitiveField.java index ab8016aefc57..6e4c2f63b822 100644 --- a/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/UnknownPrimitiveField.java +++ b/substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/annotate/UnknownPrimitiveField.java @@ -24,6 +24,9 @@ */ package com.oracle.svm.core.annotate; +import org.graalvm.nativeimage.Platform; +import org.graalvm.nativeimage.Platforms; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -32,6 +35,7 @@ /** For fields with this annotation no static analysis is done. */ @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.FIELD) +@Platforms(Platform.HOSTED_ONLY.class) public @interface UnknownPrimitiveField { } diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/analysis/AnnotationsProcessor.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/analysis/AnnotationsProcessor.java index 4358e8ca8eeb..5d6265b5a49a 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/analysis/AnnotationsProcessor.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/analysis/AnnotationsProcessor.java @@ -34,6 +34,7 @@ import com.oracle.graal.pointsto.meta.AnalysisType; import com.oracle.graal.pointsto.util.AnalysisError; import com.oracle.svm.core.hub.AnnotationsEncoding; +import com.oracle.svm.hosted.substitute.SubstitutionReflectivityFilter; public class AnnotationsProcessor { @@ -46,6 +47,7 @@ public static Object encodeAnnotations(AnalysisMetaAccess metaAccess, Annotation Collections.addAll(all, allAnnotations); Collections.addAll(all, declaredAnnotations); final Set usedAnnotations = all.stream() + .filter(a -> !SubstitutionReflectivityFilter.shouldExclude(a.annotationType(), metaAccess, metaAccess.getUniverse())) .filter(a -> { try { AnalysisType annotationClass = metaAccess.lookupJavaType(a.getClass()); diff --git a/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/NoHostedAnnotationsTest.java b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/NoHostedAnnotationsTest.java new file mode 100644 index 000000000000..ea4e20e602cd --- /dev/null +++ b/substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/NoHostedAnnotationsTest.java @@ -0,0 +1,48 @@ +/* + * 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.test; + +import java.lang.annotation.Annotation; + +import org.junit.Assert; +import org.junit.Test; + +import com.oracle.svm.core.annotate.DuplicatedInNativeCode; + +public class NoHostedAnnotationsTest { + + @DuplicatedInNativeCode + private static class TestClass { + } + + @Test + public void test() { + // Checkstyle: allow direct annotation access + Annotation[] annotations = TestClass.class.getAnnotations(); + // Checkstyle: disallow direct annotation access + Assert.assertEquals("The hosted annotation is present in runtime!", 0, annotations.length); + } +}