diff --git a/src/main/java/org/openjdk/jmc/rjmx/ConnectionToolkit.java b/src/main/java/org/openjdk/jmc/rjmx/ConnectionToolkit.java index d9afc8ba..dfe5dde1 100644 --- a/src/main/java/org/openjdk/jmc/rjmx/ConnectionToolkit.java +++ b/src/main/java/org/openjdk/jmc/rjmx/ConnectionToolkit.java @@ -365,6 +365,9 @@ public static boolean isHotSpot(IConnectionHandle connectionHandle) { return vmName != null && JavaVMVersionToolkit.isHotspotJVMName(vmName); } + public static boolean isSubstrateVm(IConnectionHandle connectionHandle) { + return getVMName(connectionHandle).equals("Substrate VM"); + } /** * Returns {@code true} if the connection handle is associated with an Oracle built JVM, * {@code false} otherwise. If the information is already present in the {@link JVMDescriptor}, diff --git a/src/main/java/org/openjdk/jmc/rjmx/services/jfr/internal/FlightRecorderServiceV2.java b/src/main/java/org/openjdk/jmc/rjmx/services/jfr/internal/FlightRecorderServiceV2.java index f0fc9322..d529e973 100644 --- a/src/main/java/org/openjdk/jmc/rjmx/services/jfr/internal/FlightRecorderServiceV2.java +++ b/src/main/java/org/openjdk/jmc/rjmx/services/jfr/internal/FlightRecorderServiceV2.java @@ -105,12 +105,20 @@ public String getVersion() { private boolean isDynamicFlightRecorderSupported(IConnectionHandle handle) { // All OpenJDK versions of JFR support dynamic enablement of JFR, so if there are no commercial features in play // all is A-OK. + if (ConnectionToolkit.isSubstrateVm(handle)){ + // JFR may not have been built into the native image. Check that FlightRecorderMXBean is accessible from the MBean server. + return isAvailable(handle); + } + return !cfs.hasCommercialFeatures() || (ConnectionToolkit.isHotSpot(handle) && ConnectionToolkit.isJavaVersionAboveOrEqual(handle, JavaVersionSupport.DYNAMIC_JFR_SUPPORTED)); } private boolean isFlightRecorderDisabled(IConnectionHandle handle) { - if (cfs != null && cfs.hasCommercialFeatures()) { + if (ConnectionToolkit.isSubstrateVm(handle)){ + // For SVM commercial features may be available but disabled and JFR is still enabled + return !isAvailable(handle); + } else if (cfs != null && cfs.hasCommercialFeatures()) { return !cfs.isCommercialFeaturesEnabled() || JVMSupportToolkit.isFlightRecorderDisabled(handle, false); } else { return JVMSupportToolkit.isFlightRecorderDisabled(handle, false); @@ -127,7 +135,7 @@ public FlightRecorderServiceV2(IConnectionHandle handle) throws ConnectionExcept if (!isDynamicFlightRecorderSupported(handle) && isFlightRecorderDisabled(handle)) { throw new ServiceNotAvailableException(""); //$NON-NLS-1$ } - if (JVMSupportToolkit.isFlightRecorderDisabled(handle, true)) { + if (!ConnectionToolkit.isSubstrateVm(handle) && JVMSupportToolkit.isFlightRecorderDisabled(handle, true)) { throw new ServiceNotAvailableException(""); //$NON-NLS-1$ } connection = handle;