RFR: 8352109: java/awt/Desktop/MailTest.java fails in platforms where Action.MAIL is not supported

Alexey Ivanov aivanov at openjdk.org
Tue Mar 18 17:56:10 UTC 2025


On Sun, 16 Mar 2025 08:56:24 GMT, Manukumar V S <mvs at openjdk.org> wrote:

> **Issue**
> java/awt/Desktop/MailTest.java fails in platforms where Action.MAIL is not supported
> 
> **Reason**
> In `MailTest.java`, there is a condition check(`if (!desktop.isSupported(Desktop.Action.MAIL))`) which will force pass the test if the corresponding 'Action' is not supported by the platform. But, apparently, this is not working good and the code flow went past this and fails in desktop.mail() method with an UnsupportedOperationException. 
> 
> **Fix**
> Even though we are calling `PassFailJFrame.forcePass()` if the 'Action.MAIL' is unsupported, the PassFailJFrame just count downs a latch and the actual action will be taken later only(in `awaitAndCheck()`). But at the meantime, the desktop.mail() call gets executed in the constructor of MailTest() and it will result in an UnsupportedOperationException. So, the fix is to return from the constructor immediately if the operation is 'unsupported'.
> 
> **Testing**
> This is a manual test, so it is tested locally and found to be working fine.

Bump the copyright year, too.

test/jdk/java/awt/Desktop/MailTest.java line 63:

> 61:             PassFailJFrame.forcePass();
> 62:             return;
> 63:         }

A better and could be to move these checks into the `main` method and return right away without using `PassFailJFrame` at all. This would avoid creating and showing the UI before immediately disposing of it.

A `jtreg.SkippedException` could be thrown instead of passing the test — this way we'll be able to know if the test is never in an environment where it does perform the test actions.

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

Changes requested by aivanov (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/24072#pullrequestreview-2695655305
PR Review Comment: https://git.openjdk.org/jdk/pull/24072#discussion_r2001645783


More information about the client-libs-dev mailing list