Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5086496

REGRESSION: Can't copy/paste/cut in native components with an applet

XMLWordPrintable

    • x86
    • linux

      Name: gm110360 Date: 08/12/2004


      FULL PRODUCT VERSION :
      java version "1.5.0-beta2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta2-b51)
      Java HotSpot(TM) Client VM (build 1.5.0-beta2-b51, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Linux jupiter 2.6.3-7mdk #1 Wed Mar 17 15:56:42 CET 2004 i686 unknown unknown GNU/Linux


      A DESCRIPTION OF THE PROBLEM :
      Copy/Paste/Cut in *native* components no longer works in the presense of a SecurityManager which forbids access to the clipboard. Copying simply simply doesn't work while pasting throws a security exception. This seems to occur only if the dialog is modal, I would guess because the SecurityManager sees untrusted code on the stack (the show() or setVisible(true)) call.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run the attached applet in the appletviewer.
      2. Try pasting something into the text field via shift+insert or middle click.
      3. Try copying from the text field with ctrl+insert or middle clicking.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Copying and pasting (and cutting) should work.
      ACTUAL -
      In step 2 (for shift+insert), an exception is thrown (stack trace attached).
      Step 3 does nothing (pasting to a different X window doesn't produce the copied text).


      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      Exception stack trace from step 2:
      java.lang.reflect.InvocationTargetException
              at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
              at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
              at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
              at java.lang.reflect.Method.invoke(Method.java:582)
              at sun.awt.X11.ComponentAccessor.processEvent(ComponentAccessor.java:277)
              at sun.awt.X11.XTextFieldPeer.handleJavaKeyEvent(XTextFieldPeer.java:360)
              at sun.awt.X11.XComponentPeer.handleEvent(XComponentPeer.java:614)
              at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:699)
              at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:916)
              at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:794)
              at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:632)
              at java.awt.Component.dispatchEventImpl(Component.java:3819)
              at java.awt.Component.dispatchEvent(Component.java:3781)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
              at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
              at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
              at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:153)
              at java.awt.Dialog$1.run(Dialog.java:514)
              at java.awt.Dialog.show(Dialog.java:535)
              at TestApplet$1.windowOpened(TestApplet.java:25)
              at java.awt.Window.processWindowEvent(Window.java:1177)
              at java.awt.Window.processEvent(Window.java:1138)
              at java.awt.Component.dispatchEventImpl(Component.java:3933)
              at java.awt.Container.dispatchEventImpl(Container.java:2019)
              at java.awt.Window.dispatchEventImpl(Window.java:1764)
              at java.awt.Component.dispatchEvent(Component.java:3781)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
              at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
              at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
      Caused by: java.security.AccessControlException: access denied (java.awt.AWTPermission accessClipboard)
              at java.security.AccessControlContext.checkPermission(AccessControlContext.java:264)
              at java.security.AccessController.checkPermission(AccessController.java:427)
              at java.lang.SecurityManager.checkPermission(SecurityManager.java:524)
              at java.lang.SecurityManager.checkSystemClipboardAccess(SecurityManager.java:1368)
              at sun.awt.X11.XToolkit.getSystemClipboard(XToolkit.java:762)
              at sun.awt.X11.XTextTransferHelper.doClipboardAction(XTextTransferHelper.java:125)
              at sun.awt.X11.XTextTransferHelper.processKeyEvent(XTextTransferHelper.java:99)
              at sun.awt.X11.XTextFieldPeer$XAWTTextField.processComponentKeyEvent(XTextFieldPeer.java:641)
              at javax.swing.JComponent.processKeyEvent(JComponent.java:2680)
              at java.awt.Component.processEvent(Component.java:5242)
              at java.awt.Container.processEvent(Container.java:1961)
              ... 32 more

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      Java code:

      import javax.swing.*;
      import java.awt.*;
      import java.awt.event.*;
      import java.applet.*;

      public class TestApplet extends Applet{
        
        public void start(){
          
          final Frame f = new Frame();
          f.setBounds(200, 200, 200, 100);
          f.addWindowListener(new WindowAdapter(){
            public void windowOpened(WindowEvent evt){
              Dialog dialog = new Dialog(f);
              Container contentPane = dialog;
              contentPane.setLayout(new BorderLayout());
              contentPane.add(new TextField());
              
              dialog.setModal(true);
              
              dialog.setBounds(200, 200, 200, 100);
          
              dialog.show();
            }
          });
          f.show();
        }
      }


      HTML code:
      <APPLET code="TestApplet" WIDTH="200" HEIGHT="100"></APPLET>
      ---------- END SOURCE ----------

      Release Regression From : 1.4.2
      The above release value was the last known release where this
      bug was known to work. Since then there has been a regression.

      (Incident Review ID: 295945)
      ======================================================================

            agerasimsunw Alexander Gerasimov (Inactive)
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: