- /*
- * PREPARE EVOLUTION OF JAVA APIs INTRODUCED IN JDK 18 The following static
- * methods will be added to Subject
- */
- public Subject current() {
- return currentSubject();
- }
-
- public static <T> T callAs(Subject subject, Callable<T> action) {
- try {
- return Subject.doAs(subject, new PrivilegedExceptionAction<T>() {
-
- @Override
- public T run() throws Exception {
- return action.call();
- }
-
- });
- } catch (PrivilegedActionException e) {
- throw new CompletionException("Failed to execute action for " + subject, e.getCause());
- }
- }
-