50
50
import org .graalvm .nativeimage .Platforms ;
51
51
import org .graalvm .nativeimage .dynamicaccess .ReflectiveAccess ;
52
52
import org .graalvm .nativeimage .dynamicaccess .AccessCondition ;
53
+ import org .graalvm .nativeimage .impl .APIDeprecationSupport ;
53
54
import org .graalvm .nativeimage .impl .RuntimeReflectionSupport ;
54
55
55
56
//Checkstyle: allow reflection
63
64
@ Platforms (Platform .HOSTED_ONLY .class )
64
65
public final class RuntimeReflection {
65
66
67
+ private static final APIDeprecationSupport deprecationFlag = ImageSingletons .lookup (APIDeprecationSupport .class );
68
+
66
69
/**
67
70
* Makes the provided classes available for reflection at run time. A call to
68
71
* {@link Class#forName} for the names of the classes will return the classes at run time.
@@ -72,6 +75,7 @@ public final class RuntimeReflection {
72
75
* @since 19.0
73
76
*/
74
77
public static void register (Class <?>... classes ) {
78
+ deprecationFlag .printDeprecationWarning ();
75
79
ImageSingletons .lookup (RuntimeReflectionSupport .class ).register (AccessCondition .unconditional (), classes );
76
80
}
77
81
@@ -85,6 +89,7 @@ public static void register(Class<?>... classes) {
85
89
* @since 23.0
86
90
*/
87
91
public static void registerClassLookup (String className ) {
92
+ deprecationFlag .printDeprecationWarning ();
88
93
ImageSingletons .lookup (RuntimeReflectionSupport .class ).registerClassLookup (AccessCondition .unconditional (), className );
89
94
}
90
95
@@ -98,6 +103,7 @@ public static void registerClassLookup(String className) {
98
103
* @since 19.0
99
104
*/
100
105
public static void register (Executable ... methods ) {
106
+ deprecationFlag .printDeprecationWarning ();
101
107
ImageSingletons .lookup (RuntimeReflectionSupport .class ).register (AccessCondition .unconditional (), false , methods );
102
108
}
103
109
@@ -112,6 +118,7 @@ public static void register(Executable... methods) {
112
118
* @since 21.3
113
119
*/
114
120
public static void registerAsQueried (Executable ... methods ) {
121
+ deprecationFlag .printDeprecationWarning ();
115
122
ImageSingletons .lookup (RuntimeReflectionSupport .class ).register (AccessCondition .unconditional (), true , methods );
116
123
}
117
124
@@ -127,6 +134,7 @@ public static void registerAsQueried(Executable... methods) {
127
134
* @since 23.0
128
135
*/
129
136
public static void registerMethodLookup (Class <?> declaringClass , String methodName , Class <?>... parameterTypes ) {
137
+ deprecationFlag .printDeprecationWarning ();
130
138
ImageSingletons .lookup (RuntimeReflectionSupport .class ).registerMethodLookup (AccessCondition .unconditional (), declaringClass , methodName , parameterTypes );
131
139
}
132
140
@@ -143,6 +151,7 @@ public static void registerMethodLookup(Class<?> declaringClass, String methodNa
143
151
* @since 23.0
144
152
*/
145
153
public static void registerConstructorLookup (Class <?> declaringClass , Class <?>... parameterTypes ) {
154
+ deprecationFlag .printDeprecationWarning ();
146
155
ImageSingletons .lookup (RuntimeReflectionSupport .class ).registerConstructorLookup (AccessCondition .unconditional (), declaringClass , parameterTypes );
147
156
}
148
157
@@ -156,6 +165,7 @@ public static void registerConstructorLookup(Class<?> declaringClass, Class<?>..
156
165
* @since 19.0
157
166
*/
158
167
public static void register (Field ... fields ) {
168
+ deprecationFlag .printDeprecationWarning ();
159
169
ImageSingletons .lookup (RuntimeReflectionSupport .class ).register (AccessCondition .unconditional (), false , fields );
160
170
}
161
171
@@ -170,6 +180,7 @@ public static void register(Field... fields) {
170
180
* @since 19.0
171
181
*/
172
182
public static void registerFieldLookup (Class <?> declaringClass , String fieldName ) {
183
+ deprecationFlag .printDeprecationWarning ();
173
184
ImageSingletons .lookup (RuntimeReflectionSupport .class ).registerFieldLookup (AccessCondition .unconditional (), declaringClass , fieldName );
174
185
}
175
186
@@ -181,6 +192,7 @@ public static void registerFieldLookup(Class<?> declaringClass, String fieldName
181
192
* @since 23.0
182
193
*/
183
194
public static void registerAllClasses (Class <?> declaringClass ) {
195
+ deprecationFlag .printDeprecationWarning ();
184
196
ImageSingletons .lookup (RuntimeReflectionSupport .class ).registerAllClassesQuery (AccessCondition .unconditional (), declaringClass );
185
197
}
186
198
@@ -192,6 +204,7 @@ public static void registerAllClasses(Class<?> declaringClass) {
192
204
* @since 23.0
193
205
*/
194
206
public static void registerAllDeclaredClasses (Class <?> declaringClass ) {
207
+ deprecationFlag .printDeprecationWarning ();
195
208
ImageSingletons .lookup (RuntimeReflectionSupport .class ).registerAllDeclaredClassesQuery (AccessCondition .unconditional (), declaringClass );
196
209
}
197
210
@@ -204,6 +217,7 @@ public static void registerAllDeclaredClasses(Class<?> declaringClass) {
204
217
* @since 23.0
205
218
*/
206
219
public static void registerAllMethods (Class <?> declaringClass ) {
220
+ deprecationFlag .printDeprecationWarning ();
207
221
ImageSingletons .lookup (RuntimeReflectionSupport .class ).registerAllMethodsQuery (AccessCondition .unconditional (), true , declaringClass );
208
222
}
209
223
@@ -216,6 +230,7 @@ public static void registerAllMethods(Class<?> declaringClass) {
216
230
* @since 23.0
217
231
*/
218
232
public static void registerAllDeclaredMethods (Class <?> declaringClass ) {
233
+ deprecationFlag .printDeprecationWarning ();
219
234
ImageSingletons .lookup (RuntimeReflectionSupport .class ).registerAllDeclaredMethodsQuery (AccessCondition .unconditional (), true , declaringClass );
220
235
}
221
236
@@ -228,6 +243,7 @@ public static void registerAllDeclaredMethods(Class<?> declaringClass) {
228
243
* @since 23.0
229
244
*/
230
245
public static void registerAllConstructors (Class <?> declaringClass ) {
246
+ deprecationFlag .printDeprecationWarning ();
231
247
ImageSingletons .lookup (RuntimeReflectionSupport .class ).registerAllConstructorsQuery (AccessCondition .unconditional (), true , declaringClass );
232
248
}
233
249
@@ -240,6 +256,7 @@ public static void registerAllConstructors(Class<?> declaringClass) {
240
256
* @since 23.0
241
257
*/
242
258
public static void registerAllDeclaredConstructors (Class <?> declaringClass ) {
259
+ deprecationFlag .printDeprecationWarning ();
243
260
ImageSingletons .lookup (RuntimeReflectionSupport .class ).registerAllDeclaredConstructorsQuery (AccessCondition .unconditional (), true , declaringClass );
244
261
}
245
262
@@ -252,6 +269,7 @@ public static void registerAllDeclaredConstructors(Class<?> declaringClass) {
252
269
* @since 23.0
253
270
*/
254
271
public static void registerAllFields (Class <?> declaringClass ) {
272
+ deprecationFlag .printDeprecationWarning ();
255
273
ImageSingletons .lookup (RuntimeReflectionSupport .class ).registerAllFields (AccessCondition .unconditional (), declaringClass );
256
274
}
257
275
@@ -264,6 +282,7 @@ public static void registerAllFields(Class<?> declaringClass) {
264
282
* @since 23.0
265
283
*/
266
284
public static void registerAllDeclaredFields (Class <?> declaringClass ) {
285
+ deprecationFlag .printDeprecationWarning ();
267
286
ImageSingletons .lookup (RuntimeReflectionSupport .class ).registerAllDeclaredFields (AccessCondition .unconditional (), declaringClass );
268
287
}
269
288
@@ -275,6 +294,7 @@ public static void registerAllDeclaredFields(Class<?> declaringClass) {
275
294
* @since 23.0
276
295
*/
277
296
public static void registerAllNestMembers (Class <?> declaringClass ) {
297
+ deprecationFlag .printDeprecationWarning ();
278
298
ImageSingletons .lookup (RuntimeReflectionSupport .class ).registerAllNestMembersQuery (AccessCondition .unconditional (), declaringClass );
279
299
}
280
300
@@ -286,6 +306,7 @@ public static void registerAllNestMembers(Class<?> declaringClass) {
286
306
* @since 23.0
287
307
*/
288
308
public static void registerAllPermittedSubclasses (Class <?> declaringClass ) {
309
+ deprecationFlag .printDeprecationWarning ();
289
310
ImageSingletons .lookup (RuntimeReflectionSupport .class ).registerAllPermittedSubclassesQuery (AccessCondition .unconditional (), declaringClass );
290
311
}
291
312
@@ -297,6 +318,7 @@ public static void registerAllPermittedSubclasses(Class<?> declaringClass) {
297
318
* @since 23.0
298
319
*/
299
320
public static void registerAllRecordComponents (Class <?> declaringClass ) {
321
+ deprecationFlag .printDeprecationWarning ();
300
322
ImageSingletons .lookup (RuntimeReflectionSupport .class ).registerAllRecordComponentsQuery (AccessCondition .unconditional (), declaringClass );
301
323
}
302
324
@@ -308,6 +330,7 @@ public static void registerAllRecordComponents(Class<?> declaringClass) {
308
330
* @since 23.0
309
331
*/
310
332
public static void registerAllSigners (Class <?> declaringClass ) {
333
+ deprecationFlag .printDeprecationWarning ();
311
334
ImageSingletons .lookup (RuntimeReflectionSupport .class ).registerAllSignersQuery (AccessCondition .unconditional (), declaringClass );
312
335
}
313
336
@@ -343,6 +366,7 @@ public static void register(boolean finalIsWritable, boolean allowUnsafeAccess,
343
366
* @since 19.0
344
367
*/
345
368
public static void registerForReflectiveInstantiation (Class <?>... classes ) {
369
+ deprecationFlag .printDeprecationWarning ();
346
370
for (Class <?> clazz : classes ) {
347
371
if (clazz .isArray () || clazz .isInterface () || Modifier .isAbstract (clazz .getModifiers ())) {
348
372
throw new IllegalArgumentException ("Class " + clazz .getTypeName () + " cannot be instantiated reflectively. It must be a non-abstract instance type." );
0 commit comments