40 * Performs any required security checks and dynamic reconfiguration to allow the module of a
41 * given class to access the classes in the JVMCI module.
42 *
43 * Note: This API uses {@link Class} instead of {@link Module} to provide backwards
44 * compatibility for JVMCI clients compiled against a JDK release earlier than 9.
45 *
46 * @param requestor a class requesting access to the JVMCI module for its module
47 * @throws SecurityException if a security manager is present and it denies
48 * {@link JVMCIPermission}
49 */
50 public static void exportJVMCITo(Class<?> requestor) {
51 SecurityManager sm = System.getSecurityManager();
52 if (sm != null) {
53 sm.checkPermission(new JVMCIPermission());
54 }
55 Module jvmci = Services.class.getModule();
56 Module requestorModule = requestor.getModule();
57 if (jvmci != requestorModule) {
58 for (String pkg : jvmci.getPackages()) {
59 // Export all JVMCI packages dynamically instead
60 // of requiring a long list of -XaddExports
61 // options on the JVM command line.
62 if (!jvmci.isExported(pkg, requestorModule)) {
63 jvmci.addExports(pkg, requestorModule);
64 }
65 }
66 }
67 }
68
69 /**
70 * Gets an {@link Iterable} of the JVMCI providers available for a given service.
71 *
72 * @throws SecurityException if a security manager is present and it denies
73 * {@link JVMCIPermission}
74 */
75 public static <S> Iterable<S> load(Class<S> service) {
76 SecurityManager sm = System.getSecurityManager();
77 if (sm != null) {
78 sm.checkPermission(new JVMCIPermission());
79 }
80 Module jvmci = Services.class.getModule();
|
40 * Performs any required security checks and dynamic reconfiguration to allow the module of a
41 * given class to access the classes in the JVMCI module.
42 *
43 * Note: This API uses {@link Class} instead of {@link Module} to provide backwards
44 * compatibility for JVMCI clients compiled against a JDK release earlier than 9.
45 *
46 * @param requestor a class requesting access to the JVMCI module for its module
47 * @throws SecurityException if a security manager is present and it denies
48 * {@link JVMCIPermission}
49 */
50 public static void exportJVMCITo(Class<?> requestor) {
51 SecurityManager sm = System.getSecurityManager();
52 if (sm != null) {
53 sm.checkPermission(new JVMCIPermission());
54 }
55 Module jvmci = Services.class.getModule();
56 Module requestorModule = requestor.getModule();
57 if (jvmci != requestorModule) {
58 for (String pkg : jvmci.getPackages()) {
59 // Export all JVMCI packages dynamically instead
60 // of requiring a long list of --add-exports
61 // options on the JVM command line.
62 if (!jvmci.isExported(pkg, requestorModule)) {
63 jvmci.addExports(pkg, requestorModule);
64 }
65 }
66 }
67 }
68
69 /**
70 * Gets an {@link Iterable} of the JVMCI providers available for a given service.
71 *
72 * @throws SecurityException if a security manager is present and it denies
73 * {@link JVMCIPermission}
74 */
75 public static <S> Iterable<S> load(Class<S> service) {
76 SecurityManager sm = System.getSecurityManager();
77 if (sm != null) {
78 sm.checkPermission(new JVMCIPermission());
79 }
80 Module jvmci = Services.class.getModule();
|