---
title: "NFIState"
description: "Thread-local state of the NFI that is shared between different backends."
kind: "class"
id: "com.oracle.truffle.nfi.backend.spi.NFIState"
module: "truffle-nfi"
version: "25.6.0-elide.4"
canonical: "https://graalvm.elide.help/25.6.0-elide.4/api/truffle-nfi/com/oracle/truffle/nfi/backend/spi/NFIState.html"
---

# ◆ NFIState

[truffle-nfi](../../../../../../index.md) › [com.oracle.truffle.nfi.backend.spi](index.md) · Every page: [llms.txt](../../../../../../llms.txt)

Class in [`com.oracle.truffle.nfi.backend.spi`](index.md).

```java
public final class NFIState
```

Inheritance: [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html) > `NFIState`

Thread-local state of the NFI that is shared between different backends. All methods should only be called from the corresponding thread to which this state belongs (for thread-safety reasons and because the SVM NFI backend relies on it by using a FastThreadLocalBytes for the errno pointer, which means the errno pointer points inside the IsolateThread), except the constructor and [`dispose()`](NFIState.md#dispose%28%29) which may be called from another thread, as Truffle hooks which call those are not guaranteed to be called from the corresponding thread.

## Constructors

### NFIState(Thread)
<a id="&lt;init&gt;(java.lang.Thread)"></a>`public NFIState(Thread thread)`. Cite: `com/oracle/truffle/nfi/backend/spi/NFIState.html#<init>(java.lang.Thread)`

## Methods

### getNFIErrno()
<a id="getNFIErrno()"></a>`public int getNFIErrno()`. Cite: `com/oracle/truffle/nfi/backend/spi/NFIState.html#getNFIErrno()`

### setNFIErrno(int)
<a id="setNFIErrno(int)"></a>`public void setNFIErrno(int nfiErrno)`. Cite: `com/oracle/truffle/nfi/backend/spi/NFIState.html#setNFIErrno(int)`

### getPendingException()
<a id="getPendingException()"></a>`public Throwable getPendingException()`. Cite: `com/oracle/truffle/nfi/backend/spi/NFIState.html#getPendingException()`

### setPendingException(Throwable)
<a id="setPendingException(java.lang.Throwable)"></a>`public void setPendingException(Throwable t)`. Cite: `com/oracle/truffle/nfi/backend/spi/NFIState.html#setPendingException(java.lang.Throwable)`

### clearPendingException()
<a id="clearPendingException()"></a>`public void clearPendingException()`. Cite: `com/oracle/truffle/nfi/backend/spi/NFIState.html#clearPendingException()`

### savePendingException()
<a id="savePendingException()"></a>`public Throwable savePendingException()`. Since 25.6. Saves and clears the pending exception so an upcall and its nested calls see a clean state. Pair this with `restorePendingException(Throwable)` in a `finally` block. Returns `Throwable`: the previous pending exception, or `null`. Cite: `com/oracle/truffle/nfi/backend/spi/NFIState.html#savePendingException()`

### restorePendingException(Throwable)
<a id="restorePendingException(java.lang.Throwable)"></a>`public void restorePendingException(Throwable saved)`. Since 25.6. Restores a non-null saved exception, replacing any exception produced by the upcall. If `saved` is `null`, leaves the current pending exception untouched so a new exception can propagate to the enclosing downcall. Parameters: `saved` `Throwable`: the exception returned by `savePendingException()`. Cite: `com/oracle/truffle/nfi/backend/spi/NFIState.html#restorePendingException(java.lang.Throwable)`

### dispose()
<a id="dispose()"></a>`public void dispose()`. Cite: `com/oracle/truffle/nfi/backend/spi/NFIState.html#dispose()`

## Inherited members

- From class [`Object`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html): [`clone`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#clone%28%29), [`equals`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#equals%28java.lang.Object%29), [`finalize`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#finalize%28%29), [`getClass`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#getClass%28%29), [`hashCode`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#hashCode%28%29), [`notify`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notify%28%29), [`notifyAll`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#notifyAll%28%29), [`toString`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#toString%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long%29), [`wait`](https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/lang/Object.html#wait%28long,int%29)
