Skip to content

8358526: Clarify behavior of java.awt.HeadlessException constructed with no-args #25881

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

Closed
wants to merge 1 commit into from

Conversation

prrace
Copy link
Contributor

@prrace prrace commented Jun 18, 2025

Clarify the behaviour of new HeadlessException().getMessage()
The spec. is updated to be clear that empty means null, not an empty string.


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-8359951 to be approved

Issues

  • JDK-8358526: Clarify behavior of java.awt.HeadlessException constructed with no-args (Bug - P2)
  • JDK-8359951: Clarify behavior of java.awt.HeadlessException constructed with no-args (CSR)

Reviewers

Reviewing

Using git

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

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

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 25881

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

Using diff file

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

Using Webrev

Link to Webrev Comment

@prrace
Copy link
Contributor Author

prrace commented Jun 18, 2025

/csr

@bridgekeeper
Copy link

bridgekeeper bot commented Jun 18, 2025

👋 Welcome back prr! 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
Copy link

openjdk bot commented Jun 18, 2025

@prrace 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:

8358526: Clarify behavior of java.awt.HeadlessException constructed with no-args

Reviewed-by: aivanov, honkar

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 36 new commits pushed to 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 changed the title 8358526 8358526: Clarify behavior of java.awt.HeadlessException constructed with no-args Jun 18, 2025
@openjdk openjdk bot added csr Pull request needs approved CSR before integration rfr Pull request is ready for review labels Jun 18, 2025
@openjdk
Copy link

openjdk bot commented Jun 18, 2025

@prrace an approved CSR request is already required for this pull request.

@openjdk
Copy link

openjdk bot commented Jun 18, 2025

@prrace The following label will be automatically applied to this pull request:

  • client

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

@mlbridge
Copy link

mlbridge bot commented Jun 18, 2025

Webrevs

@prrace
Copy link
Contributor Author

prrace commented Jun 18, 2025

CSR to be reviewed https://bugs.openjdk.org/browse/JDK-8359951

Copy link
Member

@aivanov-jdk aivanov-jdk left a comment

Choose a reason for hiding this comment

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

Should each constructor specify how the message returned by getMessage is constructed instead of directing to the specification of getMessage for details?

Comment on lines 54 to 56
* For such {@code HeadlessException} the default headless error message
* may be auto-generated for some platforms.
* The text of the default headless message may depend on
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't align, the following text has to be modified too.

The first sentence of the second paragraph, “For such {@code HeadlessException} the default headless error message may be auto-generated for some platforms,” should be replaced with the slightly edited text from the HeadlessException(String) constructor: “For some platforms, the {@code null} detail message may be replaced with the default headless error message.”

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't see why.

@prrace
Copy link
Contributor Author

prrace commented Jun 18, 2025

Should each constructor specify how the message returned by getMessage is constructed instead of directing to the specification of getMessage for details?

100% no. I am not wasting time on that. This whole spec. is getting revamped again in JDK 26 in very short order after this minimal fix is backported to JDK 25

@aivanov-jdk
Copy link
Member

Should each constructor specify how the message returned by getMessage is constructed instead of directing to the specification of getMessage for details?

100% no. I am not wasting time on that. This whole spec. is getting revamped again in JDK 26 in very short order after this minimal fix is backported to JDK 25

I see, thank you for your clarification.

So, this is a minimal update to the specification to quickly address the problem with null vs. empty message, which is being backported to JDK 25; the specification for JDK 26 is going to be overhauled shortly.

Is my understanding correct now?

@prrace
Copy link
Contributor Author

prrace commented Jun 19, 2025

Should each constructor specify how the message returned by getMessage is constructed instead of directing to the specification of getMessage for details?

100% no. I am not wasting time on that. This whole spec. is getting revamped again in JDK 26 in very short order after this minimal fix is backported to JDK 25

I see, thank you for your clarification.

So, this is a minimal update to the specification to quickly address the problem with null vs. empty message, which is being backported to JDK 25; the specification for JDK 26 is going to be overhauled shortly.

Is my understanding correct now?

Right. What I am obliged to do in order to satisfy one specific TCK test. Nothing more.

@aivanov-jdk
Copy link
Member

Right. What I am obliged to do in order to satisfy one specific TCK test. Nothing more.

Thank you! It makes perfect sense.

Looks good to me.

@openjdk openjdk bot added ready Pull request is ready to be integrated and removed csr Pull request needs approved CSR before integration labels Jun 20, 2025
Copy link
Contributor

Choose a reason for hiding this comment

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

do copyright years need to be updated for this file if there's a docs change?

Copy link
Contributor

@honkar-jdk honkar-jdk left a comment

Choose a reason for hiding this comment

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

Updated javadoc and regression test LGTM.

@prrace
Copy link
Contributor Author

prrace commented Jun 20, 2025

/integrate

@openjdk
Copy link

openjdk bot commented Jun 20, 2025

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

Your commit was automatically rebased without conflicts.

@openjdk openjdk bot added the integrated Pull request has been integrated label Jun 20, 2025
@openjdk openjdk bot closed this Jun 20, 2025
@openjdk openjdk bot removed ready Pull request is ready to be integrated rfr Pull request is ready for review labels Jun 20, 2025
Comment on lines +36 to +37
String nullmsg = new HeadlessException().getMessage();
String emptymsg = new HeadlessException("").getMessage();
Copy link
Contributor

@honkar-jdk honkar-jdk Jun 20, 2025

Choose a reason for hiding this comment

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

@prrace I was thinking of a case which would actually throw HeadlessException when run with Djava.awt.headless=true such as creating a frame or robot but the exception msg can be null or default message from GraphicsEnvironment so making it difficult to validate on different platforms. The current test works well to validate both empty and null message.

@openjdk
Copy link

openjdk bot commented Jun 20, 2025

@prrace Pushed as commit 81985d4.

💡 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
client [email protected] integrated Pull request has been integrated
Development

Successfully merging this pull request may close these issues.

4 participants