Top Description Inners Fields Constructors Methods
jdk.internal.vm

public Class ScopedValueContainer

extends StackableScope
Class Inheritance
Imports
java.lang.ScopedValue.CallableOp, java.util.concurrent.StructureViolationException, jdk.internal.access.JavaLangAccess, .SharedSecrets, jdk.internal.misc.Unsafe

A StackableScope to represent scoped-value bindings. This class defines static methods to run an operation with a ScopedValueContainer on the scope stack. It also defines a method to get the latest ScopedValueContainer and a method to return a snapshot of the scoped value bindings.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static record
ScopedValueContainer.BindingsSnapshot

A snapshot of the scoped value bindings.

Field Summary

Modifier and TypeField and Description
private static final JavaLangAccess

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static <V, X extends Throwable> V
call(ScopedValue.CallableOp<V, X> op)

For use by ScopedValue to call a value returning operation in a structured context.

private static <V, X extends Throwable> V
callWithoutScope(ScopedValue.CallableOp<V, X> op)

Call an operation without a scope on the stack.

public static ScopedValueContainer.BindingsSnapshot
captureBindings()

Returns the scoped value bindings for the current thread.

private <V, X extends Throwable> V
doCall(ScopedValue.CallableOp<V, X> op)

Call an operation with this scope on the stack.

private void
doRun(Runnable op)

Run an operation with this scope on the stack.

public static <T extends ScopedValueContainer> T
latest(Class<T> containerClass)

Returns the "latest" ScopedValueContainer for the current Thread.

public static ScopedValueContainer
latest()

Returns the "latest" ScopedValueContainer for the current Thread.

public static void
run(Runnable op)

For use by ScopedValue to run an operation in a structured context.

private static void
runWithoutScope(Runnable op)

Run an operation without a scope on the stack.

private static void
throwIfFailed(Throwable ex, boolean atTop)

Throws ex if not null.

Inherited from jdk.internal.vm.StackableScope:
enclosingScopeenclosingScopeheadownerpopAllpopForcefullypreviouspushtryClosetryPop

Field Detail

JLAback to summary
private static final JavaLangAccess JLA

Hides jdk.internal.vm.StackableScope.JLA.

Constructor Detail

ScopedValueContainerback to summary
private ScopedValueContainer()

Method Detail

callback to summary
public static <V, X extends Throwable> V call(ScopedValue.CallableOp<V, X> op)

For use by ScopedValue to call a value returning operation in a structured context.

callWithoutScopeback to summary
private static <V, X extends Throwable> V callWithoutScope(ScopedValue.CallableOp<V, X> op)

Call an operation without a scope on the stack.

captureBindingsback to summary
public static ScopedValueContainer.BindingsSnapshot captureBindings()

Returns the scoped value bindings for the current thread.

doCallback to summary
private <V, X extends Throwable> V doCall(ScopedValue.CallableOp<V, X> op)

Call an operation with this scope on the stack.

doRunback to summary
private void doRun(Runnable op)

Run an operation with this scope on the stack.

latestback to summary
public static <T extends ScopedValueContainer> T latest(Class<T> containerClass)

Returns the "latest" ScopedValueContainer for the current Thread. This may be on the current thread's scope task or may require walking up the tree to find it.

latestback to summary
public static ScopedValueContainer latest()

Returns the "latest" ScopedValueContainer for the current Thread. This may be on the current thread's scope task or may require walking up the tree to find it.

runback to summary
public static void run(Runnable op)

For use by ScopedValue to run an operation in a structured context.

runWithoutScopeback to summary
private static void runWithoutScope(Runnable op)

Run an operation without a scope on the stack.

throwIfFailedback to summary
private static void throwIfFailed(Throwable ex, boolean atTop)

Throws ex if not null. StructureViolationException is thrown or added as a suppressed exception when atTop is false.

jdk.internal.vm back to summary

public final Record ScopedValueContainer.BindingsSnapshot

extends Record
Class Inheritance
Record Components
scopedValueBindings:Object
container:ScopedValueContainer

A snapshot of the scoped value bindings. The snapshot includes the bindings established for the current thread and scoped value container.

Field Summary

Modifier and TypeField and Description
private final ScopedValueContainer
container

Record Component accessed by container().

private final Object
scopedValueBindings

Record Component accessed by scopedValueBindings().

Constructor Summary

AccessConstructor and Description
public
BindingsSnapshot(Object scopedValueBindings, ScopedValueContainer container)

Method Summary

Modifier and TypeMethod and Description
public ScopedValueContainer
container()

Record Component getter of container.

public final boolean
equals(Object
the reference object with which to compare.
o
)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public Object
scopedValueBindings()

Record Component getter of scopedValueBindings.

public final String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

containerback to summary
private final ScopedValueContainer container

Record Component accessed by container().

scopedValueBindingsback to summary
private final Object scopedValueBindings

Record Component accessed by scopedValueBindings().

Constructor Detail

BindingsSnapshotback to summary
public BindingsSnapshot(Object scopedValueBindings, ScopedValueContainer container)

Method Detail

containerback to summary
public ScopedValueContainer container()

Record Component getter of container.

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this record is equal to the argument; false otherwise.

hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

Returns:int

a hash code value for this record.

scopedValueBindingsback to summary
public Object scopedValueBindings()

Record Component getter of scopedValueBindings.

toStringback to summary
public final String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

Returns:String

a string representation of the object.