---
title: "Fallback"
description: "A method annotated with Fallback is treated as a Specialization that implicitly links all the guards of all other declared Specialization annotated methods of the operation in a negated form."
kind: "annotation interface"
id: "com.oracle.truffle.api.dsl.Fallback"
module: "truffle-api"
version: "25.6.0-elide.4"
canonical: "https://graalvm.elide.help/25.6.0-elide.4/api/truffle-api/com/oracle/truffle/api/dsl/Fallback.html"
---

# @ Fallback

[truffle-api](../../../../../index.md) › [com.oracle.truffle.api.dsl](index.md) · Every page: [llms.txt](../../../../../llms.txt)

Annotation interface in [`com.oracle.truffle.api.dsl`](index.md). Since 0.8 or earlier.

```java
@Retention(CLASS)
@Target({METHOD})
public @interface Fallback
```

A method annotated with [`Fallback`](Fallback.md) is treated as a [`Specialization`](Specialization.md) that implicitly links all the guards of all other declared [`Specialization`](Specialization.md) annotated methods of the operation in a negated form. As a consequence it cannot declare any other guards. The expected signature of the method must match to the signature of a [`Specialization`](Specialization.md) with the additional limitation that only generically executable argument types are allowed. A generically executable argument is an argument that can be executed from the child [`Node`](../nodes/Node.md) using an execute method without [`UnsupportedOperationException`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/UnsupportedOperationException.html). In many cases the generically executable type is [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html). An operation is limited to just one [`Fallback`](Fallback.md) specialization which is always ordered at the end of the specialization chain.

A simple example showing the use of the [`Fallback`](Fallback.md) annotation in a DSL operation:

```java
@Specialization int doInt(int a) {..}
@Specialization int doDouble(double a) {..}
@Fallback int orElse(Object a) {..}
```

The previous example could be redeclared just using [`Specialization`](Specialization.md) annotated methods as follows:

```java
@Specialization int doInt(int a) {..}
@Specialization int doDouble(double a) {..}
@Specialization(guard={"!isInt(a)", "!isDouble(a)"})
int orElse(Object a) {..}
```

**Performance note:** For operations with a lot of [`Specialization`](Specialization.md) annotated methods the use of [`Fallback`](Fallback.md) might generate a guard that is very big. Try to avoid the use of [`Fallback`](Fallback.md) for specializations that are significantly important for peak performance.

Fallback annotated methods support [`Cached`](Cached.md), [`Bind`](Bind.md) and dispatched [`com.oracle.truffle.api.library.CachedLibrary`](../library/CachedLibrary.md).

**See also**

- [`Specialization`](Specialization.md)
- [`NodeChild`](NodeChild.md)
