Debian Codegraph @

api/src/main/java/jakarta/enterprise/inject/build/compatible/spi/SecurityActions.java

raw
1 /*
2 * Copyright (c) 2021 Red Hat and others
3 *
4 * This program and the accompanying materials are made available under the
5 * Apache Software License 2.0 which is available at:
6 * https://www.apache.org/licenses/LICENSE-2.0.
7 *
8 * SPDX-License-Identifier: Apache-2.0
9 */
10
11 package jakarta.enterprise.inject.build.compatible.spi;
12
13 import java.security.AccessController;
14 import java.security.PrivilegedAction;
15 import java.util.ServiceLoader;
16
17 /**
18 * This utility class is used to optimize invocation made through the SecurityManager
19 *
20 * @author Antoine Sabot-durand
21 */
22
23 final class SecurityActions {
24 private SecurityActions() {
25 }
26
27 static <T> ServiceLoader<T> loadService(Class<T> service, ClassLoader classLoader) {
28 return AccessController.doPrivileged(
29 (PrivilegedAction<ServiceLoader<T>>) () -> ServiceLoader.load(service, classLoader)
30 );
31 }
32 }