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