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