1/*
2 * Copyright (c) 2008, 2016, 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
26package sun.awt;
27
28import jdk.internal.misc.Unsafe;
29
30import javax.accessibility.AccessibleContext;
31import java.awt.*;
32import java.awt.event.FocusEvent.Cause;
33import java.awt.dnd.DragSourceContext;
34import java.awt.dnd.DropTargetContext;
35import java.awt.dnd.peer.DragSourceContextPeer;
36import java.awt.dnd.peer.DropTargetContextPeer;
37import java.awt.event.AWTEventListener;
38import java.awt.event.InputEvent;
39import java.awt.event.InvocationEvent;
40import java.awt.event.KeyEvent;
41import java.awt.geom.Point2D;
42import java.awt.image.BufferStrategy;
43import java.awt.peer.ComponentPeer;
44
45import java.awt.peer.MenuComponentPeer;
46import java.lang.reflect.InvocationTargetException;
47import java.security.AccessControlContext;
48
49import java.io.File;
50import java.util.ResourceBundle;
51import java.util.Vector;
52import javax.accessibility.AccessibleBundle;
53
54/**
55 * The AWTAccessor utility class.
56 * The main purpose of this class is to enable accessing
57 * private and package-private fields of classes from
58 * different classes/packages. See sun.misc.SharedSecretes
59 * for another example.
60 */
61public final class AWTAccessor {
62
63    private static final Unsafe unsafe = Unsafe.getUnsafe();
64
65    /*
66     * We don't need any objects of this class.
67     * It's rather a collection of static methods
68     * and interfaces.
69     */
70    private AWTAccessor() {
71    }
72
73    /*
74     * An interface of accessor for the java.awt.Component class.
75     */
76    public interface ComponentAccessor {
77        /*
78         * Sets whether the native background erase for a component
79         * has been disabled via SunToolkit.disableBackgroundErase().
80         */
81        void setBackgroundEraseDisabled(Component comp, boolean disabled);
82        /*
83         * Indicates whether the native background erase for a
84         * component has been disabled via
85         * SunToolkit.disableBackgroundErase().
86         */
87        boolean getBackgroundEraseDisabled(Component comp);
88        /*
89         *
90         * Gets the bounds of this component in the form of a
91         * {@code Rectangle} object. The bounds specify this
92         * component's width, height, and location relative to
93         * its parent.
94         */
95        Rectangle getBounds(Component comp);
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        void requestFocus(Component comp, 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        <T extends ComponentPeer> T 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         * Return an array containing all the windows this
360         * window currently owns.
361         */
362        Window[] getOwnedWindows(Window w);
363    }
364
365    /**
366     * An accessor for the AWTEvent class.
367     */
368    public interface AWTEventAccessor {
369        /**
370         * Marks the event as posted.
371         */
372        void setPosted(AWTEvent ev);
373
374        /**
375         * Sets the flag on this AWTEvent indicating that it was
376         * generated by the system.
377         */
378        void setSystemGenerated(AWTEvent ev);
379
380        /**
381         * Indicates whether this AWTEvent was generated by the system.
382         */
383        boolean isSystemGenerated(AWTEvent ev);
384
385        /**
386         * Returns the acc this event was constructed with.
387         */
388        AccessControlContext getAccessControlContext(AWTEvent ev);
389
390        /**
391         * Returns binary data associated with this event;
392         */
393        byte[] getBData(AWTEvent ev);
394
395        /**
396         * Associates binary data with this event;
397         */
398        void setBData(AWTEvent ev, byte[] bdata);
399    }
400
401    public interface InputEventAccessor {
402        /*
403         * Accessor for InputEvent.getButtonDownMasks()
404         */
405        int[] getButtonDownMasks();
406
407        /*
408         * Accessor for InputEvent.canAccessSystemClipboard field
409         */
410        boolean canAccessSystemClipboard(InputEvent event);
411        void setCanAccessSystemClipboard(InputEvent event,
412                boolean canAccessSystemClipboard);
413    }
414
415    /*
416     * An accessor for the java.awt.Frame class.
417     */
418    public interface FrameAccessor {
419        /*
420         * Sets the state of this frame.
421         */
422        void setExtendedState(Frame frame, int state);
423        /*
424         * Gets the state of this frame.
425         */
426       int getExtendedState(Frame frame);
427        /*
428         * Gets the maximized bounds of this frame.
429         */
430       Rectangle getMaximizedBounds(Frame frame);
431    }
432
433    /**
434     * An interface of accessor for the java.awt.KeyboardFocusManager class.
435     */
436    public interface KeyboardFocusManagerAccessor {
437        /**
438         * Indicates whether the native implementation should
439         * proceed with a pending focus request for the heavyweight.
440         */
441        int shouldNativelyFocusHeavyweight(Component heavyweight,
442                                           Component descendant,
443                                           boolean temporary,
444                                           boolean focusedWindowChangeAllowed,
445                                           long time,
446                                           Cause cause);
447        /**
448         * Delivers focus for the lightweight descendant of the heavyweight
449         * synchronously.
450         */
451        boolean processSynchronousLightweightTransfer(Component heavyweight,
452                                                      Component descendant,
453                                                      boolean temporary,
454                                                      boolean focusedWindowChangeAllowed,
455                                                      long time);
456        /**
457         * Removes the last focus request for the heavyweight from the queue.
458         */
459        void removeLastFocusRequest(Component heavyweight);
460
461        /**
462         * Gets the most recent focus owner in the window.
463         */
464        Component getMostRecentFocusOwner(Window window);
465
466        /**
467         * Sets the most recent focus owner in the window.
468         */
469        void setMostRecentFocusOwner(Window window, Component component);
470
471        /**
472         * Returns current KFM of the specified AppContext.
473         */
474        KeyboardFocusManager getCurrentKeyboardFocusManager(AppContext ctx);
475
476        /**
477         * Return the current focus cycle root
478         */
479        Container getCurrentFocusCycleRoot();
480    }
481
482    /**
483     * An accessor for the MenuComponent class.
484     */
485    public interface MenuComponentAccessor {
486        /**
487         * Returns the appContext of the menu component.
488         */
489        AppContext getAppContext(MenuComponent menuComp);
490
491        /**
492         * Sets the appContext of the menu component.
493         */
494        void setAppContext(MenuComponent menuComp, AppContext appContext);
495
496        /**
497         * Returns the peer of the menu component.
498         */
499        <T extends MenuComponentPeer> T getPeer(MenuComponent menuComp);
500
501        /**
502         * Returns the menu container of the menu component.
503         */
504        MenuContainer getParent(MenuComponent menuComp);
505
506        /**
507         * Sets the menu container of the menu component.
508         */
509        void  setParent(MenuComponent menuComp, MenuContainer menuContainer);
510
511        /**
512         * Gets the font used for this menu component.
513         */
514        Font getFont_NoClientCode(MenuComponent menuComp);
515    }
516
517    /**
518     * An accessor for the EventQueue class
519     */
520    public interface EventQueueAccessor {
521        /**
522         * Gets the event dispatch thread.
523         */
524        Thread getDispatchThread(EventQueue eventQueue);
525
526        /**
527         * Checks if the current thread is EDT for the given EQ.
528         */
529        public boolean isDispatchThreadImpl(EventQueue eventQueue);
530
531        /**
532         * Removes any pending events for the specified source object.
533         */
534        void removeSourceEvents(EventQueue eventQueue, Object source, boolean removeAllEvents);
535
536        /**
537         * Returns whether an event is pending on any of the separate Queues.
538         */
539        boolean noEvents(EventQueue eventQueue);
540
541        /**
542         * Called from PostEventQueue.postEvent to notify that a new event
543         * appeared.
544         */
545        void wakeup(EventQueue eventQueue, boolean isShutdown);
546
547        /**
548         * Static in EventQueue
549         */
550        void invokeAndWait(Object source, Runnable r)
551            throws InterruptedException, InvocationTargetException;
552
553        /**
554         * Sets the delegate for the EventQueue used by FX/AWT single threaded mode
555         */
556        void setFwDispatcher(EventQueue eventQueue, FwDispatcher dispatcher);
557
558        /**
559         * Gets most recent event time in the EventQueue
560         */
561        long getMostRecentEventTime(EventQueue eventQueue);
562    }
563
564    /*
565     * An accessor for the PopupMenu class
566     */
567    public interface PopupMenuAccessor {
568        /*
569         * Returns whether the popup menu is attached to a tray
570         */
571        boolean isTrayIconPopup(PopupMenu popupMenu);
572    }
573
574    /*
575     * An accessor for the FileDialog class
576     */
577    public interface FileDialogAccessor {
578        /*
579         * Sets the files the user selects
580         */
581        void setFiles(FileDialog fileDialog, File files[]);
582
583        /*
584         * Sets the file the user selects
585         */
586        void setFile(FileDialog fileDialog, String file);
587
588        /*
589         * Sets the directory the user selects
590         */
591        void setDirectory(FileDialog fileDialog, String directory);
592
593        /*
594         * Returns whether the file dialog allows the multiple file selection.
595         */
596        boolean isMultipleMode(FileDialog fileDialog);
597    }
598
599    /*
600     * An accessor for the ScrollPaneAdjustable class.
601     */
602    public interface ScrollPaneAdjustableAccessor {
603        /*
604         * Sets the value of this scrollbar to the specified value.
605         */
606        void setTypedValue(final ScrollPaneAdjustable adj, final int v,
607                           final int type);
608    }
609
610    /**
611     * An accessor for the CheckboxMenuItem class
612     */
613    public interface CheckboxMenuItemAccessor {
614        /**
615         * Returns whether menu item is checked
616         */
617        boolean getState(CheckboxMenuItem cmi);
618    }
619
620    /**
621     * An accessor for the Cursor class
622     */
623    public interface CursorAccessor {
624        /**
625         * Returns pData of the Cursor class
626         */
627        long getPData(Cursor cursor);
628
629        /**
630         * Sets pData to the Cursor class
631         */
632        void setPData(Cursor cursor, long pData);
633
634        /**
635         * Return type of the Cursor class
636         */
637        int getType(Cursor cursor);
638    }
639
640    /**
641     * An accessor for the MenuBar class
642     */
643    public interface MenuBarAccessor {
644        /**
645         * Returns help menu
646         */
647        Menu getHelpMenu(MenuBar menuBar);
648
649        /**
650         * Returns menus
651         */
652        Vector<Menu> getMenus(MenuBar menuBar);
653    }
654
655    /**
656     * An accessor for the MenuItem class
657     */
658    public interface MenuItemAccessor {
659        /**
660         * Returns whether menu item is enabled
661         */
662        boolean isEnabled(MenuItem item);
663
664        /**
665         * Gets the command name of the action event that is fired
666         * by this menu item.
667         */
668        String getActionCommandImpl(MenuItem item);
669
670        /**
671         * Returns true if the item and all its ancestors are
672         * enabled, false otherwise
673         */
674        boolean isItemEnabled(MenuItem item);
675
676        /**
677         * Returns label
678         */
679        String getLabel(MenuItem item);
680
681        /**
682         * Returns shortcut
683         */
684        MenuShortcut getShortcut(MenuItem item);
685    }
686
687    /**
688     * An accessor for the Menu class
689     */
690    public interface MenuAccessor {
691        /**
692         * Returns vector of the items that are part of the Menu
693         */
694        Vector<MenuItem> getItems(Menu menu);
695    }
696
697    /**
698     * An accessor for the KeyEvent class
699     */
700    public interface KeyEventAccessor {
701        /**
702         * Sets rawCode field for KeyEvent
703         */
704        void setRawCode(KeyEvent ev, long rawCode);
705
706        /**
707         * Sets primaryLevelUnicode field for KeyEvent
708         */
709        void setPrimaryLevelUnicode(KeyEvent ev, long primaryLevelUnicode);
710
711        /**
712         * Sets extendedKeyCode field for KeyEvent
713         */
714        void setExtendedKeyCode(KeyEvent ev, long extendedKeyCode);
715
716        /**
717         * Gets original source for KeyEvent
718         */
719        Component getOriginalSource(KeyEvent ev);
720
721        /**
722         * Gets isProxyActive field for KeyEvent
723         */
724        boolean isProxyActive(KeyEvent ev);
725    }
726
727    /**
728     * An accessor for the ClientPropertyKey class
729     */
730    public interface ClientPropertyKeyAccessor {
731        /**
732         * Retrieves JComponent_TRANSFER_HANDLER enum object
733         */
734        Object getJComponent_TRANSFER_HANDLER();
735    }
736
737    /**
738     * An accessor for the SystemTray class
739     */
740    public interface SystemTrayAccessor {
741        /**
742         * Support for reporting bound property changes for Object properties.
743         */
744        void firePropertyChange(SystemTray tray, String propertyName, Object oldValue, Object newValue);
745    }
746
747    /**
748     * An accessor for the TrayIcon class
749     */
750    public interface TrayIconAccessor {
751        void addNotify(TrayIcon trayIcon) throws AWTException;
752        void removeNotify(TrayIcon trayIcon);
753    }
754
755    /**
756     * An accessor for the DefaultKeyboardFocusManager class
757     */
758    public interface DefaultKeyboardFocusManagerAccessor {
759        public void consumeNextKeyTyped(DefaultKeyboardFocusManager dkfm, KeyEvent e);
760    }
761
762    /*
763     * An accessor for the SequencedEventAccessor class
764     */
765    public interface SequencedEventAccessor {
766        /*
767         * Returns the nested event.
768         */
769        AWTEvent getNested(AWTEvent sequencedEvent);
770
771        /*
772         * Returns true if the event is an instances of SequencedEvent.
773         */
774        boolean isSequencedEvent(AWTEvent event);
775
776        /*
777         * Creates SequencedEvent with the given nested event
778         */
779        AWTEvent create(AWTEvent event);
780    }
781
782    /*
783     * An accessor for the Toolkit class
784     */
785    public interface ToolkitAccessor {
786        void setPlatformResources(ResourceBundle bundle);
787    }
788
789    /*
790     * An accessor object for the InvocationEvent class
791     */
792    public interface InvocationEventAccessor {
793        void dispose(InvocationEvent event);
794    }
795
796    /*
797     * An accessor object for the SystemColor class
798     */
799    public interface SystemColorAccessor {
800        void updateSystemColors();
801    }
802
803    /*
804     * An accessor object for the AccessibleContext class
805     */
806    public interface AccessibleContextAccessor {
807        void setAppContext(AccessibleContext accessibleContext, AppContext appContext);
808        AppContext getAppContext(AccessibleContext accessibleContext);
809        Object getNativeAXResource(AccessibleContext accessibleContext);
810        void setNativeAXResource(AccessibleContext accessibleContext, Object value);
811    }
812
813    /*
814     * An accessor object for the AccessibleContext class
815     */
816    public interface AccessibleBundleAccessor {
817        String getKey(AccessibleBundle accessibleBundle);
818    }
819
820    /*
821     * An accessor object for the DragSourceContext class
822     */
823    public interface DragSourceContextAccessor {
824        /**
825         * Returns the peer of the DragSourceContext.
826         */
827        DragSourceContextPeer getPeer(DragSourceContext dsc);
828    }
829
830    /*
831     * An accessor object for the DropTargetContext class
832     */
833    public interface DropTargetContextAccessor {
834        /**
835         * Resets the DropTargetContext.
836         */
837        void reset(DropTargetContext dtc);
838        /**
839         * Sets the {@code DropTargetContextPeer}
840         */
841        void setDropTargetContextPeer(DropTargetContext dtc,
842                                      DropTargetContextPeer dtcp);
843    }
844
845    /*
846     * Accessor instances are initialized in the static initializers of
847     * corresponding AWT classes by using setters defined below.
848     */
849    private static ComponentAccessor componentAccessor;
850    private static ContainerAccessor containerAccessor;
851    private static WindowAccessor windowAccessor;
852    private static AWTEventAccessor awtEventAccessor;
853    private static InputEventAccessor inputEventAccessor;
854    private static FrameAccessor frameAccessor;
855    private static KeyboardFocusManagerAccessor kfmAccessor;
856    private static MenuComponentAccessor menuComponentAccessor;
857    private static EventQueueAccessor eventQueueAccessor;
858    private static PopupMenuAccessor popupMenuAccessor;
859    private static FileDialogAccessor fileDialogAccessor;
860    private static ScrollPaneAdjustableAccessor scrollPaneAdjustableAccessor;
861    private static CheckboxMenuItemAccessor checkboxMenuItemAccessor;
862    private static CursorAccessor cursorAccessor;
863    private static MenuBarAccessor menuBarAccessor;
864    private static MenuItemAccessor menuItemAccessor;
865    private static MenuAccessor menuAccessor;
866    private static KeyEventAccessor keyEventAccessor;
867    private static ClientPropertyKeyAccessor clientPropertyKeyAccessor;
868    private static SystemTrayAccessor systemTrayAccessor;
869    private static TrayIconAccessor trayIconAccessor;
870    private static DefaultKeyboardFocusManagerAccessor defaultKeyboardFocusManagerAccessor;
871    private static SequencedEventAccessor sequencedEventAccessor;
872    private static ToolkitAccessor toolkitAccessor;
873    private static InvocationEventAccessor invocationEventAccessor;
874    private static SystemColorAccessor systemColorAccessor;
875    private static AccessibleContextAccessor accessibleContextAccessor;
876    private static AccessibleBundleAccessor accessibleBundleAccessor;
877    private static DragSourceContextAccessor dragSourceContextAccessor;
878    private static DropTargetContextAccessor dropTargetContextAccessor;
879
880    /*
881     * Set an accessor object for the java.awt.Component class.
882     */
883    public static void setComponentAccessor(ComponentAccessor ca) {
884        componentAccessor = ca;
885    }
886
887    /*
888     * Retrieve the accessor object for the java.awt.Component class.
889     */
890    public static ComponentAccessor getComponentAccessor() {
891        if (componentAccessor == null) {
892            unsafe.ensureClassInitialized(Component.class);
893        }
894
895        return componentAccessor;
896    }
897
898    /*
899     * Set an accessor object for the java.awt.Container class.
900     */
901    public static void setContainerAccessor(ContainerAccessor ca) {
902        containerAccessor = ca;
903    }
904
905    /*
906     * Retrieve the accessor object for the java.awt.Container class.
907     */
908    public static ContainerAccessor getContainerAccessor() {
909        if (containerAccessor == null) {
910            unsafe.ensureClassInitialized(Container.class);
911        }
912
913        return containerAccessor;
914    }
915
916    /*
917     * Set an accessor object for the java.awt.Window class.
918     */
919    public static void setWindowAccessor(WindowAccessor wa) {
920        windowAccessor = wa;
921    }
922
923    /*
924     * Retrieve the accessor object for the java.awt.Window class.
925     */
926    public static WindowAccessor getWindowAccessor() {
927        if (windowAccessor == null) {
928            unsafe.ensureClassInitialized(Window.class);
929        }
930        return windowAccessor;
931    }
932
933    /*
934     * Set an accessor object for the java.awt.AWTEvent class.
935     */
936    public static void setAWTEventAccessor(AWTEventAccessor aea) {
937        awtEventAccessor = aea;
938    }
939
940    /*
941     * Retrieve the accessor object for the java.awt.AWTEvent class.
942     */
943    public static AWTEventAccessor getAWTEventAccessor() {
944        if (awtEventAccessor == null) {
945            unsafe.ensureClassInitialized(AWTEvent.class);
946        }
947        return awtEventAccessor;
948    }
949
950    /*
951     * Set an accessor object for the java.awt.event.InputEvent class.
952     */
953    public static void setInputEventAccessor(InputEventAccessor iea) {
954        inputEventAccessor = iea;
955    }
956
957    /*
958     * Retrieve the accessor object for the java.awt.event.InputEvent class.
959     */
960    public static InputEventAccessor getInputEventAccessor() {
961        if (inputEventAccessor == null) {
962            unsafe.ensureClassInitialized(InputEvent.class);
963        }
964        return inputEventAccessor;
965    }
966
967    /*
968     * Set an accessor object for the java.awt.Frame class.
969     */
970    public static void setFrameAccessor(FrameAccessor fa) {
971        frameAccessor = fa;
972    }
973
974    /*
975     * Retrieve the accessor object for the java.awt.Frame class.
976     */
977    public static FrameAccessor getFrameAccessor() {
978        if (frameAccessor == null) {
979            unsafe.ensureClassInitialized(Frame.class);
980        }
981        return frameAccessor;
982    }
983
984    /*
985     * Set an accessor object for the java.awt.KeyboardFocusManager class.
986     */
987    public static void setKeyboardFocusManagerAccessor(KeyboardFocusManagerAccessor kfma) {
988        kfmAccessor = kfma;
989    }
990
991    /*
992     * Retrieve the accessor object for the java.awt.KeyboardFocusManager class.
993     */
994    public static KeyboardFocusManagerAccessor getKeyboardFocusManagerAccessor() {
995        if (kfmAccessor == null) {
996            unsafe.ensureClassInitialized(KeyboardFocusManager.class);
997        }
998        return kfmAccessor;
999    }
1000
1001    /*
1002     * Set an accessor object for the java.awt.MenuComponent class.
1003     */
1004    public static void setMenuComponentAccessor(MenuComponentAccessor mca) {
1005        menuComponentAccessor = mca;
1006    }
1007
1008    /*
1009     * Retrieve the accessor object for the java.awt.MenuComponent class.
1010     */
1011    public static MenuComponentAccessor getMenuComponentAccessor() {
1012        if (menuComponentAccessor == null) {
1013            unsafe.ensureClassInitialized(MenuComponent.class);
1014        }
1015        return menuComponentAccessor;
1016    }
1017
1018    /*
1019     * Set an accessor object for the java.awt.EventQueue class.
1020     */
1021    public static void setEventQueueAccessor(EventQueueAccessor eqa) {
1022        eventQueueAccessor = eqa;
1023    }
1024
1025    /*
1026     * Retrieve the accessor object for the java.awt.EventQueue class.
1027     */
1028    public static EventQueueAccessor getEventQueueAccessor() {
1029        if (eventQueueAccessor == null) {
1030            unsafe.ensureClassInitialized(EventQueue.class);
1031        }
1032        return eventQueueAccessor;
1033    }
1034
1035    /*
1036     * Set an accessor object for the java.awt.PopupMenu class.
1037     */
1038    public static void setPopupMenuAccessor(PopupMenuAccessor pma) {
1039        popupMenuAccessor = pma;
1040    }
1041
1042    /*
1043     * Retrieve the accessor object for the java.awt.PopupMenu class.
1044     */
1045    public static PopupMenuAccessor getPopupMenuAccessor() {
1046        if (popupMenuAccessor == null) {
1047            unsafe.ensureClassInitialized(PopupMenu.class);
1048        }
1049        return popupMenuAccessor;
1050    }
1051
1052    /*
1053     * Set an accessor object for the java.awt.FileDialog class.
1054     */
1055    public static void setFileDialogAccessor(FileDialogAccessor fda) {
1056        fileDialogAccessor = fda;
1057    }
1058
1059    /*
1060     * Retrieve the accessor object for the java.awt.FileDialog class.
1061     */
1062    public static FileDialogAccessor getFileDialogAccessor() {
1063        if (fileDialogAccessor == null) {
1064            unsafe.ensureClassInitialized(FileDialog.class);
1065        }
1066        return fileDialogAccessor;
1067    }
1068
1069    /*
1070     * Set an accessor object for the java.awt.ScrollPaneAdjustable class.
1071     */
1072    public static void setScrollPaneAdjustableAccessor(ScrollPaneAdjustableAccessor adj) {
1073        scrollPaneAdjustableAccessor = adj;
1074    }
1075
1076    /*
1077     * Retrieve the accessor object for the java.awt.ScrollPaneAdjustable
1078     * class.
1079     */
1080    public static ScrollPaneAdjustableAccessor getScrollPaneAdjustableAccessor() {
1081        if (scrollPaneAdjustableAccessor == null) {
1082            unsafe.ensureClassInitialized(ScrollPaneAdjustable.class);
1083        }
1084        return scrollPaneAdjustableAccessor;
1085    }
1086
1087    /**
1088     * Set an accessor object for the java.awt.CheckboxMenuItem class.
1089     */
1090    public static void setCheckboxMenuItemAccessor(CheckboxMenuItemAccessor cmia) {
1091        checkboxMenuItemAccessor = cmia;
1092    }
1093
1094    /**
1095     * Retrieve the accessor object for the java.awt.CheckboxMenuItem class.
1096     */
1097    public static CheckboxMenuItemAccessor getCheckboxMenuItemAccessor() {
1098        if (checkboxMenuItemAccessor == null) {
1099            unsafe.ensureClassInitialized(CheckboxMenuItemAccessor.class);
1100        }
1101        return checkboxMenuItemAccessor;
1102    }
1103
1104    /**
1105     * Set an accessor object for the java.awt.Cursor class.
1106     */
1107    public static void setCursorAccessor(CursorAccessor ca) {
1108        cursorAccessor = ca;
1109    }
1110
1111    /**
1112     * Retrieve the accessor object for the java.awt.Cursor class.
1113     */
1114    public static CursorAccessor getCursorAccessor() {
1115        if (cursorAccessor == null) {
1116            unsafe.ensureClassInitialized(CursorAccessor.class);
1117        }
1118        return cursorAccessor;
1119    }
1120
1121    /**
1122     * Set an accessor object for the java.awt.MenuBar class.
1123     */
1124    public static void setMenuBarAccessor(MenuBarAccessor mba) {
1125        menuBarAccessor = mba;
1126    }
1127
1128    /**
1129     * Retrieve the accessor object for the java.awt.MenuBar class.
1130     */
1131    public static MenuBarAccessor getMenuBarAccessor() {
1132        if (menuBarAccessor == null) {
1133            unsafe.ensureClassInitialized(MenuBarAccessor.class);
1134        }
1135        return menuBarAccessor;
1136    }
1137
1138    /**
1139     * Set an accessor object for the java.awt.MenuItem class.
1140     */
1141    public static void setMenuItemAccessor(MenuItemAccessor mia) {
1142        menuItemAccessor = mia;
1143    }
1144
1145    /**
1146     * Retrieve the accessor object for the java.awt.MenuItem class.
1147     */
1148    public static MenuItemAccessor getMenuItemAccessor() {
1149        if (menuItemAccessor == null) {
1150            unsafe.ensureClassInitialized(MenuItemAccessor.class);
1151        }
1152        return menuItemAccessor;
1153    }
1154
1155    /**
1156     * Set an accessor object for the java.awt.Menu class.
1157     */
1158    public static void setMenuAccessor(MenuAccessor ma) {
1159        menuAccessor = ma;
1160    }
1161
1162    /**
1163     * Retrieve the accessor object for the java.awt.Menu class.
1164     */
1165    public static MenuAccessor getMenuAccessor() {
1166        if (menuAccessor == null) {
1167            unsafe.ensureClassInitialized(MenuAccessor.class);
1168        }
1169        return menuAccessor;
1170    }
1171
1172    /**
1173     * Set an accessor object for the java.awt.event.KeyEvent class.
1174     */
1175    public static void setKeyEventAccessor(KeyEventAccessor kea) {
1176        keyEventAccessor = kea;
1177    }
1178
1179    /**
1180     * Retrieve the accessor object for the java.awt.event.KeyEvent class.
1181     */
1182    public static KeyEventAccessor getKeyEventAccessor() {
1183        if (keyEventAccessor == null) {
1184            unsafe.ensureClassInitialized(KeyEventAccessor.class);
1185        }
1186        return keyEventAccessor;
1187    }
1188
1189    /**
1190     * Set an accessor object for the javax.swing.ClientPropertyKey class.
1191     */
1192    public static void setClientPropertyKeyAccessor(ClientPropertyKeyAccessor cpka) {
1193        clientPropertyKeyAccessor = cpka;
1194    }
1195
1196    /**
1197     * Retrieve the accessor object for the javax.swing.ClientPropertyKey class.
1198     */
1199    public static ClientPropertyKeyAccessor getClientPropertyKeyAccessor() {
1200        if (clientPropertyKeyAccessor == null) {
1201            unsafe.ensureClassInitialized(ClientPropertyKeyAccessor.class);
1202        }
1203        return clientPropertyKeyAccessor;
1204    }
1205
1206    /**
1207     * Set an accessor object for the java.awt.SystemTray class.
1208     */
1209    public static void setSystemTrayAccessor(SystemTrayAccessor sta) {
1210        systemTrayAccessor = sta;
1211    }
1212
1213    /**
1214     * Retrieve the accessor object for the java.awt.SystemTray class.
1215     */
1216    public static SystemTrayAccessor getSystemTrayAccessor() {
1217        if (systemTrayAccessor == null) {
1218            unsafe.ensureClassInitialized(SystemTrayAccessor.class);
1219        }
1220        return systemTrayAccessor;
1221    }
1222
1223    /**
1224     * Set an accessor object for the java.awt.TrayIcon class.
1225     */
1226    public static void setTrayIconAccessor(TrayIconAccessor tia) {
1227        trayIconAccessor = tia;
1228    }
1229
1230    /**
1231     * Retrieve the accessor object for the java.awt.TrayIcon class.
1232     */
1233    public static TrayIconAccessor getTrayIconAccessor() {
1234        if (trayIconAccessor == null) {
1235            unsafe.ensureClassInitialized(TrayIconAccessor.class);
1236        }
1237        return trayIconAccessor;
1238    }
1239
1240    /**
1241     * Set an accessor object for the java.awt.DefaultKeyboardFocusManager class.
1242     */
1243    public static void setDefaultKeyboardFocusManagerAccessor(DefaultKeyboardFocusManagerAccessor dkfma) {
1244        defaultKeyboardFocusManagerAccessor = dkfma;
1245    }
1246
1247    /**
1248     * Retrieve the accessor object for the java.awt.DefaultKeyboardFocusManager class.
1249     */
1250    public static DefaultKeyboardFocusManagerAccessor getDefaultKeyboardFocusManagerAccessor() {
1251        if (defaultKeyboardFocusManagerAccessor == null) {
1252            unsafe.ensureClassInitialized(DefaultKeyboardFocusManagerAccessor.class);
1253        }
1254        return defaultKeyboardFocusManagerAccessor;
1255    }
1256    /*
1257     * Set an accessor object for the java.awt.SequencedEvent class.
1258     */
1259    public static void setSequencedEventAccessor(SequencedEventAccessor sea) {
1260        sequencedEventAccessor = sea;
1261    }
1262
1263    /*
1264     * Get the accessor object for the java.awt.SequencedEvent class.
1265     */
1266    public static SequencedEventAccessor getSequencedEventAccessor() {
1267        if (sequencedEventAccessor == null) {
1268            try {
1269                unsafe.ensureClassInitialized(
1270                        Class.forName("java.awt.SequencedEvent"));
1271            } catch (ClassNotFoundException ignore) {
1272            }
1273        }
1274        return sequencedEventAccessor;
1275    }
1276
1277    /*
1278     * Set an accessor object for the java.awt.Toolkit class.
1279     */
1280    public static void setToolkitAccessor(ToolkitAccessor ta) {
1281        toolkitAccessor = ta;
1282    }
1283
1284    /*
1285     * Get the accessor object for the java.awt.Toolkit class.
1286     */
1287    public static ToolkitAccessor getToolkitAccessor() {
1288        if (toolkitAccessor == null) {
1289            unsafe.ensureClassInitialized(Toolkit.class);
1290        }
1291
1292        return toolkitAccessor;
1293    }
1294
1295    /*
1296     * Get the accessor object for the java.awt.event.InvocationEvent class.
1297     */
1298    public static void setInvocationEventAccessor(InvocationEventAccessor invocationEventAccessor) {
1299        AWTAccessor.invocationEventAccessor = invocationEventAccessor;
1300    }
1301
1302    /*
1303     * Set the accessor object for the java.awt.event.InvocationEvent class.
1304     */
1305    public static InvocationEventAccessor getInvocationEventAccessor() {
1306        return invocationEventAccessor;
1307    }
1308
1309    /*
1310     * Get the accessor object for the java.awt.SystemColor class.
1311     */
1312    public static SystemColorAccessor getSystemColorAccessor() {
1313        if (systemColorAccessor == null) {
1314            unsafe.ensureClassInitialized(SystemColor.class);
1315        }
1316
1317        return systemColorAccessor;
1318    }
1319
1320     /*
1321     * Set the accessor object for the java.awt.SystemColor class.
1322     */
1323     public static void setSystemColorAccessor(SystemColorAccessor systemColorAccessor) {
1324         AWTAccessor.systemColorAccessor = systemColorAccessor;
1325     }
1326
1327    /*
1328     * Get the accessor object for the javax.accessibility.AccessibleContext class.
1329     */
1330    public static AccessibleContextAccessor getAccessibleContextAccessor() {
1331        if (accessibleContextAccessor == null) {
1332            unsafe.ensureClassInitialized(AccessibleContext.class);
1333        }
1334        return accessibleContextAccessor;
1335    }
1336
1337   /*
1338    * Set the accessor object for the javax.accessibility.AccessibleBundle class.
1339    */
1340    public static void setAccessibleBundleAccessor(AccessibleBundleAccessor accessor) {
1341        AWTAccessor.accessibleBundleAccessor = accessor;
1342    }
1343
1344    /*
1345     * Get the accessor object for the javax.accessibility.AccessibleBundle class.
1346     */
1347    public static AccessibleBundleAccessor getAccessibleBundleAccessor() {
1348        if (accessibleBundleAccessor == null) {
1349            unsafe.ensureClassInitialized(AccessibleBundle.class);
1350        }
1351        return accessibleBundleAccessor;
1352    }
1353
1354   /*
1355    * Set the accessor object for the javax.accessibility.AccessibleContext class.
1356    */
1357    public static void setAccessibleContextAccessor(AccessibleContextAccessor accessor) {
1358        AWTAccessor.accessibleContextAccessor = accessor;
1359    }
1360
1361    /*
1362     * Get the accessor object for the java.awt.dnd.DragSourceContext class.
1363     */
1364    public static DragSourceContextAccessor getDragSourceContextAccessor() {
1365        if (dragSourceContextAccessor == null) {
1366            unsafe.ensureClassInitialized(DragSourceContext.class);
1367        }
1368        return dragSourceContextAccessor;
1369    }
1370
1371    /*
1372     * Set the accessor object for the java.awt.dnd.DragSourceContext class.
1373     */
1374    public static void setDragSourceContextAccessor(DragSourceContextAccessor accessor) {
1375        AWTAccessor.dragSourceContextAccessor = accessor;
1376    }
1377
1378    /*
1379     * Get the accessor object for the java.awt.dnd.DropTargetContext class.
1380     */
1381    public static DropTargetContextAccessor getDropTargetContextAccessor() {
1382        if (dropTargetContextAccessor == null) {
1383            unsafe.ensureClassInitialized(DropTargetContext.class);
1384        }
1385        return dropTargetContextAccessor;
1386    }
1387
1388    /*
1389     * Set the accessor object for the java.awt.dnd.DropTargetContext class.
1390     */
1391    public static void setDropTargetContextAccessor(DropTargetContextAccessor accessor) {
1392        AWTAccessor.dropTargetContextAccessor = accessor;
1393    }
1394
1395}
1396