| Modifier and Type | Class and Description |
|---|---|
| private static record |
| Modifier and Type | Field and Description |
|---|---|
| private static final int | |
| private static final int | |
| private static final int | |
| private static final StructLayout | |
| private static final int | |
| private static final int | |
| private static final List | |
| private static final MethodHandles. | |
| private static final int | |
| private static final int | |
| private static final BufferStack | |
| private static final Map | |
| private static final int | |
| private static final int | |
| private static final IntFunction |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| private static Arena | |
| public static MethodHandle | Returns: a new MethodHandle that adapts the providedtarget so that it
directly returns the same value as the target if it is non-negative,
otherwise returns the negated captured state defined by the provided
stateNamemethod handle that returns an target, String int or a long and
has a capturing state MemorySegment as its first parameterthe name of the capturing state member layout (i.e. "errno",
"GetLastError", or "WSAGetLastError") stateName)Returns a new MethodHandle that adapts the provided |
| private static MemorySegment | |
| private static int | |
| private static long | |
| private static MethodHandle | |
| private static MethodHandle | |
| private static boolean | |
| private static boolean | |
| private static int | |
| private static long |
| ACQUIRE_ARENA | back to summary |
|---|---|
| private static final int ACQUIRE_ARENA | |
| ALLOCATE | back to summary |
|---|---|
| private static final int ALLOCATE | |
| ARENA_CLOSE | back to summary |
|---|---|
| private static final int ARENA_CLOSE | |
| CAPTURE_LAYOUT | back to summary |
|---|---|
| private static final StructLayout CAPTURE_LAYOUT | |
| ERROR_INT | back to summary |
|---|---|
| private static final int ERROR_INT | |
| ERROR_LONG | back to summary |
|---|---|
| private static final int ERROR_LONG | |
| HANDLES_CACHE | back to summary |
|---|---|
| private static final List<MethodHandle> HANDLES_CACHE | |
| LOOKUP | back to summary |
|---|---|
| private static final MethodHandles. | |
| NON_NEGATIVE_INT | back to summary |
|---|---|
| private static final int NON_NEGATIVE_INT | |
| NON_NEGATIVE_LONG | back to summary |
|---|---|
| private static final int NON_NEGATIVE_LONG | |
| POOL | back to summary |
|---|---|
| private static final BufferStack POOL | |
| SEGMENT_EXTRACTION_HANDLE_CACHE | back to summary |
|---|---|
| private static final Map<CaptureStateUtil. | |
| SUCCESS_INT | back to summary |
|---|---|
| private static final int SUCCESS_INT | |
| SUCCESS_LONG | back to summary |
|---|---|
| private static final int SUCCESS_LONG | |
| UNDERLYING_MAKE_HANDLE | back to summary |
|---|---|
| private static final IntFunction<MethodHandle> UNDERLYING_MAKE_HANDLE | |
| CaptureStateUtil | back to summary |
|---|---|
| private CaptureStateUtil() | |
| acquireArena | back to summary |
|---|---|
private static Arena acquireArena()
| |
| adaptSystemCall | back to summary |
|---|---|
| public static MethodHandle adaptSystemCall(MethodHandle target, String stateName) Returns a new MethodHandle that adapts the provided
This method is suitable for adapting system-call method handles(e.g.
// (MemorySegment capture, MemorySegment pathname, int flags)int static final MethodHandle CAPTURING_OPEN = ... // (MemorySegment pathname, int flags)int static final MethodHandle OPEN = CaptureStateUtil .adaptSystemCall(CAPTURING_OPEN, "errno"); try { int fh = (int)OPEN.invokeExact(pathName, flags); if (fh < 0) { throw new IOException("Error opening file: errno = " + (-fh)); } processFile(fh); } catch (Throwable t) { throw new RuntimeException(t); } target method handle that takes a MemorySegment and two
int parameters and returns an int value, the method returns a new
method handle that is doing the equivalent of:
private static final MemoryLayout CAPTURE_LAYOUT = Linker.Option.captureStateLayout(); private static final BufferStack POOL = BufferStack.of(CAPTURE_LAYOUT); public int invoke(MethodHandle target, String stateName, int a, int b) { try (var arena = POOL.pushFrame(CAPTURE_LAYOUT)) { final MemorySegment segment = arena.allocate(CAPTURE_LAYOUT); final int result = (int) handle.invoke(segment, a, b); if (result >= 0) { return result; } return -(int) CAPTURE_LAYOUT .varHandle(MemoryLayout.PathElement.groupElement(stateName)) .get(segment, 0); } } stateName is the name of the
captured state (e.g. errno). The static CAPTURE_LAYOUT is shared
across all target method handles adapted by this method.
| |
| allocate | back to summary |
|---|---|
private static MemorySegment allocate(Arena arena)
| |
| error | back to summary |
|---|---|
private static int error(MethodHandle errorHandle, int value, MemorySegment segment) throws Throwable
| |
| error | back to summary |
|---|---|
private static long error(MethodHandle errorHandle, long value, MemorySegment segment) throws Throwable
| |
| makeHandle | back to summary |
|---|---|
| private static MethodHandle makeHandle(int index) | |
| makeSegmentExtractionHandle | back to summary |
|---|---|
| private static MethodHandle makeSegmentExtractionHandle(CaptureStateUtil. | |
| nonNegative | back to summary |
|---|---|
private static boolean nonNegative(int value)
| |
| nonNegative | back to summary |
|---|---|
private static boolean nonNegative(long value)
| |
| success | back to summary |
|---|---|
private static int success(int value, MemorySegment segment)
| |
| success | back to summary |
|---|---|
private static long success(long value, MemorySegment segment)
| |
| Modifier and Type | Field and Description |
|---|---|
| private final Class | returnType
Record Component accessed by returnType(). |
| private final String | stateName
Record Component accessed by stateName(). |
| Access | Constructor and Description |
|---|---|
| pack-priv | |
| private |
| Modifier and Type | Method and Description |
|---|---|
| public final boolean | equals(Object o)
Implements abstract java. Indicates whether some other object is "equal to" this one. |
| public final int | |
| private static IllegalArgumentException | |
| pack-priv static Class | |
| public Class | |
| public String | |
| public final String | toString()
Implements abstract java. Returns a string representation of the record. |
| returnType | back to summary |
|---|---|
| private final Class<?> returnType Record Component accessed by returnType(). | |
| stateName | back to summary |
|---|---|
| private final String stateName Record Component accessed by stateName(). | |
| SegmentExtractorKey | back to summary |
|---|---|
| pack-priv SegmentExtractorKey(MethodHandle target, String stateName) | |
| SegmentExtractorKey | back to summary |
|---|---|
| private SegmentExtractorKey(Class<?> returnType, String stateName) | |
| equals | back to summary |
|---|---|
| public final boolean equals(Object o) Implements abstract java. Doc from java. Indicates whether some other object is "equal to" this one. In addition
to the general contract of
R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
| |
| hashCode | back to summary |
|---|---|
| public final int hashCode() Implements abstract java. Doc from java. Returns a hash code value for the record.
Obeys the general contract of | |
| illegalArgDoesNot | back to summary |
|---|---|
| private static IllegalArgumentException illegalArgDoesNot(MethodHandle target, String info) | |
| returnType | back to summary |
|---|---|
| pack-priv static Class | |
| returnType | back to summary |
|---|---|
| public Class Record Component getter of returnType. | |
| stateName | back to summary |
|---|---|
| public String stateName() Record Component getter of stateName. | |
| toString | back to summary |
|---|---|
| public final String toString() Implements abstract java. Doc from java. Returns a string representation of the record.
In accordance with the general contract of 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. | |