4747import org .graalvm .nativeimage .Platform ;
4848import org .graalvm .nativeimage .Platforms ;
4949import org .graalvm .nativeimage .dynamicaccess .ForeignAccess ;
50+ import org .graalvm .nativeimage .impl .APIDeprecationSupport ;
5051import org .graalvm .nativeimage .dynamicaccess .AccessCondition ;
5152import org .graalvm .nativeimage .impl .RuntimeForeignAccessSupport ;
5253
5354@ Platforms (Platform .HOSTED_ONLY .class )
5455public final class RuntimeForeignAccess {
5556
57+ private static final APIDeprecationSupport deprecationFlag = ImageSingletons .lookup (APIDeprecationSupport .class );
58+
5659 /**
5760 * Registers the provided function descriptor and options pair at image build time for downcalls
5861 * into foreign code. Required to get a downcall method handle using
@@ -63,14 +66,15 @@ public final class RuntimeForeignAccess {
6366 * performed to ensure that the arguments have the expected type. It will be deprecated in favor
6467 * of strongly typed variant as soon as possible.
6568 * <p>
66- * This API is deprecated; use {@link ForeignAccess} instead.
69+ * This API is deprecated; use the {@link ForeignAccess} instead.
6770 *
6871 * @param desc A {@link java.lang.foreign.FunctionDescriptor} to register for downcalls.
6972 * @param options An array of {@link java.lang.foreign.Linker.Option} used for the downcalls.
7073 *
7174 * @since 23.1
7275 */
7376 public static void registerForDowncall (Object desc , Object ... options ) {
77+ deprecationFlag .printDeprecationWarning ();
7478 ImageSingletons .lookup (RuntimeForeignAccessSupport .class ).registerForDowncall (AccessCondition .unconditional (), desc , options );
7579 }
7680
@@ -83,14 +87,15 @@ public static void registerForDowncall(Object desc, Object... options) {
8387 * performed to ensure that the arguments have the expected type. It will be deprecated in favor
8488 * of strongly typed variant as soon as possible.
8589 * <p>
86- * This API is deprecated; use {@link ForeignAccess} instead.
90+ * This API is deprecated; use the {@link ForeignAccess} instead.
8791 *
8892 * @param desc A {@link java.lang.foreign.FunctionDescriptor} to register for upcalls.
8993 * @param options An array of {@link java.lang.foreign.Linker.Option} used for the upcalls.
9094 *
9195 * @since 24.1
9296 */
9397 public static void registerForUpcall (Object desc , Object ... options ) {
98+ deprecationFlag .printDeprecationWarning ();
9499 ImageSingletons .lookup (RuntimeForeignAccessSupport .class ).registerForUpcall (AccessCondition .unconditional (), desc , options );
95100 }
96101
@@ -112,7 +117,7 @@ public static void registerForUpcall(Object desc, Object... options) {
112117 * of strongly typed variant as soon as possible.
113118 * </p>
114119 * <p>
115- * This API is deprecated; use {@link ForeignAccess} instead.
120+ * This API is deprecated; use the {@link ForeignAccess} instead.
116121 *
117122 * @param target A direct method handle denoting a static method.
118123 * @param desc A {@link java.lang.foreign.FunctionDescriptor} to register for upcalls.
@@ -121,6 +126,7 @@ public static void registerForUpcall(Object desc, Object... options) {
121126 * @since 24.2
122127 */
123128 public static void registerForDirectUpcall (MethodHandle target , Object desc , Object ... options ) {
129+ deprecationFlag .printDeprecationWarning ();
124130 ImageSingletons .lookup (RuntimeForeignAccessSupport .class ).registerForDirectUpcall (AccessCondition .unconditional (), target , desc , options );
125131 }
126132
0 commit comments