1 /*
   2  * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package sun.awt;
  27 
  28 import jdk.internal.misc.Unsafe;
  29 
  30 import javax.accessibility.AccessibleContext;
  31 import java.awt.*;
  32 import java.awt.event.FocusEvent.Cause;
  33 import java.awt.dnd.DragSourceContext;
  34 import java.awt.dnd.DropTargetContext;
  35 import java.awt.dnd.peer.DragSourceContextPeer;
  36 import java.awt.dnd.peer.DropTargetContextPeer;
  37 import java.awt.event.AWTEventListener;
  38 import java.awt.event.InputEvent;
  39 import java.awt.event.InvocationEvent;
  40 import java.awt.event.KeyEvent;
  41 import java.awt.event.MouseEvent;
  42 import java.awt.geom.Point2D;
  43 import java.awt.image.BufferStrategy;
  44 import java.awt.peer.ComponentPeer;
  45 
  46 import java.awt.peer.MenuComponentPeer;
  47 import java.lang.reflect.InvocationTargetException;
  48 import java.security.AccessControlContext;
  49 
  50 import java.io.File;
  51 import java.util.ResourceBundle;
  52 import java.util.Vector;
  53 import javax.accessibility.AccessibleBundle;
  54 
  55 /**
  56  * The AWTAccessor utility class.
  57  * The main purpose of this class is to enable accessing
  58  * private and package-private fields of classes from
  59  * different classes/packages. See sun.misc.SharedSecretes
  60  * for another example.
  61  */
  62 public final class AWTAccessor {
  63 
  64     private static final Unsafe unsafe = Unsafe.getUnsafe();
  65 
  66     /*
  67      * We don't need any objects of this class.
  68      * It's rather a collection of static methods
  69      * and interfaces.
  70      */
  71     private AWTAccessor() {
  72     }
  73 
  74     /*
  75      * An interface of accessor for the java.awt.Component class.
  76      */
  77     public interface ComponentAccessor {
  78         /*
  79          * Sets whether the native background erase for a component
  80          * has been disabled via SunToolkit.disableBackgroundErase().
  81          */
  82         void setBackgroundEraseDisabled(Component comp, boolean disabled);
  83         /*
  84          * Indicates whether the native background erase for a
  85          * component has been disabled via
  86          * SunToolkit.disableBackgroundErase().
  87          */
  88         boolean getBackgroundEraseDisabled(Component comp);
  89         /*
  90          *
  91          * Gets the bounds of this component in the form of a
  92          * {@code Rectangle} object. The bounds specify this
  93          * component's width, height, and location relative to
  94          * its parent.
  95          */
  96         Rectangle getBounds(Component comp);
  97 
  98         /**
  99          * Sets GraphicsConfiguration value for the component.
 100          */
 101         void setGraphicsConfiguration(Component comp, GraphicsConfiguration gc);
 102         /*
 103          * Requests focus to the component.
 104          */
 105         void requestFocus(Component comp, Cause cause);
 106         /*
 107          * Determines if the component can gain focus.
 108          */
 109         boolean canBeFocusOwner(Component comp);
 110 
 111         /**
 112          * Returns whether the component is visible without invoking
 113          * any client code.
 114          */
 115         boolean isVisible(Component comp);
 116 
 117         /**
 118          * Sets the RequestFocusController.
 119          */
 120         void setRequestFocusController(RequestFocusController requestController);
 121 
 122         /**
 123          * Returns the appContext of the component.
 124          */
 125         AppContext getAppContext(Component comp);
 126 
 127         /**
 128          * Sets the appContext of the component.
 129          */
 130         void setAppContext(Component comp, AppContext appContext);
 131 
 132         /**
 133          * Returns the parent of the component.
 134          */
 135         Container getParent(Component comp);
 136 
 137         /**
 138          * Sets the parent of the component to the specified parent.
 139          */
 140         void setParent(Component comp, Container parent);
 141 
 142         /**
 143          * Resizes the component to the specified width and height.
 144          */
 145         void setSize(Component comp, int width, int height);
 146 
 147         /**
 148          * Returns the location of the component.
 149          */
 150         Point getLocation(Component comp);
 151 
 152         /**
 153          * Moves the component to the new location.
 154          */
 155         void setLocation(Component comp, int x, int y);
 156 
 157         /**
 158          * Determines whether this component is enabled.
 159          */
 160         boolean isEnabled(Component comp);
 161 
 162         /**
 163          * Determines whether this component is displayable.
 164          */
 165         boolean isDisplayable(Component comp);
 166 
 167         /**
 168          * Gets the cursor set in the component.
 169          */
 170         Cursor getCursor(Component comp);
 171 
 172         /**
 173          * Returns the peer of the component.
 174          */
 175         <T extends ComponentPeer> T getPeer(Component comp);
 176 
 177         /**
 178          * Sets the peer of the component to the specified peer.
 179          */
 180         void setPeer(Component comp, ComponentPeer peer);
 181 
 182         /**
 183          * Determines whether this component is lightweight.
 184          */
 185         boolean isLightweight(Component comp);
 186 
 187         /**
 188          * Returns whether or not paint messages received from
 189          * the operating system should be ignored.
 190          */
 191         boolean getIgnoreRepaint(Component comp);
 192 
 193         /**
 194          * Returns the width of the component.
 195          */
 196         int getWidth(Component comp);
 197 
 198         /**
 199          * Returns the height of the component.
 200          */
 201         int getHeight(Component comp);
 202 
 203         /**
 204          * Returns the x coordinate of the component.
 205          */
 206         int getX(Component comp);
 207 
 208         /**
 209          * Returns the y coordinate of the component.
 210          */
 211         int getY(Component comp);
 212 
 213         /**
 214          * Gets the foreground color of this component.
 215          */
 216         Color getForeground(Component comp);
 217 
 218         /**
 219          * Gets the background color of this component.
 220          */
 221         Color getBackground(Component comp);
 222 
 223         /**
 224          * Sets the background of this component to the specified color.
 225          */
 226         void setBackground(Component comp, Color background);
 227 
 228         /**
 229          * Gets the font of the component.
 230          */
 231         Font getFont(Component comp);
 232 
 233         /**
 234          * Processes events occurring on this component.
 235          */
 236         void processEvent(Component comp, AWTEvent e);
 237 
 238 
 239         /*
 240          * Returns the acc this component was constructed with.
 241          */
 242         AccessControlContext getAccessControlContext(Component comp);
 243 
 244         /**
 245          * Revalidates the component synchronously.
 246          */
 247         void revalidateSynchronously(Component comp);
 248 
 249         /**
 250          * Creates a new strategy for multi-buffering on this component.
 251          */
 252         void createBufferStrategy(Component comp, int numBuffers,
 253                 BufferCapabilities caps) throws AWTException;
 254 
 255         /**
 256          * returns the buffer strategy used by this component.
 257          */
 258         BufferStrategy getBufferStrategy(Component comp);
 259     }
 260 
 261     /*
 262      * An interface of accessor for the java.awt.Container class.
 263      */
 264     public interface ContainerAccessor {
 265         /**
 266          * Validates the container unconditionally.
 267          */
 268         void validateUnconditionally(Container cont);
 269 
 270         /**
 271          *
 272          * Access to the private version of findComponentAt method which has
 273          * a controllable behavior. Setting 'ignoreEnabled' to 'false'
 274          * bypasses disabled Components during the search.
 275          */
 276         Component findComponentAt(Container cont, int x, int y, boolean ignoreEnabled);
 277 
 278         /**
 279          * Starts LW Modal.
 280          */
 281         void startLWModal(Container cont);
 282 
 283         /**
 284          * Starts LW Modal.
 285          */
 286         void stopLWModal(Container cont);
 287     }
 288 
 289     /*
 290      * An interface of accessor for java.awt.Window class.
 291      */
 292     public interface WindowAccessor {
 293         /*
 294          * Update the image of a non-opaque (translucent) window.
 295          */
 296         void updateWindow(Window window);
 297 
 298         /**
 299          * Set the size of the security warning.
 300          */
 301         void setSecurityWarningSize(Window w, int width, int height);
 302 
 303         /** Request to recalculate the new position of the security warning for
 304          * the given window size/location as reported by the native system.
 305          */
 306         Point2D calculateSecurityWarningPosition(Window window,
 307                 double x, double y, double w, double h);
 308 
 309         /** Sets the synchronous status of focus requests on lightweight
 310          * components in the specified window to the specified value.
 311          */
 312         void setLWRequestStatus(Window changed, boolean status);
 313 
 314         /**
 315          * Indicates whether this window should receive focus on subsequently
 316          * being shown, or being moved to the front.
 317          */
 318         boolean isAutoRequestFocus(Window w);
 319 
 320         /**
 321          * Indicates whether the specified window is an utility window for TrayIcon.
 322          */
 323         boolean isTrayIconWindow(Window w);
 324 
 325         /**
 326          * Marks the specified window as an utility window for TrayIcon.
 327          */
 328         void setTrayIconWindow(Window w, boolean isTrayIconWindow);
 329 
 330         /**
 331          * Return an array containing all the windows this
 332          * window currently owns.
 333          */
 334         Window[] getOwnedWindows(Window w);
 335     }
 336 
 337     /**
 338      * An accessor for the AWTEvent class.
 339      */
 340     public interface AWTEventAccessor {
 341         /**
 342          * Marks the event as posted.
 343          */
 344         void setPosted(AWTEvent ev);
 345 
 346         /**
 347          * Sets the flag on this AWTEvent indicating that it was
 348          * generated by the system.
 349          */
 350         void setSystemGenerated(AWTEvent ev);
 351 
 352         /**
 353          * Indicates whether this AWTEvent was generated by the system.
 354          */
 355         boolean isSystemGenerated(AWTEvent ev);
 356 
 357         /**
 358          * Returns the acc this event was constructed with.
 359          */
 360         AccessControlContext getAccessControlContext(AWTEvent ev);
 361 
 362         /**
 363          * Returns binary data associated with this event;
 364          */
 365         byte[] getBData(AWTEvent ev);
 366 
 367         /**
 368          * Associates binary data with this event;
 369          */
 370         void setBData(AWTEvent ev, byte[] bdata);
 371     }
 372 
 373     public interface InputEventAccessor {
 374         /*
 375          * Accessor for InputEvent.getButtonDownMasks()
 376          */
 377         int[] getButtonDownMasks();
 378 
 379         /*
 380          * Accessor for InputEvent.canAccessSystemClipboard field
 381          */
 382         boolean canAccessSystemClipboard(InputEvent event);
 383         void setCanAccessSystemClipboard(InputEvent event,
 384                 boolean canAccessSystemClipboard);
 385     }
 386 
 387     /**
 388      * An accessor for the MouseEvent class.
 389      */
 390     public interface MouseEventAccessor {
 391         /**
 392          * Indicates whether the event is a result of a touch event.
 393          */
 394         boolean isCausedByTouchEvent(MouseEvent ev);
 395 
 396         /**
 397          * Sets whether the event is a result of a touch event.
 398          */
 399         void setCausedByTouchEvent(MouseEvent ev, boolean causedByTouchEvent);
 400     }
 401 
 402     /*
 403      * An accessor for the java.awt.Frame class.
 404      */
 405     public interface FrameAccessor {
 406         /*
 407          * Sets the state of this frame.
 408          */
 409         void setExtendedState(Frame frame, int state);
 410         /*
 411          * Gets the state of this frame.
 412          */
 413        int getExtendedState(Frame frame);
 414         /*
 415          * Gets the maximized bounds of this frame.
 416          */
 417        Rectangle getMaximizedBounds(Frame frame);
 418     }
 419 
 420     /**
 421      * An interface of accessor for the java.awt.KeyboardFocusManager class.
 422      */
 423     public interface KeyboardFocusManagerAccessor {
 424         /**
 425          * Indicates whether the native implementation should
 426          * proceed with a pending focus request for the heavyweight.
 427          */
 428         int shouldNativelyFocusHeavyweight(Component heavyweight,
 429                                            Component descendant,
 430                                            boolean temporary,
 431                                            boolean focusedWindowChangeAllowed,
 432                                            long time,
 433                                            Cause cause);
 434         /**
 435          * Delivers focus for the lightweight descendant of the heavyweight
 436          * synchronously.
 437          */
 438         boolean processSynchronousLightweightTransfer(Component heavyweight,
 439                                                       Component descendant,
 440                                                       boolean temporary,
 441                                                       boolean focusedWindowChangeAllowed,
 442                                                       long time);
 443         /**
 444          * Removes the last focus request for the heavyweight from the queue.
 445          */
 446         void removeLastFocusRequest(Component heavyweight);
 447 
 448         /**
 449          * Gets the most recent focus owner in the window.
 450          */
 451         Component getMostRecentFocusOwner(Window window);
 452 
 453         /**
 454          * Sets the most recent focus owner in the window.
 455          */
 456         void setMostRecentFocusOwner(Window window, Component component);
 457 
 458         /**
 459          * Returns current KFM of the specified AppContext.
 460          */
 461         KeyboardFocusManager getCurrentKeyboardFocusManager(AppContext ctx);
 462 
 463         /**
 464          * Return the current focus cycle root
 465          */
 466         Container getCurrentFocusCycleRoot();
 467     }
 468 
 469     /**
 470      * An accessor for the MenuComponent class.
 471      */
 472     public interface MenuComponentAccessor {
 473         /**
 474          * Returns the appContext of the menu component.
 475          */
 476         AppContext getAppContext(MenuComponent menuComp);
 477 
 478         /**
 479          * Sets the appContext of the menu component.
 480          */
 481         void setAppContext(MenuComponent menuComp, AppContext appContext);
 482 
 483         /**
 484          * Returns the peer of the menu component.
 485          */
 486         <T extends MenuComponentPeer> T getPeer(MenuComponent menuComp);
 487 
 488         /**
 489          * Returns the menu container of the menu component.
 490          */
 491         MenuContainer getParent(MenuComponent menuComp);
 492 
 493         /**
 494          * Sets the menu container of the menu component.
 495          */
 496         void  setParent(MenuComponent menuComp, MenuContainer menuContainer);
 497 
 498         /**
 499          * Gets the font used for this menu component.
 500          */
 501         Font getFont_NoClientCode(MenuComponent menuComp);
 502     }
 503 
 504     /**
 505      * An accessor for the EventQueue class
 506      */
 507     public interface EventQueueAccessor {
 508         /**
 509          * Gets the event dispatch thread.
 510          */
 511         Thread getDispatchThread(EventQueue eventQueue);
 512 
 513         /**
 514          * Checks if the current thread is EDT for the given EQ.
 515          */
 516         public boolean isDispatchThreadImpl(EventQueue eventQueue);
 517 
 518         /**
 519          * Removes any pending events for the specified source object.
 520          */
 521         void removeSourceEvents(EventQueue eventQueue, Object source, boolean removeAllEvents);
 522 
 523         /**
 524          * Returns whether an event is pending on any of the separate Queues.
 525          */
 526         boolean noEvents(EventQueue eventQueue);
 527 
 528         /**
 529          * Called from PostEventQueue.postEvent to notify that a new event
 530          * appeared.
 531          */
 532         void wakeup(EventQueue eventQueue, boolean isShutdown);
 533 
 534         /**
 535          * Static in EventQueue
 536          */
 537         void invokeAndWait(Object source, Runnable r)
 538             throws InterruptedException, InvocationTargetException;
 539 
 540         /**
 541          * Sets the delegate for the EventQueue used by FX/AWT single threaded mode
 542          */
 543         void setFwDispatcher(EventQueue eventQueue, FwDispatcher dispatcher);
 544 
 545         /**
 546          * Gets most recent event time in the EventQueue
 547          */
 548         long getMostRecentEventTime(EventQueue eventQueue);
 549     }
 550 
 551     /*
 552      * An accessor for the PopupMenu class
 553      */
 554     public interface PopupMenuAccessor {
 555         /*
 556          * Returns whether the popup menu is attached to a tray
 557          */
 558         boolean isTrayIconPopup(PopupMenu popupMenu);
 559     }
 560 
 561     /*
 562      * An accessor for the FileDialog class
 563      */
 564     public interface FileDialogAccessor {
 565         /*
 566          * Sets the files the user selects
 567          */
 568         void setFiles(FileDialog fileDialog, File files[]);
 569 
 570         /*
 571          * Sets the file the user selects
 572          */
 573         void setFile(FileDialog fileDialog, String file);
 574 
 575         /*
 576          * Sets the directory the user selects
 577          */
 578         void setDirectory(FileDialog fileDialog, String directory);
 579 
 580         /*
 581          * Returns whether the file dialog allows the multiple file selection.
 582          */
 583         boolean isMultipleMode(FileDialog fileDialog);
 584     }
 585 
 586     /*
 587      * An accessor for the ScrollPaneAdjustable class.
 588      */
 589     public interface ScrollPaneAdjustableAccessor {
 590         /*
 591          * Sets the value of this scrollbar to the specified value.
 592          */
 593         void setTypedValue(final ScrollPaneAdjustable adj, final int v,
 594                            final int type);
 595     }
 596 
 597     /**
 598      * An accessor for the CheckboxMenuItem class
 599      */
 600     public interface CheckboxMenuItemAccessor {
 601         /**
 602          * Returns whether menu item is checked
 603          */
 604         boolean getState(CheckboxMenuItem cmi);
 605     }
 606 
 607     /**
 608      * An accessor for the Cursor class
 609      */
 610     public interface CursorAccessor {
 611         /**
 612          * Returns pData of the Cursor class
 613          */
 614         long getPData(Cursor cursor);
 615 
 616         /**
 617          * Sets pData to the Cursor class
 618          */
 619         void setPData(Cursor cursor, long pData);
 620 
 621         /**
 622          * Return type of the Cursor class
 623          */
 624         int getType(Cursor cursor);
 625     }
 626 
 627     /**
 628      * An accessor for the MenuBar class
 629      */
 630     public interface MenuBarAccessor {
 631         /**
 632          * Returns help menu
 633          */
 634         Menu getHelpMenu(MenuBar menuBar);
 635 
 636         /**
 637          * Returns menus
 638          */
 639         Vector<Menu> getMenus(MenuBar menuBar);
 640     }
 641 
 642     /**
 643      * An accessor for the MenuItem class
 644      */
 645     public interface MenuItemAccessor {
 646         /**
 647          * Returns whether menu item is enabled
 648          */
 649         boolean isEnabled(MenuItem item);
 650 
 651         /**
 652          * Gets the command name of the action event that is fired
 653          * by this menu item.
 654          */
 655         String getActionCommandImpl(MenuItem item);
 656 
 657         /**
 658          * Returns true if the item and all its ancestors are
 659          * enabled, false otherwise
 660          */
 661         boolean isItemEnabled(MenuItem item);
 662 
 663         /**
 664          * Returns label
 665          */
 666         String getLabel(MenuItem item);
 667 
 668         /**
 669          * Returns shortcut
 670          */
 671         MenuShortcut getShortcut(MenuItem item);
 672     }
 673 
 674     /**
 675      * An accessor for the Menu class
 676      */
 677     public interface MenuAccessor {
 678         /**
 679          * Returns vector of the items that are part of the Menu
 680          */
 681         Vector<MenuItem> getItems(Menu menu);
 682     }
 683 
 684     /**
 685      * An accessor for the KeyEvent class
 686      */
 687     public interface KeyEventAccessor {
 688         /**
 689          * Sets rawCode field for KeyEvent
 690          */
 691         void setRawCode(KeyEvent ev, long rawCode);
 692 
 693         /**
 694          * Sets primaryLevelUnicode field for KeyEvent
 695          */
 696         void setPrimaryLevelUnicode(KeyEvent ev, long primaryLevelUnicode);
 697 
 698         /**
 699          * Sets extendedKeyCode field for KeyEvent
 700          */
 701         void setExtendedKeyCode(KeyEvent ev, long extendedKeyCode);
 702 
 703         /**
 704          * Gets original source for KeyEvent
 705          */
 706         Component getOriginalSource(KeyEvent ev);
 707 
 708         /**
 709          * Gets isProxyActive field for KeyEvent
 710          */
 711         boolean isProxyActive(KeyEvent ev);
 712     }
 713 
 714     /**
 715      * An accessor for the ClientPropertyKey class
 716      */
 717     public interface ClientPropertyKeyAccessor {
 718         /**
 719          * Retrieves JComponent_TRANSFER_HANDLER enum object
 720          */
 721         Object getJComponent_TRANSFER_HANDLER();
 722     }
 723 
 724     /**
 725      * An accessor for the SystemTray class
 726      */
 727     public interface SystemTrayAccessor {
 728         /**
 729          * Support for reporting bound property changes for Object properties.
 730          */
 731         void firePropertyChange(SystemTray tray, String propertyName, Object oldValue, Object newValue);
 732     }
 733 
 734     /**
 735      * An accessor for the TrayIcon class
 736      */
 737     public interface TrayIconAccessor {
 738         void addNotify(TrayIcon trayIcon) throws AWTException;
 739         void removeNotify(TrayIcon trayIcon);
 740     }
 741 
 742     /**
 743      * An accessor for the DefaultKeyboardFocusManager class
 744      */
 745     public interface DefaultKeyboardFocusManagerAccessor {
 746         public void consumeNextKeyTyped(DefaultKeyboardFocusManager dkfm, KeyEvent e);
 747     }
 748 
 749     /*
 750      * An accessor for the SequencedEventAccessor class
 751      */
 752     public interface SequencedEventAccessor {
 753         /*
 754          * Returns the nested event.
 755          */
 756         AWTEvent getNested(AWTEvent sequencedEvent);
 757 
 758         /*
 759          * Returns true if the event is an instances of SequencedEvent.
 760          */
 761         boolean isSequencedEvent(AWTEvent event);
 762 
 763         /*
 764          * Creates SequencedEvent with the given nested event
 765          */
 766         AWTEvent create(AWTEvent event);
 767     }
 768 
 769     /*
 770      * An accessor for the Toolkit class
 771      */
 772     public interface ToolkitAccessor {
 773         void setPlatformResources(ResourceBundle bundle);
 774     }
 775 
 776     /*
 777      * An accessor object for the InvocationEvent class
 778      */
 779     public interface InvocationEventAccessor {
 780         void dispose(InvocationEvent event);
 781     }
 782 
 783     /*
 784      * An accessor object for the SystemColor class
 785      */
 786     public interface SystemColorAccessor {
 787         void updateSystemColors();
 788     }
 789 
 790     /*
 791      * An accessor object for the AccessibleContext class
 792      */
 793     public interface AccessibleContextAccessor {
 794         void setAppContext(AccessibleContext accessibleContext, AppContext appContext);
 795         AppContext getAppContext(AccessibleContext accessibleContext);
 796         Object getNativeAXResource(AccessibleContext accessibleContext);
 797         void setNativeAXResource(AccessibleContext accessibleContext, Object value);
 798     }
 799 
 800     /*
 801      * An accessor object for the AccessibleContext class
 802      */
 803     public interface AccessibleBundleAccessor {
 804         String getKey(AccessibleBundle accessibleBundle);
 805     }
 806 
 807     /*
 808      * An accessor object for the DragSourceContext class
 809      */
 810     public interface DragSourceContextAccessor {
 811         /**
 812          * Returns the peer of the DragSourceContext.
 813          */
 814         DragSourceContextPeer getPeer(DragSourceContext dsc);
 815     }
 816 
 817     /*
 818      * An accessor object for the DropTargetContext class
 819      */
 820     public interface DropTargetContextAccessor {
 821         /**
 822          * Resets the DropTargetContext.
 823          */
 824         void reset(DropTargetContext dtc);
 825         /**
 826          * Sets the {@code DropTargetContextPeer}
 827          */
 828         void setDropTargetContextPeer(DropTargetContext dtc,
 829                                       DropTargetContextPeer dtcp);
 830     }
 831 
 832     /*
 833      * Accessor instances are initialized in the static initializers of
 834      * corresponding AWT classes by using setters defined below.
 835      */
 836     private static ComponentAccessor componentAccessor;
 837     private static ContainerAccessor containerAccessor;
 838     private static WindowAccessor windowAccessor;
 839     private static AWTEventAccessor awtEventAccessor;
 840     private static InputEventAccessor inputEventAccessor;
 841     private static MouseEventAccessor mouseEventAccessor;
 842     private static FrameAccessor frameAccessor;
 843     private static KeyboardFocusManagerAccessor kfmAccessor;
 844     private static MenuComponentAccessor menuComponentAccessor;
 845     private static EventQueueAccessor eventQueueAccessor;
 846     private static PopupMenuAccessor popupMenuAccessor;
 847     private static FileDialogAccessor fileDialogAccessor;
 848     private static ScrollPaneAdjustableAccessor scrollPaneAdjustableAccessor;
 849     private static CheckboxMenuItemAccessor checkboxMenuItemAccessor;
 850     private static CursorAccessor cursorAccessor;
 851     private static MenuBarAccessor menuBarAccessor;
 852     private static MenuItemAccessor menuItemAccessor;
 853     private static MenuAccessor menuAccessor;
 854     private static KeyEventAccessor keyEventAccessor;
 855     private static ClientPropertyKeyAccessor clientPropertyKeyAccessor;
 856     private static SystemTrayAccessor systemTrayAccessor;
 857     private static TrayIconAccessor trayIconAccessor;
 858     private static DefaultKeyboardFocusManagerAccessor defaultKeyboardFocusManagerAccessor;
 859     private static SequencedEventAccessor sequencedEventAccessor;
 860     private static ToolkitAccessor toolkitAccessor;
 861     private static InvocationEventAccessor invocationEventAccessor;
 862     private static SystemColorAccessor systemColorAccessor;
 863     private static AccessibleContextAccessor accessibleContextAccessor;
 864     private static AccessibleBundleAccessor accessibleBundleAccessor;
 865     private static DragSourceContextAccessor dragSourceContextAccessor;
 866     private static DropTargetContextAccessor dropTargetContextAccessor;
 867 
 868     /*
 869      * Set an accessor object for the java.awt.Component class.
 870      */
 871     public static void setComponentAccessor(ComponentAccessor ca) {
 872         componentAccessor = ca;
 873     }
 874 
 875     /*
 876      * Retrieve the accessor object for the java.awt.Component class.
 877      */
 878     public static ComponentAccessor getComponentAccessor() {
 879         if (componentAccessor == null) {
 880             unsafe.ensureClassInitialized(Component.class);
 881         }
 882 
 883         return componentAccessor;
 884     }
 885 
 886     /*
 887      * Set an accessor object for the java.awt.Container class.
 888      */
 889     public static void setContainerAccessor(ContainerAccessor ca) {
 890         containerAccessor = ca;
 891     }
 892 
 893     /*
 894      * Retrieve the accessor object for the java.awt.Container class.
 895      */
 896     public static ContainerAccessor getContainerAccessor() {
 897         if (containerAccessor == null) {
 898             unsafe.ensureClassInitialized(Container.class);
 899         }
 900 
 901         return containerAccessor;
 902     }
 903 
 904     /*
 905      * Set an accessor object for the java.awt.Window class.
 906      */
 907     public static void setWindowAccessor(WindowAccessor wa) {
 908         windowAccessor = wa;
 909     }
 910 
 911     /*
 912      * Retrieve the accessor object for the java.awt.Window class.
 913      */
 914     public static WindowAccessor getWindowAccessor() {
 915         if (windowAccessor == null) {
 916             unsafe.ensureClassInitialized(Window.class);
 917         }
 918         return windowAccessor;
 919     }
 920 
 921     /*
 922      * Set an accessor object for the java.awt.AWTEvent class.
 923      */
 924     public static void setAWTEventAccessor(AWTEventAccessor aea) {
 925         awtEventAccessor = aea;
 926     }
 927 
 928     /*
 929      * Retrieve the accessor object for the java.awt.AWTEvent class.
 930      */
 931     public static AWTEventAccessor getAWTEventAccessor() {
 932         if (awtEventAccessor == null) {
 933             unsafe.ensureClassInitialized(AWTEvent.class);
 934         }
 935         return awtEventAccessor;
 936     }
 937 
 938     /*
 939      * Set an accessor object for the java.awt.event.InputEvent class.
 940      */
 941     public static void setInputEventAccessor(InputEventAccessor iea) {
 942         inputEventAccessor = iea;
 943     }
 944 
 945     /*
 946      * Retrieve the accessor object for the java.awt.event.InputEvent class.
 947      */
 948     public static InputEventAccessor getInputEventAccessor() {
 949         if (inputEventAccessor == null) {
 950             unsafe.ensureClassInitialized(InputEvent.class);
 951         }
 952         return inputEventAccessor;
 953     }
 954 
 955     /*
 956      * Set an accessor object for the java.awt.event.MouseEvent class.
 957      */
 958     public static void setMouseEventAccessor(MouseEventAccessor mea) {
 959         mouseEventAccessor = mea;
 960     }
 961 
 962     /*
 963      * Retrieve the accessor object for the java.awt.event.MouseEvent class.
 964      */
 965     public static MouseEventAccessor getMouseEventAccessor() {
 966         if (mouseEventAccessor == null) {
 967             unsafe.ensureClassInitialized(MouseEvent.class);
 968         }
 969         return mouseEventAccessor;
 970     }
 971 
 972     /*
 973      * Set an accessor object for the java.awt.Frame class.
 974      */
 975     public static void setFrameAccessor(FrameAccessor fa) {
 976         frameAccessor = fa;
 977     }
 978 
 979     /*
 980      * Retrieve the accessor object for the java.awt.Frame class.
 981      */
 982     public static FrameAccessor getFrameAccessor() {
 983         if (frameAccessor == null) {
 984             unsafe.ensureClassInitialized(Frame.class);
 985         }
 986         return frameAccessor;
 987     }
 988 
 989     /*
 990      * Set an accessor object for the java.awt.KeyboardFocusManager class.
 991      */
 992     public static void setKeyboardFocusManagerAccessor(KeyboardFocusManagerAccessor kfma) {
 993         kfmAccessor = kfma;
 994     }
 995 
 996     /*
 997      * Retrieve the accessor object for the java.awt.KeyboardFocusManager class.
 998      */
 999     public static KeyboardFocusManagerAccessor getKeyboardFocusManagerAccessor() {
1000         if (kfmAccessor == null) {
1001             unsafe.ensureClassInitialized(KeyboardFocusManager.class);
1002         }
1003         return kfmAccessor;
1004     }
1005 
1006     /*
1007      * Set an accessor object for the java.awt.MenuComponent class.
1008      */
1009     public static void setMenuComponentAccessor(MenuComponentAccessor mca) {
1010         menuComponentAccessor = mca;
1011     }
1012 
1013     /*
1014      * Retrieve the accessor object for the java.awt.MenuComponent class.
1015      */
1016     public static MenuComponentAccessor getMenuComponentAccessor() {
1017         if (menuComponentAccessor == null) {
1018             unsafe.ensureClassInitialized(MenuComponent.class);
1019         }
1020         return menuComponentAccessor;
1021     }
1022 
1023     /*
1024      * Set an accessor object for the java.awt.EventQueue class.
1025      */
1026     public static void setEventQueueAccessor(EventQueueAccessor eqa) {
1027         eventQueueAccessor = eqa;
1028     }
1029 
1030     /*
1031      * Retrieve the accessor object for the java.awt.EventQueue class.
1032      */
1033     public static EventQueueAccessor getEventQueueAccessor() {
1034         if (eventQueueAccessor == null) {
1035             unsafe.ensureClassInitialized(EventQueue.class);
1036         }
1037         return eventQueueAccessor;
1038     }
1039 
1040     /*
1041      * Set an accessor object for the java.awt.PopupMenu class.
1042      */
1043     public static void setPopupMenuAccessor(PopupMenuAccessor pma) {
1044         popupMenuAccessor = pma;
1045     }
1046 
1047     /*
1048      * Retrieve the accessor object for the java.awt.PopupMenu class.
1049      */
1050     public static PopupMenuAccessor getPopupMenuAccessor() {
1051         if (popupMenuAccessor == null) {
1052             unsafe.ensureClassInitialized(PopupMenu.class);
1053         }
1054         return popupMenuAccessor;
1055     }
1056 
1057     /*
1058      * Set an accessor object for the java.awt.FileDialog class.
1059      */
1060     public static void setFileDialogAccessor(FileDialogAccessor fda) {
1061         fileDialogAccessor = fda;
1062     }
1063 
1064     /*
1065      * Retrieve the accessor object for the java.awt.FileDialog class.
1066      */
1067     public static FileDialogAccessor getFileDialogAccessor() {
1068         if (fileDialogAccessor == null) {
1069             unsafe.ensureClassInitialized(FileDialog.class);
1070         }
1071         return fileDialogAccessor;
1072     }
1073 
1074     /*
1075      * Set an accessor object for the java.awt.ScrollPaneAdjustable class.
1076      */
1077     public static void setScrollPaneAdjustableAccessor(ScrollPaneAdjustableAccessor adj) {
1078         scrollPaneAdjustableAccessor = adj;
1079     }
1080 
1081     /*
1082      * Retrieve the accessor object for the java.awt.ScrollPaneAdjustable
1083      * class.
1084      */
1085     public static ScrollPaneAdjustableAccessor getScrollPaneAdjustableAccessor() {
1086         if (scrollPaneAdjustableAccessor == null) {
1087             unsafe.ensureClassInitialized(ScrollPaneAdjustable.class);
1088         }
1089         return scrollPaneAdjustableAccessor;
1090     }
1091 
1092     /**
1093      * Set an accessor object for the java.awt.CheckboxMenuItem class.
1094      */
1095     public static void setCheckboxMenuItemAccessor(CheckboxMenuItemAccessor cmia) {
1096         checkboxMenuItemAccessor = cmia;
1097     }
1098 
1099     /**
1100      * Retrieve the accessor object for the java.awt.CheckboxMenuItem class.
1101      */
1102     public static CheckboxMenuItemAccessor getCheckboxMenuItemAccessor() {
1103         if (checkboxMenuItemAccessor == null) {
1104             unsafe.ensureClassInitialized(CheckboxMenuItemAccessor.class);
1105         }
1106         return checkboxMenuItemAccessor;
1107     }
1108 
1109     /**
1110      * Set an accessor object for the java.awt.Cursor class.
1111      */
1112     public static void setCursorAccessor(CursorAccessor ca) {
1113         cursorAccessor = ca;
1114     }
1115 
1116     /**
1117      * Retrieve the accessor object for the java.awt.Cursor class.
1118      */
1119     public static CursorAccessor getCursorAccessor() {
1120         if (cursorAccessor == null) {
1121             unsafe.ensureClassInitialized(CursorAccessor.class);
1122         }
1123         return cursorAccessor;
1124     }
1125 
1126     /**
1127      * Set an accessor object for the java.awt.MenuBar class.
1128      */
1129     public static void setMenuBarAccessor(MenuBarAccessor mba) {
1130         menuBarAccessor = mba;
1131     }
1132 
1133     /**
1134      * Retrieve the accessor object for the java.awt.MenuBar class.
1135      */
1136     public static MenuBarAccessor getMenuBarAccessor() {
1137         if (menuBarAccessor == null) {
1138             unsafe.ensureClassInitialized(MenuBarAccessor.class);
1139         }
1140         return menuBarAccessor;
1141     }
1142 
1143     /**
1144      * Set an accessor object for the java.awt.MenuItem class.
1145      */
1146     public static void setMenuItemAccessor(MenuItemAccessor mia) {
1147         menuItemAccessor = mia;
1148     }
1149 
1150     /**
1151      * Retrieve the accessor object for the java.awt.MenuItem class.
1152      */
1153     public static MenuItemAccessor getMenuItemAccessor() {
1154         if (menuItemAccessor == null) {
1155             unsafe.ensureClassInitialized(MenuItemAccessor.class);
1156         }
1157         return menuItemAccessor;
1158     }
1159 
1160     /**
1161      * Set an accessor object for the java.awt.Menu class.
1162      */
1163     public static void setMenuAccessor(MenuAccessor ma) {
1164         menuAccessor = ma;
1165     }
1166 
1167     /**
1168      * Retrieve the accessor object for the java.awt.Menu class.
1169      */
1170     public static MenuAccessor getMenuAccessor() {
1171         if (menuAccessor == null) {
1172             unsafe.ensureClassInitialized(MenuAccessor.class);
1173         }
1174         return menuAccessor;
1175     }
1176 
1177     /**
1178      * Set an accessor object for the java.awt.event.KeyEvent class.
1179      */
1180     public static void setKeyEventAccessor(KeyEventAccessor kea) {
1181         keyEventAccessor = kea;
1182     }
1183 
1184     /**
1185      * Retrieve the accessor object for the java.awt.event.KeyEvent class.
1186      */
1187     public static KeyEventAccessor getKeyEventAccessor() {
1188         if (keyEventAccessor == null) {
1189             unsafe.ensureClassInitialized(KeyEventAccessor.class);
1190         }
1191         return keyEventAccessor;
1192     }
1193 
1194     /**
1195      * Set an accessor object for the javax.swing.ClientPropertyKey class.
1196      */
1197     public static void setClientPropertyKeyAccessor(ClientPropertyKeyAccessor cpka) {
1198         clientPropertyKeyAccessor = cpka;
1199     }
1200 
1201     /**
1202      * Retrieve the accessor object for the javax.swing.ClientPropertyKey class.
1203      */
1204     public static ClientPropertyKeyAccessor getClientPropertyKeyAccessor() {
1205         if (clientPropertyKeyAccessor == null) {
1206             unsafe.ensureClassInitialized(ClientPropertyKeyAccessor.class);
1207         }
1208         return clientPropertyKeyAccessor;
1209     }
1210 
1211     /**
1212      * Set an accessor object for the java.awt.SystemTray class.
1213      */
1214     public static void setSystemTrayAccessor(SystemTrayAccessor sta) {
1215         systemTrayAccessor = sta;
1216     }
1217 
1218     /**
1219      * Retrieve the accessor object for the java.awt.SystemTray class.
1220      */
1221     public static SystemTrayAccessor getSystemTrayAccessor() {
1222         if (systemTrayAccessor == null) {
1223             unsafe.ensureClassInitialized(SystemTrayAccessor.class);
1224         }
1225         return systemTrayAccessor;
1226     }
1227 
1228     /**
1229      * Set an accessor object for the java.awt.TrayIcon class.
1230      */
1231     public static void setTrayIconAccessor(TrayIconAccessor tia) {
1232         trayIconAccessor = tia;
1233     }
1234 
1235     /**
1236      * Retrieve the accessor object for the java.awt.TrayIcon class.
1237      */
1238     public static TrayIconAccessor getTrayIconAccessor() {
1239         if (trayIconAccessor == null) {
1240             unsafe.ensureClassInitialized(TrayIconAccessor.class);
1241         }
1242         return trayIconAccessor;
1243     }
1244 
1245     /**
1246      * Set an accessor object for the java.awt.DefaultKeyboardFocusManager class.
1247      */
1248     public static void setDefaultKeyboardFocusManagerAccessor(DefaultKeyboardFocusManagerAccessor dkfma) {
1249         defaultKeyboardFocusManagerAccessor = dkfma;
1250     }
1251 
1252     /**
1253      * Retrieve the accessor object for the java.awt.DefaultKeyboardFocusManager class.
1254      */
1255     public static DefaultKeyboardFocusManagerAccessor getDefaultKeyboardFocusManagerAccessor() {
1256         if (defaultKeyboardFocusManagerAccessor == null) {
1257             unsafe.ensureClassInitialized(DefaultKeyboardFocusManagerAccessor.class);
1258         }
1259         return defaultKeyboardFocusManagerAccessor;
1260     }
1261     /*
1262      * Set an accessor object for the java.awt.SequencedEvent class.
1263      */
1264     public static void setSequencedEventAccessor(SequencedEventAccessor sea) {
1265         sequencedEventAccessor = sea;
1266     }
1267 
1268     /*
1269      * Get the accessor object for the java.awt.SequencedEvent class.
1270      */
1271     public static SequencedEventAccessor getSequencedEventAccessor() {
1272         if (sequencedEventAccessor == null) {
1273             try {
1274                 unsafe.ensureClassInitialized(
1275                         Class.forName("java.awt.SequencedEvent"));
1276             } catch (ClassNotFoundException ignore) {
1277             }
1278         }
1279         return sequencedEventAccessor;
1280     }
1281 
1282     /*
1283      * Set an accessor object for the java.awt.Toolkit class.
1284      */
1285     public static void setToolkitAccessor(ToolkitAccessor ta) {
1286         toolkitAccessor = ta;
1287     }
1288 
1289     /*
1290      * Get the accessor object for the java.awt.Toolkit class.
1291      */
1292     public static ToolkitAccessor getToolkitAccessor() {
1293         if (toolkitAccessor == null) {
1294             unsafe.ensureClassInitialized(Toolkit.class);
1295         }
1296 
1297         return toolkitAccessor;
1298     }
1299 
1300     /*
1301      * Get the accessor object for the java.awt.event.InvocationEvent class.
1302      */
1303     public static void setInvocationEventAccessor(InvocationEventAccessor invocationEventAccessor) {
1304         AWTAccessor.invocationEventAccessor = invocationEventAccessor;
1305     }
1306 
1307     /*
1308      * Set the accessor object for the java.awt.event.InvocationEvent class.
1309      */
1310     public static InvocationEventAccessor getInvocationEventAccessor() {
1311         return invocationEventAccessor;
1312     }
1313 
1314     /*
1315      * Get the accessor object for the java.awt.SystemColor class.
1316      */
1317     public static SystemColorAccessor getSystemColorAccessor() {
1318         if (systemColorAccessor == null) {
1319             unsafe.ensureClassInitialized(SystemColor.class);
1320         }
1321 
1322         return systemColorAccessor;
1323     }
1324 
1325      /*
1326      * Set the accessor object for the java.awt.SystemColor class.
1327      */
1328      public static void setSystemColorAccessor(SystemColorAccessor systemColorAccessor) {
1329          AWTAccessor.systemColorAccessor = systemColorAccessor;
1330      }
1331 
1332     /*
1333      * Get the accessor object for the javax.accessibility.AccessibleContext class.
1334      */
1335     public static AccessibleContextAccessor getAccessibleContextAccessor() {
1336         if (accessibleContextAccessor == null) {
1337             unsafe.ensureClassInitialized(AccessibleContext.class);
1338         }
1339         return accessibleContextAccessor;
1340     }
1341 
1342    /*
1343     * Set the accessor object for the javax.accessibility.AccessibleBundle class.
1344     */
1345     public static void setAccessibleBundleAccessor(AccessibleBundleAccessor accessor) {
1346         AWTAccessor.accessibleBundleAccessor = accessor;
1347     }
1348 
1349     /*
1350      * Get the accessor object for the javax.accessibility.AccessibleBundle class.
1351      */
1352     public static AccessibleBundleAccessor getAccessibleBundleAccessor() {
1353         if (accessibleBundleAccessor == null) {
1354             unsafe.ensureClassInitialized(AccessibleBundle.class);
1355         }
1356         return accessibleBundleAccessor;
1357     }
1358 
1359    /*
1360     * Set the accessor object for the javax.accessibility.AccessibleContext class.
1361     */
1362     public static void setAccessibleContextAccessor(AccessibleContextAccessor accessor) {
1363         AWTAccessor.accessibleContextAccessor = accessor;
1364     }
1365 
1366     /*
1367      * Get the accessor object for the java.awt.dnd.DragSourceContext class.
1368      */
1369     public static DragSourceContextAccessor getDragSourceContextAccessor() {
1370         if (dragSourceContextAccessor == null) {
1371             unsafe.ensureClassInitialized(DragSourceContext.class);
1372         }
1373         return dragSourceContextAccessor;
1374     }
1375 
1376     /*
1377      * Set the accessor object for the java.awt.dnd.DragSourceContext class.
1378      */
1379     public static void setDragSourceContextAccessor(DragSourceContextAccessor accessor) {
1380         AWTAccessor.dragSourceContextAccessor = accessor;
1381     }
1382 
1383     /*
1384      * Get the accessor object for the java.awt.dnd.DropTargetContext class.
1385      */
1386     public static DropTargetContextAccessor getDropTargetContextAccessor() {
1387         if (dropTargetContextAccessor == null) {
1388             unsafe.ensureClassInitialized(DropTargetContext.class);
1389         }
1390         return dropTargetContextAccessor;
1391     }
1392 
1393     /*
1394      * Set the accessor object for the java.awt.dnd.DropTargetContext class.
1395      */
1396     public static void setDropTargetContextAccessor(DropTargetContextAccessor accessor) {
1397         AWTAccessor.dropTargetContextAccessor = accessor;
1398     }
1399 
1400 }