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