jdk/src/java.desktop/share/classes/java/awt/AWTEvent.java
changeset 40719 4ae72a69bd3b
parent 35667 ed476aba94de
child 43722 25ba19c20260
equal deleted inserted replaced
40718:fe2adbe4d101 40719:4ae72a69bd3b
   280                 public void setBData(AWTEvent ev, byte[] bdata) {
   280                 public void setBData(AWTEvent ev, byte[] bdata) {
   281                     ev.bdata = bdata;
   281                     ev.bdata = bdata;
   282                 }
   282                 }
   283 
   283 
   284             });
   284             });
   285     }
       
   286 
       
   287     private static synchronized Field get_InputEvent_CanAccessSystemClipboard() {
       
   288         if (inputEvent_CanAccessSystemClipboard_Field == null) {
       
   289             inputEvent_CanAccessSystemClipboard_Field =
       
   290                 java.security.AccessController.doPrivileged(
       
   291                     new java.security.PrivilegedAction<Field>() {
       
   292                             public Field run() {
       
   293                                 Field field = null;
       
   294                                 try {
       
   295                                     field = InputEvent.class.
       
   296                                         getDeclaredField("canAccessSystemClipboard");
       
   297                                     field.setAccessible(true);
       
   298                                     return field;
       
   299                                 } catch (SecurityException e) {
       
   300                                     if (log.isLoggable(PlatformLogger.Level.FINE)) {
       
   301                                         log.fine("AWTEvent.get_InputEvent_CanAccessSystemClipboard() got SecurityException ", e);
       
   302                                     }
       
   303                                 } catch (NoSuchFieldException e) {
       
   304                                     if (log.isLoggable(PlatformLogger.Level.FINE)) {
       
   305                                         log.fine("AWTEvent.get_InputEvent_CanAccessSystemClipboard() got NoSuchFieldException ", e);
       
   306                                     }
       
   307                                 }
       
   308                                 return null;
       
   309                             }
       
   310                         });
       
   311         }
       
   312 
       
   313         return inputEvent_CanAccessSystemClipboard_Field;
       
   314     }
   285     }
   315 
   286 
   316     /**
   287     /**
   317      * Initialize JNI field and method IDs for fields that may be
   288      * Initialize JNI field and method IDs for fields that may be
   318      * accessed from C.
   289      * accessed from C.
   591      */
   562      */
   592     void copyPrivateDataInto(AWTEvent that) {
   563     void copyPrivateDataInto(AWTEvent that) {
   593         that.bdata = this.bdata;
   564         that.bdata = this.bdata;
   594         // Copy canAccessSystemClipboard value from this into that.
   565         // Copy canAccessSystemClipboard value from this into that.
   595         if (this instanceof InputEvent && that instanceof InputEvent) {
   566         if (this instanceof InputEvent && that instanceof InputEvent) {
   596             Field field = get_InputEvent_CanAccessSystemClipboard();
   567 
   597             if (field != null) {
   568             AWTAccessor.InputEventAccessor accessor
   598                 try {
   569                     = AWTAccessor.getInputEventAccessor();
   599                     boolean b = field.getBoolean(this);
   570 
   600                     field.setBoolean(that, b);
   571             boolean b = accessor.canAccessSystemClipboard((InputEvent) this);
   601                 } catch(IllegalAccessException e) {
   572             accessor.setCanAccessSystemClipboard((InputEvent) that, b);
   602                     if (log.isLoggable(PlatformLogger.Level.FINE)) {
       
   603                         log.fine("AWTEvent.copyPrivateDataInto() got IllegalAccessException ", e);
       
   604                     }
       
   605                 }
       
   606             }
       
   607         }
   573         }
   608         that.isSystemGenerated = this.isSystemGenerated;
   574         that.isSystemGenerated = this.isSystemGenerated;
   609     }
   575     }
   610 
   576 
   611     void dispatched() {
   577     void dispatched() {
   612         if (this instanceof InputEvent) {
   578         if (this instanceof InputEvent) {
   613             Field field = get_InputEvent_CanAccessSystemClipboard();
   579             AWTAccessor.getInputEventAccessor().
   614             if (field != null) {
   580                     setCanAccessSystemClipboard((InputEvent) this, false);
   615                 try {
       
   616                     field.setBoolean(this, false);
       
   617                 } catch(IllegalAccessException e) {
       
   618                     if (log.isLoggable(PlatformLogger.Level.FINE)) {
       
   619                         log.fine("AWTEvent.dispatched() got IllegalAccessException ", e);
       
   620                     }
       
   621                 }
       
   622             }
       
   623         }
   581         }
   624     }
   582     }
   625 } // class AWTEvent
   583 } // class AWTEvent