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