Skip to content

Commit

Permalink
[GR-47473] Fix interfaces under which FlightRecorderMXBean is registe…
Browse files Browse the repository at this point in the history
…red.

PullRequest: graal/15514
  • Loading branch information
Christian Wimmer committed Sep 14, 2023
2 parents 9cf893f + 5bc7444 commit 5d904c8
Showing 1 changed file with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,26 @@
*/
public final class ManagementSupport implements ThreadListener {

private static final boolean isJdkManagementJfrModulePresent;
private static final Class<?> FLIGHT_RECORDER_MX_BEAN_CLASS;

static {
var loggingModule = ModuleLayer.boot().findModule("jdk.management.jfr");
if (loggingModule.isPresent()) {
ManagementSupport.class.getModule().addReads(loggingModule.get());
var jfrModule = ModuleLayer.boot().findModule("jdk.management.jfr");
if (jfrModule.isPresent()) {
ManagementSupport.class.getModule().addReads(jfrModule.get());
try {
FLIGHT_RECORDER_MX_BEAN_CLASS = Class.forName("jdk.management.jfr.FlightRecorderMXBean", false, Object.class.getClassLoader());
} catch (ClassNotFoundException ex) {
throw VMError.shouldNotReachHere(ex);
}
} else {
FLIGHT_RECORDER_MX_BEAN_CLASS = null;
}
isJdkManagementJfrModulePresent = loggingModule.isPresent();
}

static class JdkManagementJfrModulePresent implements BooleanSupplier {
@Override
public boolean getAsBoolean() {
return isJdkManagementJfrModulePresent;
return FLIGHT_RECORDER_MX_BEAN_CLASS != null;
}
}

Expand Down Expand Up @@ -166,7 +172,9 @@ public boolean getAsBoolean() {
* run time.
*/
doAddPlatformManagedObjectSingleton(getOsMXBeanInterface(), (PlatformManagedObjectSupplier) this::getOsMXBean);
doAddPlatformManagedObjectSingleton(PlatformManagedObject.class, (PlatformManagedObjectSupplier) this::getFlightRecorderMXBean);
if (FLIGHT_RECORDER_MX_BEAN_CLASS != null) {
doAddPlatformManagedObjectSingleton(FLIGHT_RECORDER_MX_BEAN_CLASS, (PlatformManagedObjectSupplier) this::getFlightRecorderMXBean);
}
}

private static Class<?> getOsMXBeanInterface() {
Expand Down

0 comments on commit 5d904c8

Please sign in to comment.