Skip to content

Commit 894cf6b

Browse files
committed
[GR-42964] Deprecate --enable-monitoring without argument.
PullRequest: graal/13447
2 parents 3fc6561 + dc2c3c7 commit 894cf6b

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

docs/reference-manual/native-image/BuildOptions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The following options are supported across both GraalVM Community and Enterprise
2626
* `--enable-all-security-services`: add all security service classes to a native executable
2727
* `--enable-http`: enable HTTP support in a native executable
2828
* `--enable-https`: enable HTTPS support in a native executable
29-
* `--enable-monitoring`: enable monitoring features that allow the VM to be inspected at run time. Comma-separated list can contain `heapdump`, `jfr`, `jvmstat`, or `all` (defaults to `all` if no argument is provided). For example: `--enable-monitoring=heapdump,jvmstat`.
29+
* `--enable-monitoring`: enable monitoring features that allow the VM to be inspected at run time. Comma-separated list can contain `heapdump`, `jfr`, `jvmstat`, or `all` (deprecated behavior: defaults to `all` if no argument is provided). For example: `--enable-monitoring=heapdump,jfr`.
3030
* `--enable-sbom`: embed a Software Bill of Materials (SBOM) in the executable or shared library for passive inspection. Comma-separated list can contain `cyclonedx` or `strict` (defaults to `cyclonedx` if no argument is provided). The optional `strict` flag aborts the build if any class cannot be matched to a library in the SBOM. For example: `--enable-sbom=cyclonedx,strict`. **GraalVM Enterprise only**
3131
* `--enable-preview`: allow classes to depend on preview features of this release
3232
* `--enable-url-protocols`: list comma-separated URL protocols to enable

substratevm/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ This changelog summarizes major changes to GraalVM Native Image.
1414
* (GR-41096) Support services loaded through the `java.util.ServiceLoader.ModuleServicesLookupIterator`. An example of such service is the `com.sun.jndi.rmi.registry.RegistryContextFactory`.
1515
* (GR-41912) The builder now generated reports for internal errors, which users can share when creating issues. By default, error reports follow the `svm_err_b_<timestamp>_pid<pid>.md` pattern and are created in the working directory. Use `-H:ErrorFile` to adjust the path or filename.
1616
* (GR-36951) Add [RISC-V support](https://medium.com/p/899be38eddd9) for Native Image through the LLVM backend.
17+
* (GR-42964) Deprecate `--enable-monitoring` without an argument. The option will no longer default to `all` in a future release. Instead, please always explicitly specify the list of monitoring features to be enabled (for example, `--enable-monitoring=heapdump,jfr,jvmstat`").
1718

1819
## Version 22.3.0
1920
* (GR-35721) Remove old build output style and the `-H:±BuildOutputUseNewStyle` option.

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/VMInspectionOptions.java

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,39 @@
4444

4545
public final class VMInspectionOptions {
4646
private static final String ENABLE_MONITORING_OPTION = "enable-monitoring";
47+
private static final String MONITORING_DEFAULT_NAME = "<deprecated-default>";
4748
private static final String MONITORING_ALL_NAME = "all";
4849
private static final String MONITORING_HEAPDUMP_NAME = "heapdump";
4950
private static final String MONITORING_JFR_NAME = "jfr";
5051
private static final String MONITORING_JVMSTAT_NAME = "jvmstat";
51-
private static final String MONITORING_ALLOWED_VALUES = "'" + MONITORING_HEAPDUMP_NAME + "', '" + MONITORING_JFR_NAME + "', '" + MONITORING_JVMSTAT_NAME + "', or '" + MONITORING_ALL_NAME +
52-
"' (defaults to '" + MONITORING_ALL_NAME + "' if no argument is provided)";
52+
private static final String MONITORING_ALLOWED_VALUES = "`" + MONITORING_HEAPDUMP_NAME + "`, `" + MONITORING_JFR_NAME + "`, `" + MONITORING_JVMSTAT_NAME + "`, or `" + MONITORING_ALL_NAME +
53+
"` (deprecated behavior: defaults to `" + MONITORING_ALL_NAME + "` if no argument is provided)";
5354

54-
@APIOption(name = ENABLE_MONITORING_OPTION, defaultValue = MONITORING_ALL_NAME) //
55+
@APIOption(name = ENABLE_MONITORING_OPTION, defaultValue = MONITORING_DEFAULT_NAME) //
5556
@Option(help = "Enable monitoring features that allow the VM to be inspected at run time. Comma-separated list can contain " + MONITORING_ALLOWED_VALUES + ". " +
56-
"For example: `--" + ENABLE_MONITORING_OPTION + "=" + MONITORING_HEAPDUMP_NAME + "," + MONITORING_JVMSTAT_NAME + "`.", type = OptionType.User) //
57+
"For example: `--" + ENABLE_MONITORING_OPTION + "=" + MONITORING_HEAPDUMP_NAME + "," + MONITORING_JFR_NAME + "`.", type = OptionType.User) //
5758
public static final HostedOptionKey<LocatableMultiOptionValue.Strings> EnableMonitoringFeatures = new HostedOptionKey<>(LocatableMultiOptionValue.Strings.commaSeparated(),
5859
VMInspectionOptions::validateEnableMonitoringFeatures);
5960

60-
public static void validateEnableMonitoringFeatures(OptionKey<?> optionKey) {
61+
public static void validateEnableMonitoringFeatures(@SuppressWarnings("unused") OptionKey<?> optionKey) {
6162
Set<String> enabledFeatures = getEnabledMonitoringFeatures();
62-
enabledFeatures.removeAll(List.of(MONITORING_HEAPDUMP_NAME, MONITORING_JFR_NAME, MONITORING_JVMSTAT_NAME, MONITORING_ALL_NAME));
63+
if (enabledFeatures.contains(MONITORING_DEFAULT_NAME)) {
64+
System.out.printf(
65+
"Warning: `%s` without an argument is deprecated. Please always explicitly specify the list of monitoring features to be enabled (for example, `%s`).%n",
66+
getDefaultMonitoringCommandArgument(),
67+
SubstrateOptionsParser.commandArgument(EnableMonitoringFeatures, String.join(",", List.of(MONITORING_HEAPDUMP_NAME, MONITORING_JFR_NAME))));
68+
}
69+
enabledFeatures.removeAll(List.of(MONITORING_HEAPDUMP_NAME, MONITORING_JFR_NAME, MONITORING_JVMSTAT_NAME, MONITORING_ALL_NAME, MONITORING_DEFAULT_NAME));
6370
if (!enabledFeatures.isEmpty()) {
64-
throw UserError.abort("The option %s contains invalid value(s): %s. It can only contain %s.", optionKey.getName(), String.join(", ", enabledFeatures), MONITORING_ALLOWED_VALUES);
71+
throw UserError.abort("The `%s` option contains invalid value(s): %s. It can only contain %s.", getDefaultMonitoringCommandArgument(), String.join(", ", enabledFeatures),
72+
MONITORING_ALLOWED_VALUES);
6573
}
6674
}
6775

76+
private static String getDefaultMonitoringCommandArgument() {
77+
return SubstrateOptionsParser.commandArgument(EnableMonitoringFeatures, MONITORING_DEFAULT_NAME);
78+
}
79+
6880
@Fold
6981
public static String getHeapdumpsCommandArgument() {
7082
return SubstrateOptionsParser.commandArgument(EnableMonitoringFeatures, MONITORING_HEAPDUMP_NAME);
@@ -76,7 +88,7 @@ public static Set<String> getEnabledMonitoringFeatures() {
7688

7789
private static boolean hasAllOrKeywordMonitoringSupport(String keyword) {
7890
Set<String> enabledFeatures = getEnabledMonitoringFeatures();
79-
return enabledFeatures.contains(MONITORING_ALL_NAME) || enabledFeatures.contains(keyword);
91+
return enabledFeatures.contains(MONITORING_ALL_NAME) || enabledFeatures.contains(MONITORING_DEFAULT_NAME) || enabledFeatures.contains(keyword);
8092
}
8193

8294
@Fold

0 commit comments

Comments
 (0)