[jdk8u-dev] RFR: 8274893: Update java.desktop classes to use try-with-resources [v2]

Timofei Pushkin tpushkin at openjdk.org
Mon Sep 1 12:54:33 UTC 2025


On Mon, 1 Sep 2025 11:51:18 GMT, Andrey Turbanov <aturbanov at openjdk.org> wrote:

>> There was in the original change but in this JDK try-with-resources on an existing variable is not possible (no JDK-7196163), so I fell back to try-finally. This is not the only place where I've done this, see [832c3c3](https://github.com/openjdk/jdk8u-dev/pull/686/commits/832c3c3bb4c132b025e7d3043b40be0d2d025a95).
>> 
>> Alternatives are to either create a copy variable for try-with-resources (which also must be used inside it to prevent a compiler warning) or move all interactions with the variable inside try-with-resources — both diverge code from the original change and the pre-existing code so I decided against them.
>
> Shouldn't we revert formatting changes here, then?

I wasn't sure what would be the best here: keeping the existing formatting to changing it to be closer to the backported change — and went with the latter.

Since I don't really have a strong preference, reverted to the old one now as you suggest.

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

PR Review Comment: https://git.openjdk.org/jdk8u-dev/pull/686#discussion_r2313878810


More information about the jdk8u-dev mailing list