提交 a8848efe 编写于 作者: M mcimadamore

7116954: Misc warnings in java.beans/java.beans.context

Summary: Remove generic warnings form java.beans and java.beans.context
Reviewed-by: alanb, chegar
上级 819755bd
......@@ -37,8 +37,8 @@ import java.lang.ref.Reference;
public class BeanDescriptor extends FeatureDescriptor {
private Reference<Class> beanClassRef;
private Reference<Class> customizerClassRef;
private Reference<? extends Class<?>> beanClassRef;
private Reference<? extends Class<?>> customizerClassRef;
/**
* Create a BeanDescriptor for a bean that doesn't have a customizer.
......@@ -59,8 +59,8 @@ public class BeanDescriptor extends FeatureDescriptor {
* the bean's Customizer. For example sun.beans.OurButtonCustomizer.class.
*/
public BeanDescriptor(Class<?> beanClass, Class<?> customizerClass) {
this.beanClassRef = getWeakReference((Class)beanClass);
this.customizerClassRef = getWeakReference((Class)customizerClass);
this.beanClassRef = getWeakReference(beanClass);
this.customizerClassRef = getWeakReference(customizerClass);
String name = beanClass.getName();
while (name.indexOf('.') >= 0) {
......
......@@ -181,9 +181,9 @@ public class Beans {
// Try to find a serialized object with this name
final String serName = beanName.replace('.','/').concat(".ser");
final ClassLoader loader = cls;
ins = (InputStream)AccessController.doPrivileged
(new PrivilegedAction() {
public Object run() {
ins = AccessController.doPrivileged
(new PrivilegedAction<InputStream>() {
public InputStream run() {
if (loader == null)
return ClassLoader.getSystemResourceAsStream(serName);
else
......@@ -213,7 +213,7 @@ public class Beans {
if (result == null) {
// No serialized object, try just instantiating the class
Class cl;
Class<?> cl;
try {
cl = ClassFinder.findClass(beanName, cls);
......@@ -278,10 +278,10 @@ public class Beans {
// Now get the URL correponding to the resource name.
final ClassLoader cloader = cls;
objectUrl = (URL)
objectUrl =
AccessController.doPrivileged
(new PrivilegedAction() {
public Object run() {
(new PrivilegedAction<URL>() {
public URL run() {
if (cloader == null)
return ClassLoader.getSystemResource
(resourceName);
......@@ -326,7 +326,7 @@ public class Beans {
// now, if there is a BeanContext, add the bean, if applicable.
if (beanContext != null) {
beanContext.add(result);
unsafeBeanContextAdd(beanContext, result);
}
// If it was deserialized then it was already init-ed.
......@@ -344,12 +344,16 @@ public class Beans {
((BeansAppletStub)stub).active = true;
} else initializer.activate(applet);
} else if (beanContext != null) beanContext.add(result);
} else if (beanContext != null) unsafeBeanContextAdd(beanContext, result);
}
return result;
}
@SuppressWarnings("unchecked")
private static void unsafeBeanContextAdd(BeanContext beanContext, Object res) {
beanContext.add(res);
}
/**
* From a given bean, obtain an object representing a specified
......@@ -496,6 +500,7 @@ class ObjectInputStreamWithLoader extends ObjectInputStream
/**
* Use the given ClassLoader rather than using the system class
*/
@SuppressWarnings("rawtypes")
protected Class resolveClass(ObjectStreamClass classDesc)
throws IOException, ClassNotFoundException {
......@@ -511,7 +516,7 @@ class ObjectInputStreamWithLoader extends ObjectInputStream
class BeansAppletContext implements AppletContext {
Applet target;
Hashtable imageCache = new Hashtable();
Hashtable<URL,Object> imageCache = new Hashtable<>();
BeansAppletContext(Applet target) {
this.target = target;
......@@ -556,8 +561,8 @@ class BeansAppletContext implements AppletContext {
return null;
}
public Enumeration getApplets() {
Vector applets = new Vector();
public Enumeration<Applet> getApplets() {
Vector<Applet> applets = new Vector<>();
applets.addElement(target);
return applets.elements();
}
......@@ -583,7 +588,7 @@ class BeansAppletContext implements AppletContext {
return null;
}
public Iterator getStreamKeys(){
public Iterator<String> getStreamKeys(){
// We do nothing.
return null;
}
......
......@@ -76,7 +76,7 @@ abstract class ChangeListenerMap<L extends EventListener> {
*/
public final synchronized void add(String name, L listener) {
if (this.map == null) {
this.map = new HashMap<String, L[]>();
this.map = new HashMap<>();
}
L[] array = this.map.get(name);
int size = (array != null)
......@@ -146,7 +146,7 @@ abstract class ChangeListenerMap<L extends EventListener> {
public final void set(String name, L[] listeners) {
if (listeners != null) {
if (this.map == null) {
this.map = new HashMap<String, L[]>();
this.map = new HashMap<>();
}
this.map.put(name, listeners);
}
......@@ -167,7 +167,7 @@ abstract class ChangeListenerMap<L extends EventListener> {
if (this.map == null) {
return newArray(0);
}
List<L> list = new ArrayList<L>();
List<L> list = new ArrayList<>();
L[] listeners = this.map.get(null);
if (listeners != null) {
......@@ -239,6 +239,7 @@ abstract class ChangeListenerMap<L extends EventListener> {
*/
public final L extract(L listener) {
while (listener instanceof EventListenerProxy) {
@SuppressWarnings("unchecked")
EventListenerProxy<L> proxy = (EventListenerProxy<L>) listener;
listener = proxy.getListener();
}
......
......@@ -95,7 +95,7 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate {
this.constructor = constructorPropertyNames;
}
private static boolean definesEquals(Class type) {
private static boolean definesEquals(Class<?> type) {
try {
return type == type.getMethod("equals", Object.class).getDeclaringClass();
}
......@@ -153,7 +153,7 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate {
*/
protected Expression instantiate(Object oldInstance, Encoder out) {
int nArgs = constructor.length;
Class type = oldInstance.getClass();
Class<?> type = oldInstance.getClass();
Object[] constructorArgs = new Object[nArgs];
for(int i = 0; i < nArgs; i++) {
try {
......@@ -167,7 +167,7 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate {
return new Expression(oldInstance, oldInstance.getClass(), "new", constructorArgs);
}
private Method findMethod(Class type, String property) {
private Method findMethod(Class<?> type, String property) {
if (property == null) {
throw new IllegalArgumentException("Property name is null");
}
......@@ -182,7 +182,7 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate {
return method;
}
private void doProperty(Class type, PropertyDescriptor pd, Object oldInstance, Object newInstance, Encoder out) throws Exception {
private void doProperty(Class<?> type, PropertyDescriptor pd, Object oldInstance, Object newInstance, Encoder out) throws Exception {
Method getter = pd.getReadMethod();
Method setter = pd.getWriteMethod();
......@@ -218,7 +218,7 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate {
}
// Write out the properties of this instance.
private void initBean(Class type, Object oldInstance, Object newInstance, Encoder out) {
private void initBean(Class<?> type, Object oldInstance, Object newInstance, Encoder out) {
for (Field field : type.getFields()) {
int mod = field.getModifiers();
if (Modifier.isFinal(mod) || Modifier.isStatic(mod) || Modifier.isTransient(mod)) {
......@@ -288,7 +288,7 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate {
if (d.isTransient()) {
continue;
}
Class listenerType = d.getListenerType();
Class<?> listenerType = d.getListenerType();
// The ComponentListener is added automatically, when
......@@ -318,7 +318,7 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate {
}
catch (Exception e2) {
try {
Method m = type.getMethod("getListeners", new Class[]{Class.class});
Method m = type.getMethod("getListeners", new Class<?>[]{Class.class});
oldL = (EventListener[])MethodUtil.invoke(m, oldInstance, new Object[]{listenerType});
newL = (EventListener[])MethodUtil.invoke(m, newInstance, new Object[]{listenerType});
}
......@@ -401,7 +401,7 @@ public class DefaultPersistenceDelegate extends PersistenceDelegate {
}
}
private static PropertyDescriptor getPropertyDescriptor(Class type, String property) {
private static PropertyDescriptor getPropertyDescriptor(Class<?> type, String property) {
try {
for (PropertyDescriptor pd : Introspector.getBeanInfo(type).getPropertyDescriptors()) {
if (property.equals(pd.getName()))
......
......@@ -47,10 +47,10 @@ import java.util.Map;
public class Encoder {
private final PersistenceDelegateFinder finder = new PersistenceDelegateFinder();
private Map bindings = new IdentityHashMap();
private Map<Object, Expression> bindings = new IdentityHashMap<>();
private ExceptionListener exceptionListener;
boolean executeStatements = true;
private Map attributes;
private Map<Object, Object> attributes;
/**
* Write the specified object to the output stream.
......@@ -221,7 +221,7 @@ public class Encoder {
* @see #get
*/
public Object remove(Object oldInstance) {
Expression exp = (Expression)bindings.remove(oldInstance);
Expression exp = bindings.remove(oldInstance);
return getValue(exp);
}
......@@ -242,7 +242,7 @@ public class Encoder {
oldInstance.getClass() == String.class) {
return oldInstance;
}
Expression exp = (Expression)bindings.get(oldInstance);
Expression exp = bindings.get(oldInstance);
return getValue(exp);
}
......@@ -331,7 +331,7 @@ public class Encoder {
// Package private method for setting an attributes table for the encoder
void setAttribute(Object key, Object value) {
if (attributes == null) {
attributes = new HashMap();
attributes = new HashMap<>();
}
attributes.put(key, value);
}
......
......@@ -385,14 +385,14 @@ public class EventHandler implements InvocationHandler {
if (target != null) {
getter = Statement.getMethod(target.getClass(),
"get" + NameGenerator.capitalize(first),
new Class[]{});
new Class<?>[]{});
if (getter == null) {
getter = Statement.getMethod(target.getClass(),
"is" + NameGenerator.capitalize(first),
new Class[]{});
new Class<?>[]{});
}
if (getter == null) {
getter = Statement.getMethod(target.getClass(), first, new Class[]{});
getter = Statement.getMethod(target.getClass(), first, new Class<?>[]{});
}
}
if (getter == null) {
......@@ -450,12 +450,12 @@ public class EventHandler implements InvocationHandler {
if (eventPropertyName == null) { // Nullary method.
newArgs = new Object[]{};
argTypes = new Class[]{};
argTypes = new Class<?>[]{};
}
else {
Object input = applyGetters(arguments[0], getEventPropertyName());
newArgs = new Object[]{input};
argTypes = new Class[]{input == null ? null :
argTypes = new Class<?>[]{input == null ? null :
input.getClass()};
}
try {
......@@ -674,6 +674,7 @@ public class EventHandler implements InvocationHandler {
*
* @see EventHandler
*/
@SuppressWarnings("unchecked")
public static <T> T create(Class<T> listenerInterface,
Object target, String action,
String eventPropertyName,
......@@ -688,7 +689,7 @@ public class EventHandler implements InvocationHandler {
"listenerInterface must be non-null");
}
return (T)Proxy.newProxyInstance(target.getClass().getClassLoader(),
new Class[] {listenerInterface},
new Class<?>[] {listenerInterface},
eventHandler);
}
}
......@@ -45,7 +45,7 @@ public class EventSetDescriptor extends FeatureDescriptor {
private MethodDescriptor getMethodDescriptor;
private Reference<Method[]> listenerMethodsRef;
private Reference<Class> listenerTypeRef;
private Reference<? extends Class<?>> listenerTypeRef;
private boolean unicast;
private boolean inDefaultEventSet = true;
......@@ -91,7 +91,7 @@ public class EventSetDescriptor extends FeatureDescriptor {
}
}
private static String getListenerClassName(Class cls) {
private static String getListenerClassName(Class<?> cls) {
String className = cls.getName();
return className.substring(className.lastIndexOf('.') + 1);
}
......@@ -182,7 +182,7 @@ public class EventSetDescriptor extends FeatureDescriptor {
}
}
private static Method getMethod(Class cls, String name, int args)
private static Method getMethod(Class<?> cls, String name, int args)
throws IntrospectionException {
if (name == null) {
return null;
......@@ -295,7 +295,7 @@ public class EventSetDescriptor extends FeatureDescriptor {
: null;
}
private void setListenerType(Class cls) {
private void setListenerType(Class<?> cls) {
this.listenerTypeRef = getWeakReference(cls);
}
......
......@@ -51,7 +51,7 @@ import java.util.Map.Entry;
public class FeatureDescriptor {
private static final String TRANSIENT = "transient";
private Reference<Class> classRef;
private Reference<? extends Class<?>> classRef;
/**
* Constructs a <code>FeatureDescriptor</code>.
......@@ -284,7 +284,7 @@ public class FeatureDescriptor {
*/
private Hashtable<String, Object> getTable() {
if (this.table == null) {
this.table = new Hashtable<String, Object>();
this.table = new Hashtable<>();
}
return this.table;
}
......@@ -317,11 +317,11 @@ public class FeatureDescriptor {
// Package private methods for recreating the weak/soft referent
void setClass0(Class cls) {
void setClass0(Class<?> cls) {
this.classRef = getWeakReference(cls);
}
Class getClass0() {
Class<?> getClass0() {
return (this.classRef != null)
? this.classRef.get()
: null;
......@@ -336,7 +336,7 @@ public class FeatureDescriptor {
*/
static <T> Reference<T> getSoftReference(T object) {
return (object != null)
? new SoftReference<T>(object)
? new SoftReference<>(object)
: null;
}
......@@ -349,7 +349,7 @@ public class FeatureDescriptor {
*/
static <T> Reference<T> getWeakReference(T object) {
return (object != null)
? new WeakReference<T>(object)
? new WeakReference<>(object)
: null;
}
......@@ -363,7 +363,7 @@ public class FeatureDescriptor {
* @see Method#getGenericReturnType
* @see Method#getReturnType
*/
static Class getReturnType(Class base, Method method) {
static Class<?> getReturnType(Class<?> base, Method method) {
if (base == null) {
base = method.getDeclaringClass();
}
......@@ -380,7 +380,7 @@ public class FeatureDescriptor {
* @see Method#getGenericParameterTypes
* @see Method#getParameterTypes
*/
static Class[] getParameterTypes(Class base, Method method) {
static Class<?>[] getParameterTypes(Class<?> base, Method method) {
if (base == null) {
base = method.getDeclaringClass();
}
......@@ -425,7 +425,7 @@ public class FeatureDescriptor {
void appendTo(StringBuilder sb) {
}
static void appendTo(StringBuilder sb, String name, Reference reference) {
static void appendTo(StringBuilder sb, String name, Reference<?> reference) {
if (reference != null) {
appendTo(sb, name, reference.get());
}
......
......@@ -40,7 +40,7 @@ import java.lang.reflect.Method;
public class IndexedPropertyDescriptor extends PropertyDescriptor {
private Reference<Class> indexedPropertyTypeRef;
private Reference<? extends Class<?>> indexedPropertyTypeRef;
private Reference<Method> indexedReadMethodRef;
private Reference<Method> indexedWriteMethodRef;
......@@ -175,14 +175,14 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor {
public synchronized Method getIndexedReadMethod() {
Method indexedReadMethod = getIndexedReadMethod0();
if (indexedReadMethod == null) {
Class cls = getClass0();
Class<?> cls = getClass0();
if (cls == null ||
(indexedReadMethodName == null && indexedReadMethodRef == null)) {
// the Indexed readMethod was explicitly set to null.
return null;
}
if (indexedReadMethodName == null) {
Class type = getIndexedPropertyType0();
Class<?> type = getIndexedPropertyType0();
if (type == boolean.class || type == null) {
indexedReadMethodName = Introspector.IS_PREFIX + getBaseName();
} else {
......@@ -190,7 +190,7 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor {
}
}
Class[] args = { int.class };
Class<?>[] args = { int.class };
indexedReadMethod = Introspector.findMethod(cls, indexedReadMethodName, 1, args);
if (indexedReadMethod == null) {
// no "is" method, so look for a "get" method.
......@@ -240,7 +240,7 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor {
public synchronized Method getIndexedWriteMethod() {
Method indexedWriteMethod = getIndexedWriteMethod0();
if (indexedWriteMethod == null) {
Class cls = getClass0();
Class<?> cls = getClass0();
if (cls == null ||
(indexedWriteMethodName == null && indexedWriteMethodRef == null)) {
// the Indexed writeMethod was explicitly set to null.
......@@ -250,14 +250,14 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor {
// We need the indexed type to ensure that we get the correct method.
// Cannot use the getIndexedPropertyType method since that could
// result in an infinite loop.
Class type = getIndexedPropertyType0();
Class<?> type = getIndexedPropertyType0();
if (type == null) {
try {
type = findIndexedPropertyType(getIndexedReadMethod(), null);
setIndexedPropertyType(type);
} catch (IntrospectionException ex) {
// Set iprop type to be the classic type
Class propType = getPropertyType();
Class<?> propType = getPropertyType();
if (propType.isArray()) {
type = propType.getComponentType();
}
......@@ -268,7 +268,7 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor {
indexedWriteMethodName = Introspector.SET_PREFIX + getBaseName();
}
Class[] args = (type == null) ? null : new Class[] { int.class, type };
Class<?>[] args = (type == null) ? null : new Class<?>[] { int.class, type };
indexedWriteMethod = Introspector.findMethod(cls, indexedWriteMethodName, 2, args);
if (indexedWriteMethod != null) {
if (!indexedWriteMethod.getReturnType().equals(void.class)) {
......@@ -289,7 +289,7 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor {
throws IntrospectionException {
// If the indexed property type has not been set, then set it.
Class type = findIndexedPropertyType(getIndexedReadMethod(),
Class<?> type = findIndexedPropertyType(getIndexedReadMethod(),
writeMethod);
setIndexedPropertyType(type);
setIndexedWriteMethod0(writeMethod);
......@@ -319,7 +319,7 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor {
* or {@code null} if the type cannot be determined
*/
public synchronized Class<?> getIndexedPropertyType() {
Class type = getIndexedPropertyType0();
Class<?> type = getIndexedPropertyType0();
if (type == null) {
try {
type = findIndexedPropertyType(getIndexedReadMethod(),
......@@ -334,11 +334,11 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor {
// Private methods which set get/set the Reference objects
private void setIndexedPropertyType(Class type) {
private void setIndexedPropertyType(Class<?> type) {
this.indexedPropertyTypeRef = getWeakReference(type);
}
private Class getIndexedPropertyType0() {
private Class<?> getIndexedPropertyType0() {
return (this.indexedPropertyTypeRef != null)
? this.indexedPropertyTypeRef.get()
: null;
......@@ -356,10 +356,10 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor {
: null;
}
private Class findIndexedPropertyType(Method indexedReadMethod,
private Class<?> findIndexedPropertyType(Method indexedReadMethod,
Method indexedWriteMethod)
throws IntrospectionException {
Class indexedPropertyType = null;
Class<?> indexedPropertyType = null;
if (indexedReadMethod != null) {
Class params[] = getParameterTypes(getClass0(), indexedReadMethod);
......@@ -389,7 +389,7 @@ public class IndexedPropertyDescriptor extends PropertyDescriptor {
}
indexedPropertyType = params[1];
}
Class propertyType = getPropertyType();
Class<?> propertyType = getPropertyType();
if (propertyType != null && (!propertyType.isArray() ||
propertyType.getComponentType() != indexedPropertyType)) {
throw new IntrospectionException("type mismatch between indexed and non-indexed methods: "
......
......@@ -42,7 +42,7 @@ public class MethodDescriptor extends FeatureDescriptor {
private String[] paramNames;
private List params;
private List<WeakReference<Class<?>>> params;
private ParameterDescriptor parameterDescriptors[];
......@@ -81,10 +81,10 @@ public class MethodDescriptor extends FeatureDescriptor {
public synchronized Method getMethod() {
Method method = getMethod0();
if (method == null) {
Class cls = getClass0();
Class<?> cls = getClass0();
String name = getName();
if ((cls != null) && (name != null)) {
Class[] params = getParams();
Class<?>[] params = getParams();
if (params == null) {
for (int i = 0; i < 3; i++) {
// Find methods for up to 2 params. We are guessing here.
......@@ -121,15 +121,15 @@ public class MethodDescriptor extends FeatureDescriptor {
: null;
}
private synchronized void setParams(Class[] param) {
private synchronized void setParams(Class<?>[] param) {
if (param == null) {
return;
}
paramNames = new String[param.length];
params = new ArrayList(param.length);
params = new ArrayList<>(param.length);
for (int i = 0; i < param.length; i++) {
paramNames[i] = param[i].getName();
params.add(new WeakReference(param[i]));
params.add(new WeakReference<Class<?>>(param[i]));
}
}
......@@ -138,12 +138,12 @@ public class MethodDescriptor extends FeatureDescriptor {
return paramNames;
}
private synchronized Class[] getParams() {
Class[] clss = new Class[params.size()];
private synchronized Class<?>[] getParams() {
Class<?>[] clss = new Class<?>[params.size()];
for (int i = 0; i < params.size(); i++) {
Reference ref = (Reference)params.get(i);
Class cls = (Class)ref.get();
Reference<? extends Class<?>> ref = (Reference<? extends Class<?>>)params.get(i);
Class<?> cls = ref.get();
if (cls == null) {
return null;
} else {
......
......@@ -43,12 +43,12 @@ import static java.util.Locale.ENGLISH;
*/
class NameGenerator {
private Map valueToName;
private Map nameToCount;
private Map<Object, String> valueToName;
private Map<String, Integer> nameToCount;
public NameGenerator() {
valueToName = new IdentityHashMap();
nameToCount = new HashMap();
valueToName = new IdentityHashMap<>();
nameToCount = new HashMap<>();
}
/**
......@@ -63,6 +63,7 @@ class NameGenerator {
/**
* Returns the root name of the class.
*/
@SuppressWarnings("rawtypes")
public static String unqualifiedClassName(Class type) {
if (type.isArray()) {
return unqualifiedClassName(type.getComponentType())+"Array";
......@@ -97,15 +98,15 @@ class NameGenerator {
return unqualifiedClassName((Class)instance);
}
else {
String result = (String)valueToName.get(instance);
String result = valueToName.get(instance);
if (result != null) {
return result;
}
Class type = instance.getClass();
Class<?> type = instance.getClass();
String className = unqualifiedClassName(type);
Object size = nameToCount.get(className);
int instanceNumber = (size == null) ? 0 : ((Integer)size).intValue() + 1;
Integer size = nameToCount.get(className);
int instanceNumber = (size == null) ? 0 : (size).intValue() + 1;
nameToCount.put(className, new Integer(instanceNumber));
result = className + instanceNumber;
......
......@@ -207,7 +207,7 @@ public abstract class PersistenceDelegate {
Object oldInstance, Object newInstance,
Encoder out)
{
Class superType = type.getSuperclass();
Class<?> superType = type.getSuperclass();
PersistenceDelegate info = out.getPersistenceDelegate(superType);
info.initialize(superType, oldInstance, newInstance, out);
}
......
......@@ -431,7 +431,7 @@ public class PropertyChangeSupport implements Serializable {
listeners = entry.getValue();
} else {
if (children == null) {
children = new Hashtable<String, PropertyChangeSupport>();
children = new Hashtable<>();
}
PropertyChangeSupport pcs = new PropertyChangeSupport(this.source);
pcs.map.set(null, entry.getValue());
......@@ -460,6 +460,7 @@ public class PropertyChangeSupport implements Serializable {
ObjectInputStream.GetField fields = s.readFields();
@SuppressWarnings("unchecked")
Hashtable<String, PropertyChangeSupport> children = (Hashtable<String, PropertyChangeSupport>) fields.get("children", null);
this.source = fields.get("source", null);
fields.get("propertyChangeSupportSerializedDataVersion", 2);
......
......@@ -35,10 +35,10 @@ import java.lang.reflect.Constructor;
*/
public class PropertyDescriptor extends FeatureDescriptor {
private Reference<Class> propertyTypeRef;
private Reference<? extends Class<?>> propertyTypeRef;
private Reference<Method> readMethodRef;
private Reference<Method> writeMethodRef;
private Reference<Class> propertyEditorClassRef;
private Reference<? extends Class<?>> propertyEditorClassRef;
private boolean bound;
private boolean constrained;
......@@ -174,7 +174,7 @@ public class PropertyDescriptor extends FeatureDescriptor {
* or {@code null} if the type cannot be determined
*/
public synchronized Class<?> getPropertyType() {
Class type = getPropertyType0();
Class<?> type = getPropertyType0();
if (type == null) {
try {
type = findPropertyType(getReadMethod(), getWriteMethod());
......@@ -186,11 +186,11 @@ public class PropertyDescriptor extends FeatureDescriptor {
return type;
}
private void setPropertyType(Class type) {
private void setPropertyType(Class<?> type) {
this.propertyTypeRef = getWeakReference(type);
}
private Class getPropertyType0() {
private Class<?> getPropertyType0() {
return (this.propertyTypeRef != null)
? this.propertyTypeRef.get()
: null;
......@@ -205,13 +205,13 @@ public class PropertyDescriptor extends FeatureDescriptor {
public synchronized Method getReadMethod() {
Method readMethod = getReadMethod0();
if (readMethod == null) {
Class cls = getClass0();
Class<?> cls = getClass0();
if (cls == null || (readMethodName == null && readMethodRef == null)) {
// The read method was explicitly set to null.
return null;
}
if (readMethodName == null) {
Class type = getPropertyType0();
Class<?> type = getPropertyType0();
if (type == boolean.class || type == null) {
readMethodName = Introspector.IS_PREFIX + getBaseName();
} else {
......@@ -268,14 +268,14 @@ public class PropertyDescriptor extends FeatureDescriptor {
public synchronized Method getWriteMethod() {
Method writeMethod = getWriteMethod0();
if (writeMethod == null) {
Class cls = getClass0();
Class<?> cls = getClass0();
if (cls == null || (writeMethodName == null && writeMethodRef == null)) {
// The write method was explicitly set to null.
return null;
}
// We need the type to fetch the correct method.
Class type = getPropertyType0();
Class<?> type = getPropertyType0();
if (type == null) {
try {
// Can't use getPropertyType since it will lead to recursive loop.
......@@ -292,7 +292,7 @@ public class PropertyDescriptor extends FeatureDescriptor {
writeMethodName = Introspector.SET_PREFIX + getBaseName();
}
Class[] args = (type == null) ? null : new Class[] { type };
Class<?>[] args = (type == null) ? null : new Class<?>[] { type };
writeMethod = Introspector.findMethod(cls, writeMethodName, 1, args);
if (writeMethod != null) {
if (!writeMethod.getReturnType().equals(void.class)) {
......@@ -344,7 +344,7 @@ public class PropertyDescriptor extends FeatureDescriptor {
/**
* Overridden to ensure that a super class doesn't take precedent
*/
void setClass0(Class clz) {
void setClass0(Class<?> clz) {
if (getClass0() != null && clz.isAssignableFrom(getClass0())) {
// dont replace a subclass with a superclass
return;
......@@ -402,7 +402,7 @@ public class PropertyDescriptor extends FeatureDescriptor {
* @param propertyEditorClass The Class for the desired PropertyEditor.
*/
public void setPropertyEditorClass(Class<?> propertyEditorClass) {
this.propertyEditorClassRef = getWeakReference((Class)propertyEditorClass);
this.propertyEditorClassRef = getWeakReference(propertyEditorClass);
}
/**
......@@ -437,12 +437,12 @@ public class PropertyDescriptor extends FeatureDescriptor {
public PropertyEditor createPropertyEditor(Object bean) {
Object editor = null;
Class cls = getPropertyEditorClass();
Class<?> cls = getPropertyEditorClass();
if (cls != null) {
Constructor ctor = null;
Constructor<?> ctor = null;
if (bean != null) {
try {
ctor = cls.getConstructor(new Class[] { Object.class });
ctor = cls.getConstructor(new Class<?>[] { Object.class });
} catch (Exception ex) {
// Fall through
}
......@@ -637,12 +637,12 @@ public class PropertyDescriptor extends FeatureDescriptor {
* read and write methods are null.
* @throws IntrospectionException if the read or write method is invalid
*/
private Class findPropertyType(Method readMethod, Method writeMethod)
private Class<?> findPropertyType(Method readMethod, Method writeMethod)
throws IntrospectionException {
Class propertyType = null;
Class<?> propertyType = null;
try {
if (readMethod != null) {
Class[] params = getParameterTypes(getClass0(), readMethod);
Class<?>[] params = getParameterTypes(getClass0(), readMethod);
if (params.length != 0) {
throw new IntrospectionException("bad read method arg count: "
+ readMethod);
......@@ -654,7 +654,7 @@ public class PropertyDescriptor extends FeatureDescriptor {
}
}
if (writeMethod != null) {
Class params[] = getParameterTypes(getClass0(), writeMethod);
Class<?>[] params = getParameterTypes(getClass0(), writeMethod);
if (params.length != 1) {
throw new IntrospectionException("bad write method arg count: "
+ writeMethod);
......
......@@ -251,7 +251,7 @@ public class PropertyEditorSupport implements PropertyEditor {
public synchronized void addPropertyChangeListener(
PropertyChangeListener listener) {
if (listeners == null) {
listeners = new java.util.Vector();
listeners = new java.util.Vector<>();
}
listeners.addElement(listener);
}
......@@ -278,25 +278,30 @@ public class PropertyEditorSupport implements PropertyEditor {
* Report that we have been modified to any interested listeners.
*/
public void firePropertyChange() {
java.util.Vector targets;
java.util.Vector<PropertyChangeListener> targets;
synchronized (this) {
if (listeners == null) {
return;
}
targets = (java.util.Vector) listeners.clone();
targets = unsafeClone(listeners);
}
// Tell our listeners that "everything" has changed.
PropertyChangeEvent evt = new PropertyChangeEvent(source, null, null, null);
for (int i = 0; i < targets.size(); i++) {
PropertyChangeListener target = (PropertyChangeListener)targets.elementAt(i);
PropertyChangeListener target = targets.elementAt(i);
target.propertyChange(evt);
}
}
@SuppressWarnings("unchecked")
private <T> java.util.Vector<T> unsafeClone(java.util.Vector<T> v) {
return (java.util.Vector<T>)v.clone();
}
//----------------------------------------------------------------------
private Object value;
private Object source;
private java.util.Vector listeners;
private java.util.Vector<PropertyChangeListener> listeners;
}
......@@ -32,10 +32,12 @@ import java.lang.reflect.Field;
*/
class ReflectionUtils {
@SuppressWarnings("rawtypes")
public static boolean isPrimitive(Class type) {
return primitiveTypeFor(type) != null;
}
@SuppressWarnings("rawtypes")
public static Class primitiveTypeFor(Class wrapper) {
if (wrapper == Boolean.class) return Boolean.TYPE;
if (wrapper == Byte.class) return Byte.TYPE;
......@@ -58,6 +60,7 @@ class ReflectionUtils {
* @param el an exception listener to handle exceptions; or null
* @return value of the field; null if not found or an error is encountered
*/
@SuppressWarnings("rawtypes")
public static Object getPrivateField(Object instance, Class cls,
String name, ExceptionListener el) {
try {
......
......@@ -116,10 +116,10 @@ public class SimpleBeanInfo implements BeanInfo {
*/
public java.awt.Image loadImage(final String resourceName) {
try {
final Class c = getClass();
final Class<?> c = getClass();
java.awt.image.ImageProducer ip = (java.awt.image.ImageProducer)
java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() {
new java.security.PrivilegedAction<Object>() {
public Object run() {
java.net.URL url;
if ((url = c.getResource(resourceName)) == null) {
......
......@@ -212,7 +212,7 @@ public class Statement {
if (target == Class.class && methodName.equals("forName")) {
return ClassFinder.resolveClass((String)arguments[0], this.loader);
}
Class[] argClasses = new Class[arguments.length];
Class<?>[] argClasses = new Class<?>[arguments.length];
for(int i = 0; i < arguments.length; i++) {
argClasses[i] = (arguments[i] == null) ? null : arguments[i].getClass();
}
......
......@@ -420,7 +420,7 @@ public class VetoableChangeSupport implements Serializable {
listeners = entry.getValue();
} else {
if (children == null) {
children = new Hashtable<String, VetoableChangeSupport>();
children = new Hashtable<>();
}
VetoableChangeSupport vcs = new VetoableChangeSupport(this.source);
vcs.map.set(null, entry.getValue());
......@@ -449,7 +449,8 @@ public class VetoableChangeSupport implements Serializable {
ObjectInputStream.GetField fields = s.readFields();
Hashtable<String, VetoableChangeSupport> children = (Hashtable<String, VetoableChangeSupport>) fields.get("children", null);
@SuppressWarnings("unchecked")
Hashtable<String, VetoableChangeSupport> children = (Hashtable<String, VetoableChangeSupport>)fields.get("children", null);
this.source = fields.get("source", null);
fields.get("vetoableChangeSupportSerializedDataVersion", 2);
......
......@@ -287,8 +287,8 @@ public class XMLEncoder extends Encoder implements AutoCloseable {
this.declaration = declaration;
this.indentation = indentation;
this.out = new OutputStreamWriter(out, cs.newEncoder());
valueToExpression = new IdentityHashMap<Object, ValueData>();
targetToStatementList = new IdentityHashMap<Object, List<Statement>>();
valueToExpression = new IdentityHashMap<>();
targetToStatementList = new IdentityHashMap<>();
nameGenerator = new NameGenerator();
}
......@@ -334,7 +334,7 @@ public class XMLEncoder extends Encoder implements AutoCloseable {
private List<Statement> statementList(Object target) {
List<Statement> list = targetToStatementList.get(target);
if (list == null) {
list = new ArrayList<Statement>();
list = new ArrayList<>();
targetToStatementList.put(target, list);
}
return list;
......@@ -604,7 +604,7 @@ public class XMLEncoder extends Encoder implements AutoCloseable {
return;
}
Class primitiveType = ReflectionUtils.primitiveTypeFor(value.getClass());
Class<?> primitiveType = ReflectionUtils.primitiveTypeFor(value.getClass());
if (primitiveType != null && target == value.getClass() &&
methodName.equals("new")) {
String primitiveTypeName = primitiveType.getName();
......
......@@ -53,6 +53,7 @@ import java.util.Locale;
* @see java.util.Collection
*/
@SuppressWarnings("rawtypes")
public interface BeanContext extends BeanContextChild, Collection, DesignMode, Visibility {
/**
......
......@@ -65,6 +65,7 @@ public class BeanContextMembershipEvent extends BeanContextEvent {
* @throws NullPointerException if <CODE>changes</CODE> is <CODE>null</CODE>
*/
@SuppressWarnings("rawtypes")
public BeanContextMembershipEvent(BeanContext bc, Collection changes) {
super(bc);
......@@ -117,6 +118,7 @@ public class BeanContextMembershipEvent extends BeanContextEvent {
* Gets the array of children affected by this event.
* @return the array of children effected
*/
@SuppressWarnings("rawtypes")
public Iterator iterator() { return children.iterator(); }
/*
......@@ -127,5 +129,6 @@ public class BeanContextMembershipEvent extends BeanContextEvent {
* The list of children affected by this
* event notification.
*/
@SuppressWarnings("rawtypes")
protected Collection children;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册