RFR: 8311653: Modify -XshowSettings launcher behavior [v2]

Mandy Chung mchung at openjdk.org
Tue Jul 25 21:04:54 UTC 2023


On Tue, 25 Jul 2023 19:47:16 GMT, Sean Coffey <coffeys at openjdk.org> wrote:

>> Modify the -XshowSettings launcher option to print non-verbose settings details of all components by default. Verbose settings details will be printed via the -XshowSettings:all option. Modify the -XshowSettings option to reject bad values passed to it. Print an error message in such scenarios and abort the VM launch.
>
> Sean Coffey has updated the pull request incrementally with two additional commits since the last revision:
> 
>  - Incorporate review feedback
>  - modify -X output for :all

src/java.base/share/classes/sun/launcher/LauncherHelper.java line 170:

> 168:                  SECURITY_PROVIDERS,
> 169:                  SECURITY_TLS -> SecuritySettings.printSecuritySettings(component, ostream, true);
> 170:             case SYSTEM-> printSystemMetrics();

Nit: space before `->`
Suggestion:

            case SYSTEM -> printSystemMetrics();

src/java.base/share/classes/sun/launcher/LauncherHelper.java line 172:

> 170:             case SYSTEM-> printSystemMetrics();
> 171:             case VM -> printVmSettings(initialHeapSize, maxHeapSize, stackSize);
> 172:             case EMPTY -> printAllSettings(initialHeapSize, maxHeapSize, stackSize, false);

Nit: It seems clearer to name this as `DEFAULT`.

src/java.base/share/classes/sun/launcher/LauncherHelper.java line 191:

> 189: 
> 190:         // case-sensitive check of input flag
> 191:         List<String> validOpts = Arrays.stream(Option.values())

The logic can be simplified by building a map of option name to `Option`.


        Map<String, Option> validOpts = Arrays.stream(Option.values())
                .filter(o -> !o.equals(Option.EMPTY)) // non-valid option
                .collect(Collectors.toMap(o -> o.name()
                                                .toLowerCase(Locale.ROOT)
                                                .replace("_", ":"), Function.identity()));

        String optStr = optionFlag.substring("-XshowSettings:".length());
        Option component = validOpts.get(optStr);
        if (component == null) {
            abort(null, "java.launcher.bad.option", optStr);
        }
        return component;

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/15001#discussion_r1274078900
PR Review Comment: https://git.openjdk.org/jdk/pull/15001#discussion_r1274081324
PR Review Comment: https://git.openjdk.org/jdk/pull/15001#discussion_r1274116417


More information about the core-libs-dev mailing list