Top Description Fields Constructors Methods
org.graalvm.jniutils

public Class JNIMethodScope

extends Object
implements AutoCloseable
Class Inheritance
All Implemented Interfaces
java.lang.AutoCloseable
Static Imports
org.graalvm.jniutils.JNIUtil.getFeatureName

Scope of a call from HotSpot to native method. This also provides access to the JNIEnv value for the current thread within the native method call. If the native method call returns a non-primitive value, the return value must be set within the try-with-resources statement and then retrieved and returned outside the try-with-resources statement. This is necessary to support use of JNI local frames.

Field Summary

Modifier and TypeField and Description
private final JNI.JNIEnv
private JNIMethodScope
pack-priv HSObject
locals

List of scope local HSObjects that created within this scope.

private JNI.JObject
objResult

Used to copy the handle to an object return value out of the JNI local frame.

private final JNIMethodScope
private final String
scopeName

The name for this scope.

private static final ThreadLocal<JNIMethodScope>

Constructor Summary

AccessConstructor and Description
public
JNIMethodScope(String scopeName, JNI.JNIEnv env)

Enters the scope of an native method call.

Method Summary

Modifier and TypeMethod and Description
public void
close()

Implements java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.

public final int
public static JNI.JNIEnv
env()

Gets the JNIEnv value for the current thread.

public JNI.JNIEnv
public <R extends JNI.JObject> R
public static JNIMethodScope
scope()

Gets the inner most JNIMethodScope value for the current thread.

public static JNIMethodScope
scopeOrNull()

Gets the inner most JNIMethodScope value for the current thread.

public void
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

envback to summary
private final JNI.JNIEnv env
leafback to summary
private JNIMethodScope leaf
localsback to summary
pack-priv HSObject locals

List of scope local HSObjects that created within this scope. These are invalidated when the scope closes.

objResultback to summary
private JNI.JObject objResult

Used to copy the handle to an object return value out of the JNI local frame.

parentback to summary
private final JNIMethodScope parent
scopeNameback to summary
private final String scopeName

The name for this scope.

topScopeback to summary
private static final ThreadLocal<JNIMethodScope> topScope

Constructor Detail

JNIMethodScopeback to summary
public JNIMethodScope(String scopeName, JNI.JNIEnv env)

Enters the scope of an native method call.

Annotations
@SuppressWarnings:unchecked, this-escape

Method Detail

closeback to summary
public void close()

Implements java.lang.AutoCloseable.close.

Doc from java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources. This method is invoked automatically on objects managed by the try-with-resources statement.

Annotations
@Override
depthback to summary
public final int depth()
envback to summary
public static JNI.JNIEnv env()

Gets the JNIEnv value for the current thread.

getEnvback to summary
public JNI.JNIEnv getEnv()
getObjectResultback to summary
public <R extends JNI.JObject> R getObjectResult()
Annotations
@SuppressWarnings:unchecked
scopeback to summary
public static JNIMethodScope scope()

Gets the inner most JNIMethodScope value for the current thread.

scopeOrNullback to summary
public static JNIMethodScope scopeOrNull()

Gets the inner most JNIMethodScope value for the current thread.

setObjectResultback to summary
public void setObjectResult(JNI.JObject obj)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override