Package com.oracle.svm.core.annotate
Annotation Interface TargetClass
A class annotated with this annotation denotes a class that modifies methods of fields of another
class, called the "original" class. The original class is specified using annotation parameters:
value()
or className()
specify the original class either as a class literal or by
name, while classNameProvider()
is the most flexible approach where the class name is
computed by user code. Optionally, inner classes can be specified using the innerClass()
property.
Based on additional annotations, the original class is modified in different ways:
- None of
Delete
orSubstitute
: the annotated class is an alias for the original class. This is the most frequently used case. All methods and fields of the annotated class must be annotated too:Alias
: The annotated method or field is an alias for the original element, i.e., the annotated element does not exist at run time. All usages of the annotated element reference the original element. For fields, the original field can be further modified using theRecomputeFieldValue
andInjectAccessors
annotations (see the documentation of the annotations for details).Delete
: The annotated method or field, as well as the original element, do not exist. Any usage of them will be reported as an error.Substitute
: The annotated method replaces the original method.AnnotateOriginal
: The original method remains mostly unchanged, but with one exception: all annotations on the annotated method are also present on the original method.
Delete
: The annotated class, as well as the original class, do not exist. Any usage of them will be reported as an error.Substitute
: The annotated class replaces the original class. All fields and methods of the original class are per default treated as deleted, i.e., any usage of them will be reported as an error, with the following exception: A method annotated withSubstitute
replaces the original method, i.e., calls to the original method now call the annotated method; a method annotated withKeepOriginal
keeps the original method, i.e., calls to the original method still call the original method.
- Since:
- 22.3
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
The default value for theonlyWith()
attribute.static interface
Marker value forclassLoader()
that no custom classloader should be used.static interface
Marker value forclassNameProvider()
that no class name provider should be used. -
Optional Element Summary
Modifier and TypeOptional ElementDescriptionClass
<? extends Supplier<ClassLoader>> Specifies a custom classloader that will be used to look up the substitutee class name.Specifies the substitutee class using a class-name string.Class
<? extends Function<TargetClass, String>> Specifies the substitutee class.String[]
Specifies the suffix of the substitutee class name when it is an inner class.Class<?>[]
Substitute only if all provided predicates are true (default: unconditional substitution that is always included).Class
<?> Specifies the substitutee class using a class literal.
-
Element Details
-
value
Class<?> valueSpecifies the substitutee class using a class literal. Eithervalue()
,className()
orclassNameProvider()
element can be used to specify the substitutee class.- Since:
- 22.3
- Default:
com.oracle.svm.core.annotate.TargetClass.class
-
className
String classNameSpecifies the substitutee class using a class-name string. This method is provided for cases where the substitutee class is not accessible (according to Java language access control rules). Eithervalue()
,className()
orclassNameProvider()
element can be used to specify the substitutee class.- Since:
- 22.3
- Default:
""
-
classNameProvider
Class<? extends Function<TargetClass,String>> classNameProviderSpecifies the substitutee class. This is the most flexible version to provide the class name to specify which class should be substituted. TheFunction.apply(T)
method of the provided class can compute the class name based on system properties (like the JDK version). This annotation is the argument of the function, so the function can, e.g., build a class name that incorporates theclassName()
property. Eithervalue()
,className()
orclassNameProvider()
element can be used to specify the substitutee class.- Since:
- 22.3
- Default:
com.oracle.svm.core.annotate.TargetClass.NoClassNameProvider.class
-
innerClass
String[] innerClassSpecifies the suffix of the substitutee class name when it is an inner class.- Since:
- 22.3
- Default:
{}
-
classLoader
Class<? extends Supplier<ClassLoader>> classLoaderSpecifies a custom classloader that will be used to look up the substitutee class name.- Since:
- 24.2
- Default:
com.oracle.svm.core.annotate.TargetClass.NoClassLoaderProvider.class
-
onlyWith
Class<?>[] onlyWithSubstitute only if all provided predicates are true (default: unconditional substitution that is always included). The classes must either implementBooleanSupplier
orPredicate
<String> (the parameter forPredicate.test(T)
is the "original" class name as aString
).- Since:
- 22.3
- Default:
{com.oracle.svm.core.annotate.TargetClass.AlwaysIncluded.class}
-