Skip to content

Commit 3c47106

Browse files
committed
Adjust JFR checks for J9
1 parent 5b9a331 commit 3c47106

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

dd-java-agent/agent-profiling/src/main/java/com/datadog/profiling/agent/CompositeController.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,11 @@ public static Controller build(ConfigProvider provider, ControllerContext contex
153153
}
154154
if (!isOracleJDK8) {
155155
try {
156-
Class.forName("jdk.jfr.Event");
157-
controllers.add(OpenJdkController.instance(provider));
156+
Class<?> frClass = Class.forName("jdk.jfr.FlightRecorder");
157+
boolean isJfrAvailable = (boolean)frClass.getMethod("isAvailable", new Class<?>[0]).invoke(null);
158+
if (isJfrAvailable) {
159+
controllers.add(OpenJdkController.instance(provider));
160+
}
158161
} catch (Throwable ignored) {
159162
log.debug("Failed to load openjdk profiler", ignored);
160163
}

dd-java-agent/testing/src/test/groovy/AgentTestRunnerTest.groovy

+2-2
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ class AgentTestRunnerTest extends AgentTestRunner {
181181

182182
boolean isJFRSupported() {
183183
try {
184-
Class.forName("jdk.jfr.Recording")
185-
return true
184+
Class<?> frClass = Class.forName("jdk.jfr.FlightRecorder");
185+
return (boolean)frClass.getMethod("isAvailable", new Class<?>[0]).invoke(null);
186186
} catch (Throwable e) {
187187
return false
188188
}

0 commit comments

Comments
 (0)