harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vasily Zakharov (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HARMONY-3479) [classlib][awt][netbeans] javax.swing.TransferHandler.getPasteAction().actionPerformed() doesn't check if accessClipboard is allowed
Date Fri, 23 Mar 2007 14:30:32 GMT

    [ https://issues.apache.org/jira/browse/HARMONY-3479?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12483615
] 

Vasily Zakharov commented on HARMONY-3479:
------------------------------------------

Andrey, thank you for the investigation.

Yes, new JComponent.getTransferHandler() returns null by default (both on RI and Harmony),
however, Harmony only tries to access clipboard if transferHandler is not null, while RI seemingly
does it anyway. Looks like this is the issue.

Netbeans has a rather tricky security manager (org.netbeans.TopSecurityManager) that is used
to replace standard Swing clipboard with Netbeans' own. It interrupts standard clipboard operations
with a SecurityException to perform Netbeans clipboard operations instead. Really strange
way to do things, I agree, but the code is really complex and the comments around it suggest
it's really necessary to avoid infinite hangs in some system threads on JDK 1.5.

My guess is we better follow RI way in this aspect. I'm moving this issue to Swing component
and going to prepare a patch to TransferHandler to obtain clipboard before checking if transferHandler
is null.


> [classlib][awt][netbeans] javax.swing.TransferHandler.getPasteAction().actionPerformed()
doesn't check if accessClipboard is allowed
> ------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-3479
>                 URL: https://issues.apache.org/jira/browse/HARMONY-3479
>             Project: Harmony
>          Issue Type: Bug
>          Components: App-Oriented Bug Reports, Classlib
>            Reporter: Vasily Zakharov
>
> Consider the following test:
> import java.awt.AWTPermission;
> import java.awt.event.ActionEvent;
> import java.security.Permission;
> import javax.swing.Action;
> import javax.swing.JPanel;
> import javax.swing.TransferHandler;
> public class Test {
>     private static boolean flag = false;
>     public static void main(String args[]) throws Exception {
>         System.setSecurityManager(new TestSecurityManager());
>         Action action = TransferHandler.getPasteAction();
>         ActionEvent event = new ActionEvent(new JPanel(), 0, "");
>         System.out.println("Before");
>         action.actionPerformed(event);
>         System.out.println("After");
>         System.out.println(flag ? "SUCCESS" : "FAIL");
>     }
>     private static class TestSecurityManager extends SecurityManager {
>         public void checkPermission(Permission perm) {
>             if ((perm instanceof AWTPermission)
>                     && "accessClipboard".equals(perm.getName())) {
>                 flag = true;
>                 new Throwable().printStackTrace();
>             }
>         }
>     }
> }
> I inserted stack printing to see the stack of calls that leads to security check on RI.
> Output on RI:
> Before
> java.lang.Throwable
>         at Test$TestSecurityManager.checkPermission(Test.java:27)
>         at java.lang.SecurityManager.checkSystemClipboardAccess(Unknown Source)
>         at com.sun.java.swing.SwingUtilities2.canAccessSystemClipboard(Unknown Source)
>         at javax.swing.TransferHandler$TransferAction.getClipboard(Unknown Source)
>         at javax.swing.TransferHandler$TransferAction.actionPerformed(Unknown Source)
>         at Test.main(Test.java:17)
> java.lang.Throwable
>         at Test$TestSecurityManager.checkPermission(Test.java:27)
>         at java.lang.SecurityManager.checkSystemClipboardAccess(Unknown Source)
>         at sun.awt.windows.WToolkit.getSystemClipboard(Unknown Source)
>         at javax.swing.TransferHandler$TransferAction.getClipboard(Unknown Source)
>         at javax.swing.TransferHandler$TransferAction.actionPerformed(Unknown Source)
>         at Test.main(Test.java:17)
> After
> SUCCESS
> Output on Harmony:
> Before
> After
> FAIL
> The same problem also occurs for getCopyAction() and getCutAction(), probably this is
the same problem.
> At first look it seems to be a Swing problem, but my guess is the actual problem really
lays in the AWT layer.
> This issue was discovered while trying to run Netbeans on Harmony.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message