Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8311653: Modify -XshowSettings launcher behavior #15001

Closed
wants to merge 7 commits into from

Conversation

coffeys
Copy link
Contributor

@coffeys coffeys commented Jul 24, 2023

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.


Progress

  • Change must be properly reviewed (1 review required, with at least 1 Reviewer)
  • Change must not contain extraneous whitespace
  • Commit message must refer to an issue
  • Change requires CSR request JDK-8312593 to be approved

Issues

  • JDK-8311653: Modify -XshowSettings launcher behavior (Enhancement - P4)
  • JDK-8312593: Modify -XshowSettings launcher behavior (CSR)

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/15001/head:pull/15001
$ git checkout pull/15001

Update a local copy of the PR:
$ git checkout pull/15001
$ git pull https://git.openjdk.org/jdk.git pull/15001/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 15001

View PR using the GUI difftool:
$ git pr show -t 15001

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/15001.diff

Webrev

Link to Webrev Comment

@coffeys coffeys changed the title 8311653 show settings tweak 8311653: Modify -XshowSettings launcher behavior Jul 24, 2023
@bridgekeeper
Copy link

bridgekeeper bot commented Jul 24, 2023

👋 Welcome back coffeys! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@openjdk openjdk bot added csr Pull request needs approved CSR before integration rfr Pull request is ready for review labels Jul 24, 2023
@openjdk
Copy link

openjdk bot commented Jul 24, 2023

@coffeys The following labels will be automatically applied to this pull request:

  • core-libs
  • hotspot-runtime

When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command.

@openjdk openjdk bot added hotspot-runtime hotspot-runtime-dev@openjdk.org core-libs core-libs-dev@openjdk.org labels Jul 24, 2023
@coffeys
Copy link
Contributor Author

coffeys commented Jul 24, 2023

/label remove hotspot-runtime

@openjdk openjdk bot removed the hotspot-runtime hotspot-runtime-dev@openjdk.org label Jul 24, 2023
@openjdk
Copy link

openjdk bot commented Jul 24, 2023

@coffeys
The hotspot-runtime label was successfully removed.

@mlbridge
Copy link

mlbridge bot commented Jul 24, 2023

Webrevs

@AlanBateman
Copy link
Contributor

This looks quit good, I'm just wondering about the usage messages for -XshowSetting and -XshowSetting:all as they both say "show all settings and continue". I think we'll need to adjust the first one to say that it just shows a summary of the settings.

Comment on lines 232 to 233
Valid values are \"all\", \"locale\", \"properties\",\"security\",\
\"system\"(Linux only), \"vm\".\n\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: space after commas missing.

Suggested change
Valid values are \"all\", \"locale\", \"properties\",\"security\",\
\"system\"(Linux only), \"vm\".\n\
Valid values are \"all\", \"locale\", \"properties\", \"security\", \
\"system\"(Linux only), \"vm\".\n\

@@ -335,6 +317,11 @@ private static void printLocales() {
}

private static void printSystemMetrics() {
// only Linux supported
if (!OperatingSystem.isLinux()) {
abort(null, "java.launcher.bad.option");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
abort(null, "java.launcher.bad.option");
abort(null, "java.launcher.bad.option", "system");

maybe the isLinux check can be moved to showSettings and fall through to abort with the unmatched case.

String optStr = opts.length > 1
? opts[1].trim()
: "all";
String optStr = Arrays.stream(opts).skip(1).findFirst().orElse("").trim();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-XshowSettings:locale:junk should abort but printLocale will be called instead.

Comment on lines 131 to 132
* suboption values include "all", "locale", "properties", "security",
* "system"(Linux only) and "vm". Help message printed for bad value.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* suboption values include "all", "locale", "properties", "security",
* "system"(Linux only) and "vm". Help message printed for bad value.
* Suboption values include "all", "locale", "properties", "security",
* "system" (Linux only) and "vm". A help message is printed for an unknown suboption value.

Comment on lines 158 to 164
case "all" -> printAllSettings(true, initialHeapSize, maxHeapSize, stackSize);
case "locale" -> printLocale(true);
case "properties" -> printProperties();
case "security" -> SecuritySettings.printSecuritySettings(opts, ostream, true);
case "system" -> printSystemMetrics();
case "vm" -> printVmSettings(initialHeapSize, maxHeapSize, stackSize);
case "" -> printAllSettings(false, initialHeapSize, maxHeapSize, stackSize);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's mix in the arguments of where the "verbose" option is included.
Can they be consistent? (For example put the verbose option as the last argument).

}
}

/*
* prints the main vm settings subopt/section
* prints all available settings. Verbose option.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't take too many shortcuts in writing the description. Complete sentences are nice.

@coffeys
Copy link
Contributor Author

coffeys commented Jul 25, 2023

Thanks for the feedback to date. I think I've captured all of it in recent update.

main changes:
I've tightened up validation of input values to -XshowSettings and improved testing in this area.
Updated java -X output to highlight difference between -XshowSettings and -XshowSettings:all

SECURITY_PROPERTIES,
SECURITY_PROVIDERS,
SECURITY_TLS -> SecuritySettings.printSecuritySettings(component, ostream, true);
case SYSTEM-> printSystemMetrics();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: space before ->

Suggested change
case SYSTEM-> printSystemMetrics();
case SYSTEM -> printSystemMetrics();

SECURITY_TLS -> SecuritySettings.printSecuritySettings(component, ostream, true);
case SYSTEM-> printSystemMetrics();
case VM -> printVmSettings(initialHeapSize, maxHeapSize, stackSize);
case EMPTY -> printAllSettings(initialHeapSize, maxHeapSize, stackSize, false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: It seems clearer to name this as DEFAULT.

}

// case-sensitive check of input flag
List<String> validOpts = Arrays.stream(Option.values())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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;
        

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good suggestion Mandy! Incorporated this with latest changes.

@openjdk openjdk bot removed the csr Pull request needs approved CSR before integration label Jul 26, 2023
Copy link
Member

@mlchung mlchung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.

Regarding the CSR, the specification change says:

Bad options such as -XshowSettings:bad will no longer print any settings information. Instead a warning and help message is printed and the VM launch is aborted.

This should be updated as it will abort with an error message if the option is invalid. No warning and help message is printed.

@openjdk
Copy link

openjdk bot commented Jul 26, 2023

@coffeys This change now passes all automated pre-integration checks.

ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details.

After integration, the commit message for the final commit will be:

8311653: Modify -XshowSettings launcher behavior

Reviewed-by: mchung, rriggs

You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed.

At the time when this comment was updated there had been 9 new commits pushed to the master branch:

  • a9d21c6: 8313081: MonitoringSupport_lock should be unconditionally initialized after 8304074
  • 4c2e54f: 8309088: security/infra/java/security/cert/CertPathValidator/certification/AmazonCA.java fails
  • 830413f: 8313087: DerValue::toString should output a hex view of the values in byte array
  • 7412193: 4800398: (ch spec) Clarify Channels.newChannel(InputStream) spec
  • e7726fb: 8313155: Problem list some JUnit-based tests in test/jdk/java/lang/invoke
  • 02a0473: 8312445: Array types in annotation elements show square brackets twice
  • c22cadf: 8312526: Test dk/jfr/event/oldobject/TestHeapDeep.java failed: Could not find ChainNode
  • cc2a75e: 8312619: Strange error message when switching over long
  • 1f81e5b: 8312229: Crash involving yield, switch and anonymous classes

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.

➡️ To integrate this PR with the above commit message to the master branch, type /integrate in a new comment.

@openjdk openjdk bot added the ready Pull request is ready to be integrated label Jul 26, 2023
Copy link
Contributor

@RogerRiggs RogerRiggs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@coffeys
Copy link
Contributor Author

coffeys commented Jul 27, 2023

Thanks Mandy. CSR updated.

/integrate

@openjdk
Copy link

openjdk bot commented Jul 27, 2023

Going to push as commit 36d578c.
Since your change was applied there have been 9 commits pushed to the master branch:

  • a9d21c6: 8313081: MonitoringSupport_lock should be unconditionally initialized after 8304074
  • 4c2e54f: 8309088: security/infra/java/security/cert/CertPathValidator/certification/AmazonCA.java fails
  • 830413f: 8313087: DerValue::toString should output a hex view of the values in byte array
  • 7412193: 4800398: (ch spec) Clarify Channels.newChannel(InputStream) spec
  • e7726fb: 8313155: Problem list some JUnit-based tests in test/jdk/java/lang/invoke
  • 02a0473: 8312445: Array types in annotation elements show square brackets twice
  • c22cadf: 8312526: Test dk/jfr/event/oldobject/TestHeapDeep.java failed: Could not find ChainNode
  • cc2a75e: 8312619: Strange error message when switching over long
  • 1f81e5b: 8312229: Crash involving yield, switch and anonymous classes

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jul 27, 2023
@openjdk openjdk bot closed this Jul 27, 2023
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jul 27, 2023
@openjdk
Copy link

openjdk bot commented Jul 27, 2023

@coffeys Pushed as commit 36d578c.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core-libs core-libs-dev@openjdk.org integrated Pull request has been integrated
4 participants