< prev index next > src/java.base/share/classes/jdk/internal/vm/ScopedValueContainer.java
Print this page
/*
! * Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
/*
! * Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.internal.vm;
! import java.util.concurrent.Callable;
import java.util.concurrent.StructureViolationException;
import jdk.internal.access.JavaLangAccess;
import jdk.internal.access.SharedSecrets;
import jdk.internal.misc.Unsafe;
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package jdk.internal.vm;
! import java.lang.ScopedValue.CallableOp;
import java.util.concurrent.StructureViolationException;
import jdk.internal.access.JavaLangAccess;
import jdk.internal.access.SharedSecrets;
import jdk.internal.misc.Unsafe;
}
/**
* For use by ScopedValue to call a value returning operation in a structured context.
*/
! public static <V> V call(Callable<V> op) {
if (head() == null) {
// no need to push scope when stack is empty
return callWithoutScope(op);
} else {
return new ScopedValueContainer().doCall(op);
}
/**
* For use by ScopedValue to call a value returning operation in a structured context.
*/
! public static <V, X extends Throwable> V call(CallableOp<V, X> op) {
if (head() == null) {
// no need to push scope when stack is empty
return callWithoutScope(op);
} else {
return new ScopedValueContainer().doCall(op);
}
/**
* Call an operation without a scope on the stack.
*/
! private static <V> V callWithoutScope(Callable<V> op) {
assert head() == null;
Throwable ex;
boolean atTop;
V result;
try {
}
/**
* Call an operation without a scope on the stack.
*/
! private static <V, X extends Throwable> V callWithoutScope(CallableOp<V, X> op) {
assert head() == null;
Throwable ex;
boolean atTop;
V result;
try {
}
/**
* Call an operation with this scope on the stack.
*/
! private <V> V doCall(Callable<V> op) {
Throwable ex;
boolean atTop;
V result;
push();
try {
}
/**
* Call an operation with this scope on the stack.
*/
! private <V, X extends Throwable> V doCall(CallableOp<V, X> op) {
Throwable ex;
boolean atTop;
V result;
push();
try {
< prev index next >