8247247: JFR tests fail due to JDK-8235521 missing doPrivileged block
Reviewed-by: egahlin
This commit is contained in:
parent
30ff2ad58c
commit
c0475c81f2
@ -109,7 +109,7 @@ public final class MetadataRepository {
|
||||
}
|
||||
|
||||
public synchronized EventType getEventType(Class<? extends jdk.internal.event.Event> eventClass) {
|
||||
EventHandler h = getHandler(eventClass);
|
||||
EventHandler h = getHandler(eventClass, false);
|
||||
if (h != null && h.isRegistered()) {
|
||||
return h.getEventType();
|
||||
}
|
||||
@ -118,7 +118,7 @@ public final class MetadataRepository {
|
||||
|
||||
public synchronized void unregister(Class<? extends Event> eventClass) {
|
||||
Utils.checkRegisterPermission();
|
||||
EventHandler handler = getHandler(eventClass);
|
||||
EventHandler handler = getHandler(eventClass, false);
|
||||
if (handler != null) {
|
||||
handler.setRegistered(false);
|
||||
}
|
||||
@ -130,7 +130,7 @@ public final class MetadataRepository {
|
||||
|
||||
public synchronized EventType register(Class<? extends jdk.internal.event.Event> eventClass, List<AnnotationElement> dynamicAnnotations, List<ValueDescriptor> dynamicFields) {
|
||||
Utils.checkRegisterPermission();
|
||||
EventHandler handler = getHandler(eventClass);
|
||||
EventHandler handler = getHandler(eventClass, true);
|
||||
if (handler == null) {
|
||||
if (eventClass.getAnnotation(MirrorEvent.class) != null) {
|
||||
// don't register mirrors
|
||||
@ -165,10 +165,12 @@ public final class MetadataRepository {
|
||||
return et;
|
||||
}
|
||||
|
||||
private EventHandler getHandler(Class<? extends jdk.internal.event.Event> eventClass) {
|
||||
private EventHandler getHandler(Class<? extends jdk.internal.event.Event> eventClass, boolean ensureInitialized) {
|
||||
Utils.ensureValidEventSubclass(eventClass);
|
||||
SecuritySupport.makeVisibleToJFR(eventClass);
|
||||
Utils.ensureInitialized(eventClass);
|
||||
if (ensureInitialized) {
|
||||
Utils.ensureInitialized(eventClass);
|
||||
}
|
||||
return Utils.getHandler(eventClass);
|
||||
}
|
||||
|
||||
|
@ -432,9 +432,22 @@ public final class SecuritySupport {
|
||||
|
||||
static void ensureClassIsInitialized(Class<?> clazz) {
|
||||
try {
|
||||
MethodHandles.privateLookupIn(clazz, LOOKUP).ensureInitialized(clazz);
|
||||
MethodHandles.Lookup lookup;
|
||||
if (System.getSecurityManager() == null) {
|
||||
lookup = MethodHandles.privateLookupIn(clazz, LOOKUP);
|
||||
} else {
|
||||
lookup = AccessController.doPrivileged(new PrivilegedExceptionAction<>() {
|
||||
@Override
|
||||
public MethodHandles.Lookup run() throws IllegalAccessException {
|
||||
return MethodHandles.privateLookupIn(clazz, LOOKUP);
|
||||
}
|
||||
}, null, new ReflectPermission("suppressAccessChecks"));
|
||||
}
|
||||
lookup.ensureInitialized(clazz);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new InternalError(e);
|
||||
} catch (PrivilegedActionException e) {
|
||||
throw new InternalError(e.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user