---
title: "Alias"
description: "Mechanism for referring to fields and methods otherwise inaccessible due to Java language access control rules."
kind: "annotation interface"
id: "com.oracle.svm.core.annotate.Alias"
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/Alias.html"
---

# @ Alias

[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({METHOD, CONSTRUCTOR, FIELD})
public @interface Alias
```

Mechanism for referring to fields and methods otherwise inaccessible due to Java language access control rules. This enables VM code to directly access a private field or invoke a private method in a JDK class without using reflection. Aliases avoid the boxing/unboxing required by reflection and they type check an aliased field access or method invocation statically.

The idiom for using [`Alias`](Alias.md) is somewhat related to the [`Substitute`](Substitute.md) annotation, but reversed; both are often used in combination. In both cases a separate class is used to declare the aliased and/or substituted methods. In the substitution case occurrences of `this` actually refer to the instance of the class being substituted. In the aliased case we pretend that the class declaring the aliased method or field is an instance of the aliasee in order to access its fields or invoke its methods. An alias is always called (method alias) or accessed (field alias), whereas a substitution method is only implemented (usually not called directly). In the body of a substitution method, aliases are often called or accessed.

The element can also be annotated with [`TargetElement`](TargetElement.md) to specify additional properties. See [`TargetClass`](TargetClass.md) for an overview of the annotation system.

When aliasing \*non-static\* inner classes the constructors are passed a hidden argument which is the outer class. When writing an @Alias for a constructor of a \*non-static\* inner classes, you have to (a) explicitly declare that parameter, and (b) supply it in the calls.
