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