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