RFR: 8344059: Remove doPrivileged calls from windows platform sources in the java.desktop module [v3]
Phil Race
prr at openjdk.org
Thu Nov 14 23:49:09 UTC 2024
On Thu, 14 Nov 2024 18:42:30 GMT, Kevin Rushforth <kcr at openjdk.org> wrote:
>> src/java.desktop/windows/classes/sun/awt/windows/WFramePeer.java line 84:
>>
>>> 82: private static final boolean keepOnMinimize = "true".equals(
>>> 83: new GetPropertyAction(
>>> 84: "sun.awt.keepWorkingSetOnMinimize"));
>>
>> Shouldn't this be changed to `System.getProperty`? `GetPropertyAction` implements `PrivilegedAction` and is deprecated for removal (so I'm surprised that this doesn't generate a fatal warning).
>
> Even more to the point: this won't work the way it used to: the former call to `doPrivileged` returned a String (the value of `GetPropertyAction::run`). The new code will use the `GetPropertyAction` instance itself without executing the run method, so you will be comparing a string `"true"` to the new `GetPropertyAction` instance, which will always be false since they aren't of the same type, regardless of what you set the property to. We had a similar issue with one of our JavaFX PRs that was only discovered by testing.
Yes, this is not "RUNNING" the action so it isn't right.
And we should change it to a simple System.getProperty as Kevin points out.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/22083#discussion_r1843014336
More information about the client-libs-dev
mailing list