src/jdk.jfr/share/classes/jdk/jfr/internal/SecuritySupport.java
changeset 52698 ca6b58b8ffc5
parent 52334 a181612f0715
child 57360 5d043a159d5c
child 58240 046533575954
--- a/src/jdk.jfr/share/classes/jdk/jfr/internal/SecuritySupport.java	Tue Nov 27 11:07:44 2018 -0500
+++ b/src/jdk.jfr/share/classes/jdk/jfr/internal/SecuritySupport.java	Tue Nov 27 18:14:27 2018 +0100
@@ -79,6 +79,14 @@
     static final SafePath USER_HOME = getPathInProperty("user.home", null);
     static final SafePath JAVA_IO_TMPDIR = getPathInProperty("java.io.tmpdir", null);
 
+    static {
+        // ensure module java.base can read module jdk.jfr as early as possible
+        addReadEdge(Object.class);
+        addHandlerExport(Object.class);
+        addEventsExport(Object.class);
+        addInstrumentExport(Object.class);
+    }
+
     final static class SecureRecorderListener implements FlightRecorderListener {
 
         private final AccessControlContext context;
@@ -262,6 +270,18 @@
         Modules.addExports(JFR_MODULE, Utils.HANDLERS_PACKAGE_NAME, clazz.getModule());
     }
 
+    static void addEventsExport(Class<?> clazz) {
+        Modules.addExports(JFR_MODULE, Utils.EVENTS_PACKAGE_NAME, clazz.getModule());
+    }
+
+    static void addInstrumentExport(Class<?> clazz) {
+        Modules.addExports(JFR_MODULE, Utils.INSTRUMENT_PACKAGE_NAME, clazz.getModule());
+    }
+
+    static void addReadEdge(Class<?> clazz) {
+        Modules.addReads(clazz.getModule(), JFR_MODULE);
+    }
+
     public static void registerEvent(Class<? extends jdk.internal.event.Event> eventClass) {
         doPrivileged(() ->  MetadataRepository.getInstance().register(eventClass), new FlightRecorderPermission(Utils.REGISTER_EVENT));
     }