RFR: 8344896: Remove obsolete checks for AWTPermission accessClipboard

Alexander Zvegintsev azvegint at openjdk.org
Mon Nov 25 15:46:16 UTC 2024


On Mon, 25 Nov 2024 06:53:43 GMT, Phil Race <prr at openjdk.org> wrote:

> This removes the SecurityManager related checks for clipboard access  and methods which exist solely to support that.
> 
> One interesting thing is that there are two places where a method "canAccessSystemClipboard()"  was not only about the SM. 
> In SwingUtilities and InputEvent it would return false in headless mode, regardless of whether there is an SM.
> This means I have left the methods in place, behaving the same as before in headless mode.
> We may be able to further simplify this later  but it will be clearer with the SM-only logic removed and out of scope for this fix.

few tests use this permission indirectly:


./test/jdk/java/awt/datatransfer/Independence/IndependenceSwingTest.java:94:            sm.checkPermission(new AWTPermission("accessClipboard"));
./test/jdk/java/awt/datatransfer/Independence/IndependenceAWTTest.java:87:            sm.checkPermission(new AWTPermission("accessClipboard"));
./test/jdk/java/awt/datatransfer/SystemSelection/SystemSelectionSwingTest.java:87:                sm.checkPermission(new AWTPermission("accessClipboard"));
./test/jdk/java/awt/datatransfer/SystemSelection/SystemSelectionAWTTest.java:86:                sm.checkPermission(new AWTPermission("accessClipboard"));

src/java.desktop/share/classes/java/awt/event/InputEvent.java line 395:

> 393:             if (sm != null) {
> 394:                 try {
> 395:                     sm.checkPermission(AWTPermissions.ACCESS_CLIPBOARD_PERMISSION);

`import sun.awt.AWTPermissions;` can be removed

src/java.desktop/unix/classes/sun/awt/X11/XToolkit.java line 1239:

> 1237:         SecurityManager security = System.getSecurityManager();
> 1238:         if (security != null) {
> 1239:             security.checkPermission(AWTPermissions.ACCESS_CLIPBOARD_PERMISSION);

`import java.util.Hashtable;`
`import sun.awt.AWTPermissions;`

can be removed

src/java.desktop/windows/classes/sun/awt/windows/WToolkit.java line 684:

> 682:         SecurityManager security = System.getSecurityManager();
> 683:         if (security != null) {
> 684:             security.checkPermission(AWTPermissions.ACCESS_CLIPBOARD_PERMISSION);

unneeded `import sun.awt.AWTPermissions;`

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

PR Review: https://git.openjdk.org/jdk/pull/22356#pullrequestreview-2458363303
PR Review Comment: https://git.openjdk.org/jdk/pull/22356#discussion_r1856571037
PR Review Comment: https://git.openjdk.org/jdk/pull/22356#discussion_r1856795935
PR Review Comment: https://git.openjdk.org/jdk/pull/22356#discussion_r1856798108


More information about the client-libs-dev mailing list