Merged gcj-eclipse branch to trunk.
From-SVN: r120621
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/* AWTKeyStroke.java -- an immutable key stroke
|
||||
Copyright (C) 2002, 2004, 2005 Free Software Foundation
|
||||
Copyright (C) 2002, 2004, 2005 Free Software Foundation
|
||||
|
||||
This file is part of GNU Classpath.
|
||||
|
||||
@@ -65,6 +65,7 @@ import java.util.StringTokenizer;
|
||||
* no-arg constructor (of any accessibility).
|
||||
*
|
||||
* @author Eric Blake (ebb9@email.byu.edu)
|
||||
* @author Andrew John Hughes (gnu_andrew@member.fsf.org)
|
||||
* @see #getAWTKeyStroke(char)
|
||||
* @since 1.4
|
||||
* @status updated to 1.4
|
||||
@@ -85,13 +86,15 @@ public class AWTKeyStroke implements Serializable
|
||||
* under the assumption that garbage collection of a new keystroke is
|
||||
* easy when we find the old one that it matches in the cache.
|
||||
*/
|
||||
private static final LinkedHashMap cache = new LinkedHashMap(11, 0.75f, true)
|
||||
private static final LinkedHashMap<AWTKeyStroke,AWTKeyStroke> cache =
|
||||
new LinkedHashMap<AWTKeyStroke,AWTKeyStroke>(11, 0.75f, true)
|
||||
{
|
||||
/** The largest the keystroke cache can grow. */
|
||||
private static final int MAX_CACHE_SIZE = 2048;
|
||||
|
||||
/** Prune stale entries. */
|
||||
protected boolean removeEldestEntry(Map.Entry eldest)
|
||||
protected boolean removeEldestEntry(Map.Entry<AWTKeyStroke,AWTKeyStroke>
|
||||
eldest)
|
||||
{ // XXX - FIXME Use Map.Entry, not just Entry as gcj 3.1 workaround.
|
||||
return size() > MAX_CACHE_SIZE;
|
||||
}
|
||||
@@ -114,7 +117,7 @@ public class AWTKeyStroke implements Serializable
|
||||
*
|
||||
* @see #getAWTKeyStroke(String)
|
||||
*/
|
||||
static final HashMap vktable = new HashMap();
|
||||
static final HashMap<String,Object> vktable = new HashMap<String,Object>();
|
||||
static
|
||||
{
|
||||
// Using reflection saves the hassle of keeping this in sync with KeyEvent,
|
||||
@@ -229,7 +232,7 @@ public class AWTKeyStroke implements Serializable
|
||||
* @throws IllegalArgumentException subclass doesn't have no-arg constructor
|
||||
* @throws ClassCastException subclass doesn't extend AWTKeyStroke
|
||||
*/
|
||||
protected static void registerSubclass(final Class subclass)
|
||||
protected static void registerSubclass(final Class<?> subclass)
|
||||
{
|
||||
if (subclass == null)
|
||||
throw new IllegalArgumentException();
|
||||
@@ -252,7 +255,8 @@ public class AWTKeyStroke implements Serializable
|
||||
throws NoSuchMethodException, InstantiationException,
|
||||
IllegalAccessException, InvocationTargetException
|
||||
{
|
||||
Constructor c = subclass.getDeclaredConstructor(null);
|
||||
Constructor<?> c =
|
||||
subclass.getDeclaredConstructor((Class<?>[])null);
|
||||
c.setAccessible(true);
|
||||
// Create a new instance, to make sure that we can, and
|
||||
// to cause any ClassCastException.
|
||||
@@ -595,7 +599,7 @@ public class AWTKeyStroke implements Serializable
|
||||
*/
|
||||
protected Object readResolve() throws ObjectStreamException
|
||||
{
|
||||
AWTKeyStroke s = (AWTKeyStroke) cache.get(this);
|
||||
AWTKeyStroke s = cache.get(this);
|
||||
if (s != null)
|
||||
return s;
|
||||
cache.put(this, this);
|
||||
|
||||
Reference in New Issue
Block a user