src/share/classes/java/awt/AWTKeyStroke.java

Print this page

        

*** 65,75 **** * @since 1.4 */ public class AWTKeyStroke implements Serializable { static final long serialVersionUID = -6430539691155161871L; ! private static Map modifierKeywords; /** * Associates VK_XXX (as a String) with code (as Integer). This is * done to avoid the overhead of the reflective call to find the * constant. */ --- 65,75 ---- * @since 1.4 */ public class AWTKeyStroke implements Serializable { static final long serialVersionUID = -6430539691155161871L; ! private static Map<String, Integer> modifierKeywords; /** * Associates VK_XXX (as a String) with code (as Integer). This is * done to avoid the overhead of the reflective call to find the * constant. */
*** 83,94 **** /* * Reads keystroke class from AppContext and if null, puts there the * AWTKeyStroke class. * Must be called under locked AWTKeyStro */ ! private static Class getAWTKeyStrokeClass() { ! Class clazz = (Class)AppContext.getAppContext().get(AWTKeyStroke.class); if (clazz == null) { clazz = AWTKeyStroke.class; AppContext.getAppContext().put(AWTKeyStroke.class, AWTKeyStroke.class); } return clazz; --- 83,94 ---- /* * Reads keystroke class from AppContext and if null, puts there the * AWTKeyStroke class. * Must be called under locked AWTKeyStro */ ! private static Class<AWTKeyStroke> getAWTKeyStrokeClass() { ! Class<AWTKeyStroke> clazz = (Class)AppContext.getAppContext().get(AWTKeyStroke.class); if (clazz == null) { clazz = AWTKeyStroke.class; AppContext.getAppContext().put(AWTKeyStroke.class, AWTKeyStroke.class); } return clazz;
*** 180,190 **** protected static void registerSubclass(Class<?> subclass) { if (subclass == null) { throw new IllegalArgumentException("subclass cannot be null"); } synchronized (AWTKeyStroke.class) { ! Class keyStrokeClass = (Class)AppContext.getAppContext().get(AWTKeyStroke.class); if (keyStrokeClass != null && keyStrokeClass.equals(subclass)){ // Already registered return; } } --- 180,190 ---- protected static void registerSubclass(Class<?> subclass) { if (subclass == null) { throw new IllegalArgumentException("subclass cannot be null"); } synchronized (AWTKeyStroke.class) { ! Class<AWTKeyStroke> keyStrokeClass = (Class)AppContext.getAppContext().get(AWTKeyStroke.class); if (keyStrokeClass != null && keyStrokeClass.equals(subclass)){ // Already registered return; } }
*** 227,238 **** threat as accessible flag is set only for this Constructor object, not for Class constructor. */ private static Constructor getCtor(final Class clazz) { ! Object ctor = AccessController.doPrivileged(new PrivilegedAction() { ! public Object run() { try { Constructor ctor = clazz.getDeclaredConstructor((Class[]) null); if (ctor != null) { ctor.setAccessible(true); } --- 227,238 ---- threat as accessible flag is set only for this Constructor object, not for Class constructor. */ private static Constructor getCtor(final Class clazz) { ! Constructor ctor = AccessController.doPrivileged(new PrivilegedAction<Constructor>() { ! public Constructor run() { try { Constructor ctor = clazz.getDeclaredConstructor((Class[]) null); if (ctor != null) { ctor.setAccessible(true); }
*** 247,267 **** } private static synchronized AWTKeyStroke getCachedStroke (char keyChar, int keyCode, int modifiers, boolean onKeyRelease) { ! Map cache = (Map)AppContext.getAppContext().get(APP_CONTEXT_CACHE_KEY); AWTKeyStroke cacheKey = (AWTKeyStroke)AppContext.getAppContext().get(APP_CONTEXT_KEYSTROKE_KEY); if (cache == null) { ! cache = new HashMap(); AppContext.getAppContext().put(APP_CONTEXT_CACHE_KEY, cache); } if (cacheKey == null) { try { ! Class clazz = getAWTKeyStrokeClass(); cacheKey = (AWTKeyStroke)getCtor(clazz).newInstance((Object[]) null); AppContext.getAppContext().put(APP_CONTEXT_KEYSTROKE_KEY, cacheKey); } catch (InstantiationException e) { assert(false); } catch (IllegalAccessException e) { --- 247,267 ---- } private static synchronized AWTKeyStroke getCachedStroke (char keyChar, int keyCode, int modifiers, boolean onKeyRelease) { ! Map<AWTKeyStroke, AWTKeyStroke> cache = (Map)AppContext.getAppContext().get(APP_CONTEXT_CACHE_KEY); AWTKeyStroke cacheKey = (AWTKeyStroke)AppContext.getAppContext().get(APP_CONTEXT_KEYSTROKE_KEY); if (cache == null) { ! cache = new HashMap<>(); AppContext.getAppContext().put(APP_CONTEXT_CACHE_KEY, cache); } if (cacheKey == null) { try { ! Class<AWTKeyStroke> clazz = getAWTKeyStrokeClass(); cacheKey = (AWTKeyStroke)getCtor(clazz).newInstance((Object[]) null); AppContext.getAppContext().put(APP_CONTEXT_KEYSTROKE_KEY, cacheKey); } catch (InstantiationException e) { assert(false); } catch (IllegalAccessException e) {
*** 511,521 **** boolean typed = false; boolean pressed = false; synchronized (AWTKeyStroke.class) { if (modifierKeywords == null) { ! Map uninitializedMap = new HashMap(8, 1.0f); uninitializedMap.put("shift", Integer.valueOf(InputEvent.SHIFT_DOWN_MASK |InputEvent.SHIFT_MASK)); uninitializedMap.put("control", Integer.valueOf(InputEvent.CTRL_DOWN_MASK --- 511,521 ---- boolean typed = false; boolean pressed = false; synchronized (AWTKeyStroke.class) { if (modifierKeywords == null) { ! Map<String, Integer> uninitializedMap = new HashMap<>(8, 1.0f); uninitializedMap.put("shift", Integer.valueOf(InputEvent.SHIFT_DOWN_MASK |InputEvent.SHIFT_MASK)); uninitializedMap.put("control", Integer.valueOf(InputEvent.CTRL_DOWN_MASK
*** 859,874 **** } } class VKCollection { ! Map code2name; ! Map name2code; public VKCollection() { ! code2name = new HashMap(); ! name2code = new HashMap(); } public synchronized void put(String name, Integer code) { assert((name != null) && (code != null)); assert(findName(code) == null); --- 859,874 ---- } } class VKCollection { ! Map<Integer, String> code2name; ! Map<String, Integer> name2code; public VKCollection() { ! code2name = new HashMap<>(); ! name2code = new HashMap<>(); } public synchronized void put(String name, Integer code) { assert((name != null) && (code != null)); assert(findName(code) == null);