diff --git a/dd-java-agent/agent-profiling/profiling-controller/src/main/java/com/datadog/profiling/controller/ControllerFactory.java b/dd-java-agent/agent-profiling/profiling-controller/src/main/java/com/datadog/profiling/controller/ControllerFactory.java index a1991a5d2d..a9cd29e5be 100644 --- a/dd-java-agent/agent-profiling/profiling-controller/src/main/java/com/datadog/profiling/controller/ControllerFactory.java +++ b/dd-java-agent/agent-profiling/profiling-controller/src/main/java/com/datadog/profiling/controller/ControllerFactory.java @@ -49,8 +49,28 @@ public final class ControllerFactory { | InstantiationException | IllegalAccessException | InvocationTargetException e) { - throw new UnsupportedEnvironmentException( - "The JFR controller could not find a supported JFR API", e); + String exMsg = + "The JFR controller could not find a supported JFR API" + getFixProposalMessage(); + throw new UnsupportedEnvironmentException(exMsg, e); + } + } + + private static String getFixProposalMessage() { + try { + String javaVersion = System.getProperty("java.version"); + if (javaVersion == null) { + return ""; + } + String javaVendor = System.getProperty("java.vendor", ""); + if (javaVersion.startsWith("1.8")) { + if (javaVendor.startsWith("Azul Systems")) { + return ", use Azul zulu version 1.8.0_212+"; + } + // TODO Add version minimum once JFR backported into OpenJDK distros + } + return ", use OpenJDK 11+ or Azul zulu version 1.8.0_212+"; + } catch (Exception ex) { + return ""; } } } diff --git a/dd-java-agent/agent-profiling/profiling-controller/src/test/java/com/datadog/profiling/controller/ControllerFactoryTest.java b/dd-java-agent/agent-profiling/profiling-controller/src/test/java/com/datadog/profiling/controller/ControllerFactoryTest.java index 323bbe6fe2..972ee08a4a 100644 --- a/dd-java-agent/agent-profiling/profiling-controller/src/test/java/com/datadog/profiling/controller/ControllerFactoryTest.java +++ b/dd-java-agent/agent-profiling/profiling-controller/src/test/java/com/datadog/profiling/controller/ControllerFactoryTest.java @@ -1,5 +1,6 @@ package com.datadog.profiling.controller; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.junit.jupiter.api.condition.JRE.JAVA_8; @@ -19,10 +20,18 @@ public class ControllerFactoryTest { @Test @EnabledOnJre({JAVA_8}) public void testCreateControllerJava8() { - assertThrows( - UnsupportedEnvironmentException.class, - () -> { - ControllerFactory.createController(config); - }); + UnsupportedEnvironmentException unsupportedEnvironmentException = + assertThrows( + UnsupportedEnvironmentException.class, + () -> { + ControllerFactory.createController(config); + }); + String expected = + "The JFR controller could not find a supported JFR API, use OpenJDK 11+ or Azul zulu version 1.8.0_212+"; + if ("Azul Systems, Inc.".equals(System.getProperty("java.vendor"))) { + expected = + "The JFR controller could not find a supported JFR API, use Azul zulu version 1.8.0_212+"; + } + assertEquals(expected, unsupportedEnvironmentException.getMessage()); } }