---
title: "TargetClass"
description: "A class annotated with this annotation denotes a class that modifies methods of fields of another class, called the \"original\" class."
kind: "annotation interface"
id: "com.oracle.svm.core.annotate.TargetClass"
module: "nativeimage"
version: "25.6.0-elide.4"
canonical: "https://graalvm.elide.help/25.6.0-elide.4/api/nativeimage/com/oracle/svm/core/annotate/TargetClass.html"
---

# @ TargetClass

[nativeimage](../../../../../index.md) › [com.oracle.svm.core.annotate](index.md) · Every page: [llms.txt](../../../../../llms.txt)

Annotation interface in [`com.oracle.svm.core.annotate`](index.md). Since 22.3.

```java
@Retention(RUNTIME)
@Target({TYPE})
public @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`](TargetClass.md#value%28%29) or [`className`](TargetClass.md#className%28%29) specify the original class either as a class literal or by name, while [`classNameProvider`](TargetClass.md#classNameProvider%28%29) is the most flexible approach where the class name is computed by user code. Optionally, inner classes can be specified using the [`innerClass`](TargetClass.md#innerClass%28%29) property. Based on additional annotations, the original class is modified in different ways:

- None of [`Delete`](Delete.md) or [`Substitute`](Substitute.md): 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`](Alias.md): 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 the [`RecomputeFieldValue`](RecomputeFieldValue.md) and [`InjectAccessors`](InjectAccessors.md) annotations (see the documentation of the annotations for details).
  - [`Delete`](Delete.md): 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`](Substitute.md): The annotated method replaces the original method.
  - [`AnnotateOriginal`](AnnotateOriginal.md): The original method remains mostly unchanged, but with one exception: all annotations on the annotated method are also present on the original method.
- [`Delete`](Delete.md): The annotated class, as well as the original class, do not exist. Any usage of them will be reported as an error.
- [`Substitute`](Substitute.md): 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 with [`Substitute`](Substitute.md) replaces the original method, i.e., calls to the original method now call the annotated method; a method annotated with [`KeepOriginal`](KeepOriginal.md) keeps the original method, i.e., calls to the original method still call the original method.

## Nested types

- [`TargetClass.AlwaysIncluded`](TargetClass.AlwaysIncluded.md) (class): The default value for the TargetClass.onlyWith() attribute.
- [`TargetClass.NoClassNameProvider`](TargetClass.NoClassNameProvider.md) (interface): Marker value for classNameProvider that no class name provider should be used.

## Elements

### value()
<a id="value()"></a>`Class<?> value() default com.oracle.svm.core.annotate.TargetClass.class`. Since 22.3. Specifies the substitutee class using a class literal. Either `value()`, `className()` or `classNameProvider()` element can be used to specify the substitutee class. Default: `com.oracle.svm.core.annotate.TargetClass.class`. Cite: `com/oracle/svm/core/annotate/TargetClass.html#value()`

### className()
<a id="className()"></a>`String className() default ""`. Since 22.3. Specifies 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). Either `value()`, `className()` or `classNameProvider()` element can be used to specify the substitutee class. Default: `""`. Cite: `com/oracle/svm/core/annotate/TargetClass.html#className()`

### classNameProvider()
<a id="classNameProvider()"></a>`Class<? extends Function<TargetClass, String>> classNameProvider() default com.oracle.svm.core.annotate.TargetClass.NoClassNameProvider.class`. Since 22.3. Specifies the substitutee class. This is the most flexible version to provide the class name to specify which class should be substituted. The [`Function.apply`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Function.html#apply%28T%29) 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 the `className()` property. Either `value()`, `className()` or `classNameProvider()` element can be used to specify the substitutee class. Default: `com.oracle.svm.core.annotate.TargetClass.NoClassNameProvider.class`. Cite: `com/oracle/svm/core/annotate/TargetClass.html#classNameProvider()`

### innerClass()
<a id="innerClass()"></a>`String[] innerClass() default {}`. Since 22.3. Specifies the suffix of the substitutee class name when it is an inner class. Default: `{}`. Cite: `com/oracle/svm/core/annotate/TargetClass.html#innerClass()`

### onlyWith()
<a id="onlyWith()"></a>`Class<?>[] onlyWith() default {com.oracle.svm.core.annotate.TargetClass.AlwaysIncluded.class}`. Since 22.3. Substitute only if all provided predicates are true (default: unconditional substitution that is always included). The classes must either implement [`BooleanSupplier`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/BooleanSupplier.html) or [`Predicate`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Predicate.html)\<String\> (the parameter for [`Predicate.test`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/util/function/Predicate.html#test%28T%29) is the "original" class name as a [`String`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/String.html)). Default: `{com.oracle.svm.core.annotate.TargetClass.AlwaysIncluded.class}`. Cite: `com/oracle/svm/core/annotate/TargetClass.html#onlyWith()`
