RFR: 8344063: Remove doPrivileged calls from swing classes in the java.desktop module
Kevin Rushforth
kcr at openjdk.org
Thu Nov 14 17:56:51 UTC 2024
On Wed, 13 Nov 2024 23:19:32 GMT, Phil Race <prr at openjdk.org> wrote:
> This is the first of a number of PRs to remove doPrivileged uses in client libraries.
> These calls are obsolete dead code after JEP 486.
>
> I have run all our automated tests, including JCK tests, and manually tested SwingSet.
>
> One thing I might have missed in a couple of cases is that it seems that javac doesn't seem to notice if you leave an un-needed SuppressWarnings("removal") annotation.
>
> As per the bug report I am limiting (as much as I can) what I touch here to be just the immediate consequences of removing doPrivileged calls. These changes are plenty enough as it is.
All looks like what I would expect.
src/java.desktop/share/classes/javax/swing/AbstractAction.java line 85:
> 83: synchronized(AbstractAction.class) {
> 84: if (RECONFIGURE_ON_NULL == null) {
> 85: RECONFIGURE_ON_NULL = Boolean.getBoolean("swing.actions.reconfigureOnNull");
This seems fine because the default value you were passing (false) is also the default of `Boolean.getBoolean`
test/jdk/java/awt/im/memoryleak/InputContextMemoryLeakTest.java line 69:
> 67: p = new WeakReference<JPanel>(jp);
> 68: jp.add(tf);
> 69: frame.add(jp);
text = new WeakReference<JTextField>(new JTextField("Text"));
p = new WeakReference<JPanel>(new JPanel(new FlowLayout()));
// assume that p.get() and text.get() are always non-null. What coulld go wrong?
p.get().add(text.get());
Well oops. So this is the test failure fix you mentioned offline. This, and the below change, looks good.
-------------
Marked as reviewed by kcr (Author).
PR Review: https://git.openjdk.org/jdk/pull/22090#pullrequestreview-2436722462
PR Review Comment: https://git.openjdk.org/jdk/pull/22090#discussion_r1842605118
PR Review Comment: https://git.openjdk.org/jdk/pull/22090#discussion_r1842653721
More information about the client-libs-dev
mailing list