--- a/jdk/src/share/classes/java/lang/reflect/Proxy.java Mon Mar 10 14:32:51 2008 -0700
+++ b/jdk/src/share/classes/java/lang/reflect/Proxy.java Mon Mar 10 15:07:09 2008 -0700
@@ -33,6 +33,7 @@
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
+import java.util.List;
import java.util.WeakHashMap;
import sun.misc.ProxyGenerator;
@@ -230,7 +231,8 @@
{ InvocationHandler.class };
/** maps a class loader to the proxy class cache for that loader */
- private static Map loaderToCache = new WeakHashMap();
+ private static Map<ClassLoader, Map<List<String>, Object>> loaderToCache
+ = new WeakHashMap<ClassLoader, Map<List<String>, Object>>();
/** marks that a particular proxy class is currently being generated */
private static Object pendingGenerationMarker = new Object();
@@ -240,8 +242,8 @@
private static Object nextUniqueNumberLock = new Object();
/** set of all generated proxy classes, for isProxyClass implementation */
- private static Map proxyClasses =
- Collections.synchronizedMap(new WeakHashMap());
+ private static Map<Class<?>, Void> proxyClasses =
+ Collections.synchronizedMap(new WeakHashMap<Class<?>, Void>());
/**
* the invocation handler for this proxy instance.
@@ -353,7 +355,8 @@
/* collect interface names to use as key for proxy class cache */
String[] interfaceNames = new String[interfaces.length];
- Set interfaceSet = new HashSet(); // for detecting duplicates
+ // for detecting duplicates
+ Set<Class<?>> interfaceSet = new HashSet<Class<?>>();
for (int i = 0; i < interfaces.length; i++) {
/*
@@ -401,16 +404,16 @@
* representation of a class makes for an implicit weak
* reference to the class.
*/
- Object key = Arrays.asList(interfaceNames);
+ List<String> key = Arrays.asList(interfaceNames);
/*
* Find or create the proxy class cache for the class loader.
*/
- Map cache;
+ Map<List<String>, Object> cache;
synchronized (loaderToCache) {
- cache = (Map) loaderToCache.get(loader);
+ cache = loaderToCache.get(loader);
if (cache == null) {
- cache = new HashMap();
+ cache = new HashMap<List<String>, Object>();
loaderToCache.put(loader, cache);
}
/*
@@ -442,7 +445,7 @@
do {
Object value = cache.get(key);
if (value instanceof Reference) {
- proxyClass = (Class) ((Reference) value).get();
+ proxyClass = (Class<?>) ((Reference) value).get();
}
if (proxyClass != null) {
// proxy class already generated: return it
@@ -544,7 +547,7 @@
*/
synchronized (cache) {
if (proxyClass != null) {
- cache.put(key, new WeakReference(proxyClass));
+ cache.put(key, new WeakReference<Class<?>>(proxyClass));
} else {
cache.remove(key);
}
@@ -595,14 +598,14 @@
/*
* Look up or generate the designated proxy class.
*/
- Class cl = getProxyClass(loader, interfaces);
+ Class<?> cl = getProxyClass(loader, interfaces);
/*
* Invoke its constructor with the designated invocation handler.
*/
try {
Constructor cons = cl.getConstructor(constructorParams);
- return (Object) cons.newInstance(new Object[] { h });
+ return cons.newInstance(new Object[] { h });
} catch (NoSuchMethodException e) {
throw new InternalError(e.toString());
} catch (IllegalAccessException e) {