Top Description Fields Constructors Methods
jdk.vm.ci.hotspot

public final Class HotSpotObjectConstantScope

extends Object
implements AutoCloseable
Class Inheritance
All Implemented Interfaces
java.lang.AutoCloseable
Imports
java.util.ArrayList, .List, .Objects, jdk.vm.ci.services.Services

A mechanism for limiting the lifetime of a foreign object reference encapsulated in a HotSpotObjectConstant. A HotSpotObjectConstant allocated in a local scope will have its reference to any foreign object cleared when the scope closes. This allows the foreign memory manager to reclaim the foreign object (once there are no other strong references to it). HotSpotObjectConstantScopes have no impact on HotSpotObjectConstants that do not encapsulate a foreign object reference. The object returned by enterGlobalScope() or openLocalScope(Object) should always be used in a try-with-resources statement. Failure to close a scope will almost certainly result in foreign objects being leaked.

Field Summary

Modifier and TypeField and Description
pack-priv static final ThreadLocal<HotSpotObjectConstantScope>
private List<IndirectHotSpotObjectConstantImpl>
pack-priv final Object
localScopeDescription

An object whose Object#toString() value describes a non-global scope.

private final HotSpotObjectConstantScope

Constructor Summary

AccessConstructor and Description
private
HotSpotObjectConstantScope(Object localScopeDescription)

Method Summary

Modifier and TypeMethod and Description
pack-priv void
public void
close()

Implements java.lang.AutoCloseable.close.

Closes this resource, relinquishing any underlying resources.

public static HotSpotObjectConstantScope

Returns:

null if the current runtime does not support remote object references or if this thread is currently in the global scope
enterGlobalScope
()

Enters the global scope.

pack-priv boolean
isGlobal()

Determines if this scope is global.

public static HotSpotObjectConstantScope

Returns:

null if the current runtime does not support remote object references
openLocalScope
(Object
an non-null object whose Object#toString() value describes the scope being opened
description
)

Opens a local scope that upon closing, will release foreign object references encapsulated by HotSpotObjectConstants created in the scope.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

CURRENTback to summary
pack-priv static final ThreadLocal<HotSpotObjectConstantScope> CURRENT
foreignObjectsback to summary
private List<IndirectHotSpotObjectConstantImpl> foreignObjects
localScopeDescriptionback to summary
pack-priv final Object localScopeDescription

An object whose Object#toString() value describes a non-global scope. This is null iff this is a global scope.

parentback to summary
private final HotSpotObjectConstantScope parent

Constructor Detail

HotSpotObjectConstantScopeback to summary
private HotSpotObjectConstantScope(Object localScopeDescription)

Method Detail

addback to summary
pack-priv void add(IndirectHotSpotObjectConstantImpl obj)
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
@VMEntryPoint
@Override
enterGlobalScopeback to summary
public static HotSpotObjectConstantScope enterGlobalScope()

Enters the global scope. This is useful to escape a local scope for execution that will create foreign object references that need to outlive the local scope. Foreign object references encapsulated by HotSpotObjectConstants created in the global scope are only subject to reclamation once the HotSpotObjectConstant wrapper dies.

Returns:HotSpotObjectConstantScope

null if the current runtime does not support remote object references or if this thread is currently in the global scope

isGlobalback to summary
pack-priv boolean isGlobal()

Determines if this scope is global.

openLocalScopeback to summary
public static HotSpotObjectConstantScope openLocalScope(Object description)

Opens a local scope that upon closing, will release foreign object references encapsulated by HotSpotObjectConstants created in the scope.

Parameters
description:Object

an non-null object whose Object#toString() value describes the scope being opened

Returns:HotSpotObjectConstantScope

null if the current runtime does not support remote object references