RFR: 8353950: Clipboard interaction on Windows is unstable [v4]
Matthias Bläsing
mblaesing at openjdk.org
Thu May 29 17:30:55 UTC 2025
On Thu, 29 May 2025 16:42:29 GMT, Damon Nguyen <dnguyen at openjdk.org> wrote:
>> Matthias Bläsing has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Add headful key to the jtreg description
>
> src/java.desktop/share/classes/sun/awt/datatransfer/SunClipboard.java line 208:
>
>> 206:
>> 207: try {
>> 208: openClipboard(null);
>
> Can you help me understand why this is better? Seems odd that the try/finally block has `closeClipboard` in the finally block but the `openClipboard` was moved out of the try.
Before the change the call order was inconsistent:
- `ClipboardTransferable`: one call, `openClipboard` is called before the `try`-block
- `WClipboard`: one call with `openClipboard` before the `try`-block, one call with `openClipboard` as first statement in the `try`-block
- `SunClipboard`: three calls with `openClipboard` as first statement inside the `try`-block
I unified these so that in all cases `openClipboard` is called as the last statement before the try-block. The assumption is, that only if `openClipboard` succeeds (does not raise an exception), calling `closeClipboard` makes sense.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/24614#discussion_r2114423928
More information about the client-libs-dev
mailing list