APIdia Launch Partner
Top Description Fields Constructors Methods
jdk.internal.vm

public Class StackableScope

extends Object
Class Inheritance
Known Direct Subclasses
jdk.internal.vm.ThreadContainer, jdk.internal.vm.ScopedValueContainer
Imports
jdk.internal.access.JavaLangAccess, .SharedSecrets, jdk.internal.vm.annotation.DontInline, .ReservedStackAccess

A stackable scope to support structured constructs. The push method is used to push a StackableScope to the current thread's scope stack. The tryPop and popForcefully methods are used to pop the StackableScope from the current thread's scope stack.

Field Summary

Modifier and TypeField and Description
private static final JavaLangAccess
private final Thread
private volatile StackableScope

Constructor Summary

AccessConstructor and Description
pack-priv
StackableScope(boolean
true for a shared scope that cannot be pushed to the stack, false for scope that is owned by the current thread
shared
)

Creates a stackable scope.

protected
StackableScope()

Creates a stackable scope owned by the current thread.

Method Summary

Modifier and TypeMethod and Description
private static boolean
contains(StackableScope scope)

Returns true if the given scope is on the current thread's scope stack.

public StackableScope
enclosingScope()

Returns the scope that encloses this scope.

public <T extends StackableScope> T
enclosingScope(Class<T> type)

Returns the scope of the given type that encloses this scope.

pack-priv static StackableScope
head()

Returns the head of the current thread's scope stack.

private StackableScope
next()

Returns the scope that this scope directly encloses, null if none.

public Thread
owner()

Returns the scope owner or null if not owned.

public static void
popAll()

Pops all scopes from the current thread's scope stack.

public boolean

Returns:

true if this scope was at the top of the stack, otherwise false
popForcefully
()

Pops this scope from the current thread's scope stack.

pack-priv StackableScope
previous()

Returns the scope that directly encloses this scope, null if none.

public StackableScope
push()

Pushes this scope onto the current thread's scope stack.

private static void
setHead(StackableScope scope)

Sets the head (top) of the current thread's scope stack.

protected boolean

Returns:

true if this method closed the scope, false if it failed
tryClose
()

Override this method to close this scope and release its resources.

public boolean

Returns:

true if the pop succeeded, false if this scope is not the top of stack
tryPop
()

Pops this scope from the current thread's scope stack if the scope is at the top of stack.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

JLAback to summary
private static final JavaLangAccess JLA
ownerback to summary
private final Thread owner
previousback to summary
private volatile StackableScope previous

Constructor Detail

StackableScopeback to summary
pack-priv StackableScope(boolean shared)

Creates a stackable scope.

Parameters
shared:boolean

true for a shared scope that cannot be pushed to the stack, false for scope that is owned by the current thread

StackableScopeback to summary
protected StackableScope()

Creates a stackable scope owned by the current thread.

Method Detail

containsback to summary
private static boolean contains(StackableScope scope)

Returns true if the given scope is on the current thread's scope stack.

enclosingScopeback to summary
public StackableScope enclosingScope()

Returns the scope that encloses this scope.

enclosingScopeback to summary
public <T extends StackableScope> T enclosingScope(Class<T> type)

Returns the scope of the given type that encloses this scope.

headback to summary
pack-priv static StackableScope head()

Returns the head of the current thread's scope stack.

nextback to summary
private StackableScope next()

Returns the scope that this scope directly encloses, null if none.

ownerback to summary
public Thread owner()

Returns the scope owner or null if not owned.

popAllback to summary
public static void popAll()

Pops all scopes from the current thread's scope stack.

popForcefullyback to summary
public boolean popForcefully()

Pops this scope from the current thread's scope stack. For well-behaved usages, this scope is at the top of the stack. It is popped from the stack and the method returns true. If this scope is not at the top of the stack then this method attempts to close each of the intermediate scopes by invoking their tryClose() method. If tryClose succeeds then the scope is removed from the stack. When done, this scope is removed from the stack and false is returned. This method does nothing, and returns false, if this scope is not on the current thread's scope stack.

Returns:boolean

true if this scope was at the top of the stack, otherwise false

Annotations
@DontInline
@ReservedStackAccess
Exceptions
WrongThreadException:
it the current thread is not the owner
previousback to summary
pack-priv StackableScope previous()

Returns the scope that directly encloses this scope, null if none.

pushback to summary
public StackableScope push()

Pushes this scope onto the current thread's scope stack.

Exceptions
WrongThreadException:
it the current thread is not the owner
setHeadback to summary
private static void setHead(StackableScope scope)

Sets the head (top) of the current thread's scope stack.

tryCloseback to summary
protected boolean tryClose()

Override this method to close this scope and release its resources. This method should not pop the scope from the stack. This method is guaranteed to execute on the owner thread.

Returns:boolean

true if this method closed the scope, false if it failed

tryPopback to summary
public boolean tryPop()

Pops this scope from the current thread's scope stack if the scope is at the top of stack.

Returns:boolean

true if the pop succeeded, false if this scope is not the top of stack

Annotations
@DontInline
@ReservedStackAccess
Exceptions
WrongThreadException:
it the current thread is not the owner