|
| 1 | +package org.graalvm.nativeimage.hosted; |
| 2 | + |
| 3 | +import java.lang.reflect.Executable; |
| 4 | +import java.lang.reflect.Field; |
| 5 | + |
| 6 | +/** |
| 7 | + * This class is used to register classes, methods, fields for reflection, serialization and JNI |
| 8 | + * access at runtime. |
| 9 | + * |
| 10 | + * It should only be used at {@link Feature#afterRegistration}. |
| 11 | + */ |
| 12 | +public interface ReflectionDynamicAccess { |
| 13 | + |
| 14 | + /** |
| 15 | + * Makes the provided classes available for reflection at runtime and all of their accessible |
| 16 | + * members available for reflection queries at run time. A call to {@link Class#forName} for the |
| 17 | + * names of the classes will return the classes at run time. |
| 18 | + * |
| 19 | + * @param condition needs to be satisfied for inclusion of types for reflection at runtime |
| 20 | + */ |
| 21 | + void register(InclusionCondition condition, Class<?>... classes); |
| 22 | + |
| 23 | + /** |
| 24 | + * Makes the provided class available for reflection at runtime if {@code condition} is |
| 25 | + * satisfied. A call to {@link Class#forName} for the name of the class will return the class |
| 26 | + * (if it exists) or a {@link ClassNotFoundException} at run time. |
| 27 | + */ |
| 28 | + void registerClassLookup(InclusionCondition condition, String className); |
| 29 | + |
| 30 | + /** |
| 31 | + * Makes the provided methods available for reflection at runtime if {@code condition} is |
| 32 | + * satisfied. The methods will be returned by {@link Class#getMethod}, |
| 33 | + * {@link Class#getDeclaredMethod(String, Class[])}, and all the other methods on {@link Class} |
| 34 | + * that return a single method. |
| 35 | + */ |
| 36 | + void register(InclusionCondition condition, Executable... methods); |
| 37 | + |
| 38 | + void register(InclusionCondition condition, Field... fields); |
| 39 | + |
| 40 | + /** |
| 41 | + * Makes the provided classes available for serialization and reflection at runtime if |
| 42 | + * {@code condition} is satisfied. |
| 43 | + */ |
| 44 | + void registerForSerialization(InclusionCondition condition, Class<?>... classes); |
| 45 | + |
| 46 | + /** |
| 47 | + * Makes the provided classes available for JNI access at runtime if {@code condition} is |
| 48 | + * satisfied. Needed when native code looks up Java classes via <a href= |
| 49 | + * "https://docs.oracle.com/en/java/javase/17/docs/specs/jni/functions.html#findclass">FindClass</a>. |
| 50 | + */ |
| 51 | + void registerForJNIAccess(InclusionCondition condition, Class<?>... classes); |
| 52 | + |
| 53 | + /** |
| 54 | + * Makes the provided methods available for JNI access at runtime if {@code condition} is |
| 55 | + * satisfied. Needed when native code looks up Java methods via <a href= |
| 56 | + * "https://docs.oracle.com/en/java/javase/17/docs/specs/jni/functions.html#getmethodid">GetMethodID</a> |
| 57 | + * or <a href= |
| 58 | + * "https://docs.oracle.com/en/java/javase/17/docs/specs/jni/functions.html#getstaticmethodid">GetStaticMethodID</a>. |
| 59 | + */ |
| 60 | + void registerForJNIAccess(InclusionCondition condition, Executable... methods); |
| 61 | + |
| 62 | + /** |
| 63 | + * Makes the provided methods available for JNI access at runtime if {@code condition} is |
| 64 | + * satisfied. Needed when native code looks up Java methods via <a href= |
| 65 | + * "https://docs.oracle.com/en/java/javase/17/docs/specs/jni/functions.html#getmethodid">GetMethodID</a> |
| 66 | + * or <a href= |
| 67 | + * "https://docs.oracle.com/en/java/javase/17/docs/specs/jni/functions.html#getstaticmethodid">GetStaticMethodID</a>. |
| 68 | + */ |
| 69 | + void registerForJNIAccess(InclusionCondition condition, Field... fields); |
| 70 | +} |
0 commit comments