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