On Fri, 20 Jun 2025 22:22:53 GMT, Harshitha Onkar <[email protected]> wrote:
>> Clarify the behaviour of new HeadlessException().getMessage()
>> The spec. is updated to be clear that empty means null, not an empty string.
>
> test/jdk/java/awt/Headless/HeadlessExceptionTest.java line 37:
>
>> 35: public static void main (String[] args) {
>> 36: String nullmsg = new HeadlessException().getMessage();
>> 37: String emptymsg = new HeadlessException("").getMessage();
>
> @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.
Since this test is run on *headless* hosts, the default headless message will
always be present on Linux, therefore `nullmsg` will not be `null`.
If the test is run on headful hosts, the message should be `null` and empty
string correspondingly.
@honkar-jdk Do you suggest a test needs expanding to cover both cases where the
default headless message is present or not?
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25881#discussion_r2163891474