8042860: Fix raw and unchecked warnings in java.beans
Reviewed-by: malenkov, alanb, mduigou
--- a/jdk/src/share/classes/java/beans/EventHandler.java Tue Jun 03 11:18:03 2014 -0400
+++ b/jdk/src/share/classes/java/beans/EventHandler.java Tue Jun 03 09:22:59 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -446,7 +446,7 @@
}
if (listenerMethodName == null || listenerMethodName.equals(methodName)) {
- Class[] argTypes = null;
+ Class<?>[] argTypes = null;
Object[] newArgs = null;
if (eventPropertyName == null) { // Nullary method.
--- a/jdk/src/share/classes/java/beans/EventSetDescriptor.java Tue Jun 03 11:18:03 2014 -0400
+++ b/jdk/src/share/classes/java/beans/EventSetDescriptor.java Tue Jun 03 09:22:59 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -81,7 +81,7 @@
String eventName = NameGenerator.capitalize(eventSetName) + "Event";
Method[] listenerMethods = getListenerMethods();
if (listenerMethods.length > 0) {
- Class[] args = getParameterTypes(getClass0(), listenerMethods[0]);
+ Class<?>[] args = getParameterTypes(getClass0(), listenerMethods[0]);
// Check for EventSet compliance. Special case for vetoableChange. See 4529996
if (!"vetoableChange".equals(eventSetName) && !args[0].getName().endsWith(eventName)) {
throw new IntrospectionException("Method \"" + listenerMethodName +
--- a/jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.java Tue Jun 03 11:18:03 2014 -0400
+++ b/jdk/src/share/classes/java/beans/IndexedPropertyDescriptor.java Tue Jun 03 09:22:59 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -353,7 +353,7 @@
Class<?> indexedPropertyType = null;
if (indexedReadMethod != null) {
- Class params[] = getParameterTypes(getClass0(), indexedReadMethod);
+ Class<?>[] params = getParameterTypes(getClass0(), indexedReadMethod);
if (params.length != 1) {
throw new IntrospectionException("bad indexed read method arg count");
}
@@ -366,7 +366,7 @@
}
}
if (indexedWriteMethod != null) {
- Class params[] = getParameterTypes(getClass0(), indexedWriteMethod);
+ Class<?>[] params = getParameterTypes(getClass0(), indexedWriteMethod);
if (params.length != 2) {
throw new IntrospectionException("bad indexed write method arg count");
}
--- a/jdk/src/share/classes/java/beans/Introspector.java Tue Jun 03 11:18:03 2014 -0400
+++ b/jdk/src/share/classes/java/beans/Introspector.java Tue Jun 03 09:22:59 2014 -0700
@@ -1384,7 +1384,7 @@
* parameter list on a given class.
*/
private static Method internalFindMethod(Class<?> start, String methodName,
- int argCount, Class args[]) {
+ int argCount, Class<?> args[]) {
// For overriden methods we need to find the most derived version.
// So we start with the given class and walk up the superclass chain.
@@ -1426,7 +1426,7 @@
// Now check any inherited interfaces. This is necessary both when
// the argument class is itself an interface, and when the argument
// class is an abstract class.
- Class ifcs[] = start.getInterfaces();
+ Class<?>[] ifcs = start.getInterfaces();
for (int i = 0 ; i < ifcs.length; i++) {
// Note: The original implementation had both methods calling
// the 3 arg method. This is preserved but perhaps it should
@@ -1459,7 +1459,7 @@
* @return the method or null if not found
*/
static Method findMethod(Class<?> cls, String methodName, int argCount,
- Class args[]) {
+ Class<?>[] args) {
if (methodName == null) {
return null;
}
@@ -1502,7 +1502,7 @@
* Return true iff the given method throws the given exception.
*/
private boolean throwsException(Method method, Class<?> exception) {
- Class exs[] = method.getExceptionTypes();
+ Class<?>[] exs = method.getExceptionTypes();
for (int i = 0; i < exs.length; i++) {
if (exs[i] == exception) {
return true;
--- a/jdk/src/share/classes/java/beans/MetaData.java Tue Jun 03 11:18:03 2014 -0400
+++ b/jdk/src/share/classes/java/beans/MetaData.java Tue Jun 03 09:22:59 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -1401,7 +1401,7 @@
}
private static boolean isValid(Constructor<?> constructor, String[] names) {
- Class[] parameters = constructor.getParameterTypes();
+ Class<?>[] parameters = constructor.getParameterTypes();
if (names.length != parameters.length) {
return false;
}
--- a/jdk/src/share/classes/java/beans/PropertyDescriptor.java Tue Jun 03 11:18:03 2014 -0400
+++ b/jdk/src/share/classes/java/beans/PropertyDescriptor.java Tue Jun 03 09:22:59 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -112,7 +112,7 @@
// If this class or one of its base classes allow PropertyChangeListener,
// then we assume that any properties we discover are "bound".
// See Introspector.getTargetPropertyInfo() method.
- Class[] args = { PropertyChangeListener.class };
+ Class<?>[] args = { PropertyChangeListener.class };
this.bound = null != Introspector.findMethod(beanClass, "addPropertyChangeListener", args.length, args);
}
--- a/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceAvailableEvent.java Tue Jun 03 11:18:03 2014 -0400
+++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceAvailableEvent.java Tue Jun 03 09:22:59 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -47,7 +47,7 @@
* @param bcs The context in which the service has become available
* @param sc A <code>Class</code> reference to the newly available service
*/
- public BeanContextServiceAvailableEvent(BeanContextServices bcs, Class sc) {
+ public BeanContextServiceAvailableEvent(BeanContextServices bcs, Class<?> sc) {
super((BeanContext)bcs);
serviceClass = sc;
@@ -65,13 +65,13 @@
* Gets the service class that is the subject of this notification.
* @return A <code>Class</code> reference to the newly available service
*/
- public Class getServiceClass() { return serviceClass; }
+ public Class<?> getServiceClass() { return serviceClass; }
/**
* Gets the list of service dependent selectors.
* @return the current selectors available from the service
*/
- public Iterator getCurrentServiceSelectors() {
+ public Iterator<?> getCurrentServiceSelectors() {
return ((BeanContextServices)getSource()).getCurrentServiceSelectors(serviceClass);
}
@@ -82,5 +82,5 @@
/**
* A <code>Class</code> reference to the newly available service
*/
- protected Class serviceClass;
+ protected Class<?> serviceClass;
}
--- a/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceProvider.java Tue Jun 03 11:18:03 2014 -0400
+++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceProvider.java Tue Jun 03 09:22:59 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -70,7 +70,7 @@
*
* @return a reference to the requested service
*/
- Object getService(BeanContextServices bcs, Object requestor, Class serviceClass, Object serviceSelector);
+ Object getService(BeanContextServices bcs, Object requestor, Class<?> serviceClass, Object serviceSelector);
/**
* Invoked by <code>BeanContextServices</code>,
@@ -100,5 +100,5 @@
* @param serviceClass the specified service
* @return the current service selectors for the specified serviceClass
*/
- Iterator getCurrentServiceSelectors(BeanContextServices bcs, Class serviceClass);
+ Iterator<?> getCurrentServiceSelectors(BeanContextServices bcs, Class<?> serviceClass);
}
--- a/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceRevokedEvent.java Tue Jun 03 11:18:03 2014 -0400
+++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextServiceRevokedEvent.java Tue Jun 03 09:22:59 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -46,7 +46,7 @@
* @param sc the service that is being revoked
* @param invalidate <code>true</code> for immediate revocation
*/
- public BeanContextServiceRevokedEvent(BeanContextServices bcs, Class sc, boolean invalidate) {
+ public BeanContextServiceRevokedEvent(BeanContextServices bcs, Class<?> sc, boolean invalidate) {
super((BeanContext)bcs);
serviceClass = sc;
@@ -67,7 +67,7 @@
* @return A <code>Class</code> reference to the
* service that is being revoked
*/
- public Class getServiceClass() { return serviceClass; }
+ public Class<?> getServiceClass() { return serviceClass; }
/**
* Checks this event to determine whether or not
@@ -76,7 +76,7 @@
* @return <code>true</code> if the service being revoked is of the
* same class as the specified service
*/
- public boolean isServiceClass(Class service) {
+ public boolean isServiceClass(Class<?> service) {
return serviceClass.equals(service);
}
@@ -94,6 +94,6 @@
/**
* A <code>Class</code> reference to the service that is being revoked.
*/
- protected Class serviceClass;
+ protected Class<?> serviceClass;
private boolean invalidateRefs;
}
--- a/jdk/src/share/classes/java/beans/beancontext/BeanContextServices.java Tue Jun 03 11:18:03 2014 -0400
+++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextServices.java Tue Jun 03 09:22:59 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -62,7 +62,7 @@
* associated with the service
* @return true if the service was successful added, false otherwise
*/
- boolean addService(Class serviceClass, BeanContextServiceProvider serviceProvider);
+ boolean addService(Class<?> serviceClass, BeanContextServiceProvider serviceProvider);
/**
* BeanContextServiceProviders wishing to remove
@@ -83,7 +83,7 @@
* terminate service to all currently outstanding references
* to the specified service.
*/
- void revokeService(Class serviceClass, BeanContextServiceProvider serviceProvider, boolean revokeCurrentServicesNow);
+ void revokeService(Class<?> serviceClass, BeanContextServiceProvider serviceProvider, boolean revokeCurrentServicesNow);
/**
* Reports whether or not a given service is
@@ -91,7 +91,7 @@
* @param serviceClass the service in question
* @return true if the service is available
*/
- boolean hasService(Class serviceClass);
+ boolean hasService(Class<?> serviceClass);
/**
* A <code>BeanContextChild</code>, or any arbitrary object
@@ -113,7 +113,7 @@
* @return a reference to this context's named
* Service as requested or <code>null</code>
*/
- Object getService(BeanContextChild child, Object requestor, Class serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException;
+ Object getService(BeanContextChild child, Object requestor, Class<?> serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException;
/**
* Releases a <code>BeanContextChild</code>'s
@@ -131,7 +131,7 @@
* @return an <code>Iterator</code> consisting of the
* currently available services
*/
- Iterator getCurrentServiceClasses();
+ Iterator<?> getCurrentServiceClasses();
/**
* Gets the list of service dependent service parameters
@@ -142,7 +142,7 @@
* @return the currently available service selectors
* for the named serviceClass
*/
- Iterator getCurrentServiceSelectors(Class serviceClass);
+ Iterator<?> getCurrentServiceSelectors(Class<?> serviceClass);
/**
* Adds a <code>BeanContextServicesListener</code> to this BeanContext
--- a/jdk/src/share/classes/java/beans/beancontext/BeanContextServicesSupport.java Tue Jun 03 11:18:03 2014 -0400
+++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextServicesSupport.java Tue Jun 03 09:22:59 2014 -0700
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -129,9 +129,8 @@
public void initialize() {
super.initialize();
-
- services = new HashMap(serializable + 1);
- bcsListeners = new ArrayList(1);
+ services = new HashMap<>(serializable + 1);
+ bcsListeners = new ArrayList<>(1);
}
/**
@@ -169,7 +168,7 @@
// create an instance of a service ref
- BCSSCServiceClassRef(Class sc, BeanContextServiceProvider bcsp, boolean delegated) {
+ BCSSCServiceClassRef(Class<?> sc, BeanContextServiceProvider bcsp, boolean delegated) {
super();
serviceClass = sc;
@@ -183,7 +182,7 @@
// add a requestor and assoc listener
void addRequestor(Object requestor, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException {
- BeanContextServiceRevokedListener cbcsrl = (BeanContextServiceRevokedListener)requestors.get(requestor);
+ BeanContextServiceRevokedListener cbcsrl = requestors.get(requestor);
if (cbcsrl != null && !cbcsrl.equals(bcsrl))
throw new TooManyListenersException();
@@ -200,7 +199,7 @@
// check a requestors listener
void verifyRequestor(Object requestor, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException {
- BeanContextServiceRevokedListener cbcsrl = (BeanContextServiceRevokedListener)requestors.get(requestor);
+ BeanContextServiceRevokedListener cbcsrl = requestors.get(requestor);
if (cbcsrl != null && !cbcsrl.equals(bcsrl))
throw new TooManyListenersException();
@@ -230,15 +229,18 @@
}
- Iterator cloneOfEntries() {
- return ((HashMap)requestors.clone()).entrySet().iterator();
+ @SuppressWarnings("unchecked") // Cast from clone
+ Iterator<Map.Entry<Object, BeanContextServiceRevokedListener>> cloneOfEntries() {
+ return ((HashMap<Object, BeanContextServiceRevokedListener>)requestors.clone()).entrySet().iterator();
}
- Iterator entries() { return requestors.entrySet().iterator(); }
+ Iterator<Map.Entry<Object, BeanContextServiceRevokedListener>> entries() {
+ return requestors.entrySet().iterator();
+ }
boolean isEmpty() { return requestors.isEmpty(); }
- Class getServiceClass() { return serviceClass; }
+ Class<?> getServiceClass() { return serviceClass; }
BeanContextServiceProvider getServiceProvider() {
return serviceProvider;
@@ -281,7 +283,7 @@
* fields
*/
- Class serviceClass;
+ Class<?> serviceClass;
BeanContextServiceProvider serviceProvider;
int serviceRefs;
@@ -289,7 +291,7 @@
BeanContextServiceProvider delegateProvider; // proxy
int delegateRefs;
- HashMap requestors = new HashMap(1);
+ HashMap<Object, BeanContextServiceRevokedListener> requestors = new HashMap<>(1);
}
/*
@@ -322,16 +324,16 @@
// note usage of service per requestor, per service
- synchronized void usingService(Object requestor, Object service, Class serviceClass, BeanContextServiceProvider bcsp, boolean isDelegated, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException, UnsupportedOperationException {
+ synchronized void usingService(Object requestor, Object service, Class<?> serviceClass, BeanContextServiceProvider bcsp, boolean isDelegated, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException, UnsupportedOperationException {
// first, process mapping from serviceClass to requestor(s)
BCSSCServiceClassRef serviceClassRef = null;
if (serviceClasses == null)
- serviceClasses = new HashMap(1);
+ serviceClasses = new HashMap<>(1);
else
- serviceClassRef = (BCSSCServiceClassRef)serviceClasses.get(serviceClass);
+ serviceClassRef = serviceClasses.get(serviceClass);
if (serviceClassRef == null) { // new service being used ...
serviceClassRef = new BCSSCServiceClassRef(serviceClass, bcsp, isDelegated);
@@ -348,20 +350,20 @@
// now handle mapping from requestor to service(s)
BCSSCServiceRef serviceRef = null;
- Map services = null;
+ Map<Object , BCSSCServiceRef> services = null;
if (serviceRequestors == null) {
- serviceRequestors = new HashMap(1);
+ serviceRequestors = new HashMap<>(1);
} else {
- services = (Map)serviceRequestors.get(requestor);
+ services = serviceRequestors.get(requestor);
}
if (services == null) {
- services = new HashMap(1);
+ services = new HashMap<>(1);
serviceRequestors.put(requestor, services);
} else
- serviceRef = (BCSSCServiceRef)services.get(service);
+ serviceRef = services.get(service);
if (serviceRef == null) {
serviceRef = new BCSSCServiceRef(serviceClassRef, isDelegated);
@@ -377,11 +379,11 @@
synchronized void releaseService(Object requestor, Object service) {
if (serviceRequestors == null) return;
- Map services = (Map)serviceRequestors.get(requestor);
+ Map<Object, BCSSCServiceRef> services = serviceRequestors.get(requestor);
if (services == null) return; // oops its not there anymore!
- BCSSCServiceRef serviceRef = (BCSSCServiceRef)services.get(service);
+ BCSSCServiceRef serviceRef = services.get(service);
if (serviceRef == null) return; // oops its not there anymore!
@@ -418,33 +420,33 @@
// revoke a service
- synchronized void revokeService(Class serviceClass, boolean isDelegated, boolean revokeNow) {
+ synchronized void revokeService(Class<?> serviceClass, boolean isDelegated, boolean revokeNow) {
if (serviceClasses == null) return;
- BCSSCServiceClassRef serviceClassRef = (BCSSCServiceClassRef)serviceClasses.get(serviceClass);
+ BCSSCServiceClassRef serviceClassRef = serviceClasses.get(serviceClass);
if (serviceClassRef == null) return;
- Iterator i = serviceClassRef.cloneOfEntries();
+ Iterator<Map.Entry<Object, BeanContextServiceRevokedListener>> i = serviceClassRef.cloneOfEntries();
BeanContextServiceRevokedEvent bcsre = new BeanContextServiceRevokedEvent(BeanContextServicesSupport.this.getBeanContextServicesPeer(), serviceClass, revokeNow);
boolean noMoreRefs = false;
while (i.hasNext() && serviceRequestors != null) {
- Map.Entry entry = (Map.Entry)i.next();
- BeanContextServiceRevokedListener listener = (BeanContextServiceRevokedListener)entry.getValue();
+ Map.Entry<Object,BeanContextServiceRevokedListener> entry = i.next();
+ BeanContextServiceRevokedListener listener = entry.getValue();
if (revokeNow) {
Object requestor = entry.getKey();
- Map services = (Map)serviceRequestors.get(requestor);
+ Map<Object, BCSSCServiceRef> services = serviceRequestors.get(requestor);
if (services != null) {
- Iterator i1 = services.entrySet().iterator();
+ Iterator<Map.Entry<Object, BCSSCServiceRef>> i1 = services.entrySet().iterator();
while (i1.hasNext()) {
- Map.Entry tmp = (Map.Entry)i1.next();
+ Map.Entry<Object, BCSSCServiceRef> tmp = i1.next();
- BCSSCServiceRef serviceRef = (BCSSCServiceRef)tmp.getValue();
+ BCSSCServiceRef serviceRef = tmp.getValue();
if (serviceRef.getServiceClassRef().equals(serviceClassRef) && isDelegated == serviceRef.isDelegated()) {
i1.remove();
}
@@ -479,19 +481,19 @@
if (serviceRequestors == null) return;
- Iterator requestors = serviceRequestors.entrySet().iterator();
+ Iterator<Map.Entry<Object, Map<Object, BCSSCServiceRef>>> requestors = serviceRequestors.entrySet().iterator();
while(requestors.hasNext()) {
- Map.Entry tmp = (Map.Entry)requestors.next();
+ Map.Entry<Object, Map<Object, BCSSCServiceRef>> tmp = requestors.next();
Object requestor = tmp.getKey();
- Iterator services = ((Map)tmp.getValue()).entrySet().iterator();
+ Iterator<Map.Entry<Object, BCSSCServiceRef>> services = tmp.getValue().entrySet().iterator();
requestors.remove();
while (services.hasNext()) {
- Map.Entry entry = (Map.Entry)services.next();
+ Map.Entry<Object, BCSSCServiceRef> entry = services.next();
Object service = entry.getKey();
- BCSSCServiceRef sref = (BCSSCServiceRef)entry.getValue();
+ BCSSCServiceRef sref = entry.getValue();
BCSSCServiceClassRef scref = sref.getServiceClassRef();
@@ -513,32 +515,32 @@
void revokeAllDelegatedServicesNow() {
if (serviceClasses == null) return;
- Iterator serviceClassRefs =
- new HashSet(serviceClasses.values()).iterator();
+ Iterator<BCSSCServiceClassRef> serviceClassRefs =
+ new HashSet<>(serviceClasses.values()).iterator();
while (serviceClassRefs.hasNext()) {
- BCSSCServiceClassRef serviceClassRef = (BCSSCServiceClassRef)serviceClassRefs.next();
+ BCSSCServiceClassRef serviceClassRef = serviceClassRefs.next();
if (!serviceClassRef.isDelegated()) continue;
- Iterator i = serviceClassRef.cloneOfEntries();
+ Iterator<Map.Entry<Object, BeanContextServiceRevokedListener>> i = serviceClassRef.cloneOfEntries();
BeanContextServiceRevokedEvent bcsre = new BeanContextServiceRevokedEvent(BeanContextServicesSupport.this.getBeanContextServicesPeer(), serviceClassRef.getServiceClass(), true);
boolean noMoreRefs = false;
while (i.hasNext()) {
- Map.Entry entry = (Map.Entry)i.next();
- BeanContextServiceRevokedListener listener = (BeanContextServiceRevokedListener)entry.getValue();
+ Map.Entry<Object, BeanContextServiceRevokedListener> entry = i.next();
+ BeanContextServiceRevokedListener listener = entry.getValue();
Object requestor = entry.getKey();
- Map services = (Map)serviceRequestors.get(requestor);
+ Map<Object, BCSSCServiceRef> services = serviceRequestors.get(requestor);
if (services != null) {
- Iterator i1 = services.entrySet().iterator();
+ Iterator<Map.Entry<Object, BCSSCServiceRef>> i1 = services.entrySet().iterator();
while (i1.hasNext()) {
- Map.Entry tmp = (Map.Entry)i1.next();
+ Map.Entry<Object, BCSSCServiceRef> tmp = i1.next();
- BCSSCServiceRef serviceRef = (BCSSCServiceRef)tmp.getValue();
+ BCSSCServiceRef serviceRef = tmp.getValue();
if (serviceRef.getServiceClassRef().equals(serviceClassRef) && serviceRef.isDelegated()) {
i1.remove();
}
@@ -568,8 +570,8 @@
* fields
*/
- private transient HashMap serviceClasses;
- private transient HashMap serviceRequestors;
+ private transient HashMap<Class<?>, BCSSCServiceClassRef> serviceClasses;
+ private transient HashMap<Object, Map<Object, BeanContextServicesSupport.BCSSChild.BCSSCServiceRef>> serviceRequestors;
}
/**
@@ -597,7 +599,7 @@
protected static class BCSSServiceProvider implements Serializable {
private static final long serialVersionUID = 861278251667444782L;
- BCSSServiceProvider(Class sc, BeanContextServiceProvider bcsp) {
+ BCSSServiceProvider(Class<?> sc, BeanContextServiceProvider bcsp) {
super();
serviceProvider = bcsp;
@@ -627,7 +629,7 @@
* @return a service provider without overriding addService()
*/
- protected BCSSServiceProvider createBCSSServiceProvider(Class sc, BeanContextServiceProvider bcsp) {
+ protected BCSSServiceProvider createBCSSServiceProvider(Class<?> sc, BeanContextServiceProvider bcsp) {
return new BCSSServiceProvider(sc, bcsp);
}
@@ -671,7 +673,7 @@
* @param bcsp the service provider
*/
- public boolean addService(Class serviceClass, BeanContextServiceProvider bcsp) {
+ public boolean addService(Class<?> serviceClass, BeanContextServiceProvider bcsp) {
return addService(serviceClass, bcsp, true);
}
@@ -683,7 +685,7 @@
* @return true if the service was successfully added
*/
- protected boolean addService(Class serviceClass, BeanContextServiceProvider bcsp, boolean fireEvent) {
+ protected boolean addService(Class<?> serviceClass, BeanContextServiceProvider bcsp, boolean fireEvent) {
if (serviceClass == null) throw new NullPointerException("serviceClass");
if (bcsp == null) throw new NullPointerException("bcsp");
@@ -704,7 +706,7 @@
fireServiceAdded(bcssae);
synchronized(children) {
- Iterator i = children.keySet().iterator();
+ Iterator<Object> i = children.keySet().iterator();
while (i.hasNext()) {
Object c = i.next();
@@ -727,7 +729,7 @@
* @param revokeCurrentServicesNow whether or not to revoke the service
*/
- public void revokeService(Class serviceClass, BeanContextServiceProvider bcsp, boolean revokeCurrentServicesNow) {
+ public void revokeService(Class<?> serviceClass, BeanContextServiceProvider bcsp, boolean revokeCurrentServicesNow) {
if (serviceClass == null) throw new NullPointerException("serviceClass");
if (bcsp == null) throw new NullPointerException("bcsp");
@@ -735,7 +737,7 @@
synchronized(BeanContext.globalHierarchyLock) {
if (!services.containsKey(serviceClass)) return;
- BCSSServiceProvider bcsssp = (BCSSServiceProvider)services.get(serviceClass);
+ BCSSServiceProvider bcsssp = services.get(serviceClass);
if (!bcsssp.getServiceProvider().equals(bcsp))
throw new IllegalArgumentException("service provider mismatch");
@@ -744,7 +746,7 @@
if (bcsp instanceof Serializable) serializable--;
- Iterator i = bcsChildren(); // get the BCSChild values.
+ Iterator<BeanContextSupport.BCSChild> i = bcsChildren(); // get the BCSChild values.
while (i.hasNext()) {
((BCSSChild)i.next()).revokeService(serviceClass, false, revokeCurrentServicesNow);
@@ -758,7 +760,7 @@
* has a service, which may be delegated
*/
- public synchronized boolean hasService(Class serviceClass) {
+ public synchronized boolean hasService(Class<?> serviceClass) {
if (serviceClass == null) throw new NullPointerException("serviceClass");
synchronized(BeanContext.globalHierarchyLock) {
@@ -791,7 +793,7 @@
nestingCtxt = bcs;
}
- public Object getService(BeanContextServices bcs, Object requestor, Class serviceClass, Object serviceSelector) {
+ public Object getService(BeanContextServices bcs, Object requestor, Class<?> serviceClass, Object serviceSelector) {
Object service = null;
try {
@@ -807,12 +809,12 @@
nestingCtxt.releaseService(bcs, requestor, service);
}
- public Iterator getCurrentServiceSelectors(BeanContextServices bcs, Class serviceClass) {
+ public Iterator<?> getCurrentServiceSelectors(BeanContextServices bcs, Class<?> serviceClass) {
return nestingCtxt.getCurrentServiceSelectors(serviceClass);
}
public void serviceRevoked(BeanContextServiceRevokedEvent bcsre) {
- Iterator i = bcsChildren(); // get the BCSChild values.
+ Iterator<BeanContextSupport.BCSChild> i = bcsChildren(); // get the BCSChild values.
while (i.hasNext()) {
((BCSSChild)i.next()).revokeService(bcsre.getServiceClass(), true, bcsre.isCurrentServiceInvalidNow());
@@ -832,7 +834,7 @@
* obtain a service which may be delegated
*/
- public Object getService(BeanContextChild child, Object requestor, Class serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException {
+ public Object getService(BeanContextChild child, Object requestor, Class<?> serviceClass, Object serviceSelector, BeanContextServiceRevokedListener bcsrl) throws TooManyListenersException {
if (child == null) throw new NullPointerException("child");
if (serviceClass == null) throw new NullPointerException("serviceClass");
if (requestor == null) throw new NullPointerException("requestor");
@@ -847,7 +849,7 @@
if (bcsc == null) throw new IllegalArgumentException("not a child of this context"); // not a child ...
- BCSSServiceProvider bcsssp = (BCSSServiceProvider)services.get(serviceClass);
+ BCSSServiceProvider bcsssp = services.get(serviceClass);
if (bcsssp != null) {
BeanContextServiceProvider bcsp = bcsssp.getServiceProvider();
@@ -918,7 +920,7 @@
* @return an iterator for all the currently registered service classes.
*/
- public Iterator getCurrentServiceClasses() {
+ public Iterator<Object> getCurrentServiceClasses() {
return new BCSIterator(services.keySet().iterator());
}
@@ -927,9 +929,9 @@
* (if any) available for the specified service.
*/
- public Iterator getCurrentServiceSelectors(Class serviceClass) {
+ public Iterator<?> getCurrentServiceSelectors(Class<?> serviceClass) {
- BCSSServiceProvider bcsssp = (BCSSServiceProvider)services.get(serviceClass);
+ BCSSServiceProvider bcsssp = services.get(serviceClass);
return bcsssp != null ? new BCSIterator(bcsssp.getServiceProvider().getCurrentServiceSelectors(getBeanContextServicesPeer(), serviceClass)) : null;
}
@@ -950,7 +952,7 @@
fireServiceAdded(bcssae);
- Iterator i;
+ Iterator<Object> i;
synchronized(children) {
i = children.keySet().iterator();
@@ -982,7 +984,7 @@
fireServiceRevoked(bcssre);
- Iterator i;
+ Iterator<Object> i;
synchronized(children) {
i = children.keySet().iterator();
@@ -1085,7 +1087,7 @@
* Fires a <tt>BeanContextServiceEvent</tt> notifying of a new service.
* @param serviceClass the service class
*/
- protected final void fireServiceAdded(Class serviceClass) {
+ protected final void fireServiceAdded(Class<?> serviceClass) {
BeanContextServiceAvailableEvent bcssae = new BeanContextServiceAvailableEvent(getBeanContextServicesPeer(), serviceClass);
fireServiceAdded(bcssae);
@@ -1129,7 +1131,7 @@
* @param serviceClass the service class
* @param revokeNow whether or not the event should be revoked now
*/
- protected final void fireServiceRevoked(Class serviceClass, boolean revokeNow) {
+ protected final void fireServiceRevoked(Class<?> serviceClass, boolean revokeNow) {
Object[] copy;
BeanContextServiceRevokedEvent bcsre = new BeanContextServiceRevokedEvent(getBeanContextServicesPeer(), serviceClass, revokeNow);
@@ -1159,14 +1161,14 @@
int count = 0;
- Iterator i = services.entrySet().iterator();
+ Iterator<Map.Entry<Object, BCSSServiceProvider>> i = services.entrySet().iterator();
while (i.hasNext() && count < serializable) {
- Map.Entry entry = (Map.Entry)i.next();
+ Map.Entry<Object, BCSSServiceProvider> entry = i.next();
BCSSServiceProvider bcsp = null;
try {
- bcsp = (BCSSServiceProvider)entry.getValue();
+ bcsp = entry.getValue();
} catch (ClassCastException cce) {
continue;
}
@@ -1201,7 +1203,7 @@
int count = serializable;
while (count > 0) {
- services.put(ois.readObject(), ois.readObject());
+ services.put(ois.readObject(), (BCSSServiceProvider)ois.readObject());
count--;
}
}
@@ -1236,7 +1238,7 @@
* all accesses to the <code> protected transient HashMap services </code>
* field should be synchronized on that object
*/
- protected transient HashMap services;
+ protected transient HashMap<Object, BCSSServiceProvider> services;
/**
* The number of instances of a serializable <tt>BeanContextServceProvider</tt>.
@@ -1253,5 +1255,5 @@
/**
* List of <tt>BeanContextServicesListener</tt> objects.
*/
- protected transient ArrayList bcsListeners;
+ protected transient ArrayList<BeanContextServicesListener> bcsListeners;
}
--- a/jdk/src/share/classes/java/beans/beancontext/BeanContextSupport.java Tue Jun 03 11:18:03 2014 -0400
+++ b/jdk/src/share/classes/java/beans/beancontext/BeanContextSupport.java Tue Jun 03 09:22:59 2014 -0700
@@ -254,7 +254,7 @@
* currently nested in this <tt>BeanContext</tt>.
* @return an <tt>Iterator</tt> of the nested children
*/
- public Iterator iterator() {
+ public Iterator<Object> iterator() {
synchronized(children) {
return new BCSIterator(children.keySet().iterator());
}
@@ -292,14 +292,14 @@
* a noop remove() method.
*/
- protected static final class BCSIterator implements Iterator {
- BCSIterator(Iterator i) { super(); src = i; }
+ protected static final class BCSIterator implements Iterator<Object> {
+ BCSIterator(Iterator<?> i) { super(); src = i; }
public boolean hasNext() { return src.hasNext(); }
- public Object next() { return src.next(); }
+ public Object next() { return src.next(); }
public void remove() { /* do nothing */ }
- private Iterator src;
+ private Iterator<?> src;
}
/************************************************************************/
@@ -504,7 +504,7 @@
throw new IllegalStateException();
}
- BCSChild bcsc = (BCSChild)children.get(targetChild);
+ BCSChild bcsc = children.get(targetChild);
BCSChild pbcsc = null;
Object peer = null;
@@ -533,7 +533,7 @@
children.remove(targetChild);
if (bcsc.isProxyPeer()) {
- pbcsc = (BCSChild)children.get(peer = bcsc.getProxyPeer());
+ pbcsc = children.get(peer = bcsc.getProxyPeer());
children.remove(peer);
}
}
@@ -566,9 +566,10 @@
* in the collection are children of
* this <tt>BeanContext</tt>, false if not.
*/
+ @SuppressWarnings("rawtypes")
public boolean containsAll(Collection c) {
synchronized(children) {
- Iterator i = c.iterator();
+ Iterator<?> i = c.iterator();
while (i.hasNext())
if(!contains(i.next()))
return false;
@@ -583,6 +584,7 @@
* @throws UnsupportedOperationException thrown unconditionally by this implementation
* @return this implementation unconditionally throws {@code UnsupportedOperationException}
*/
+ @SuppressWarnings("rawtypes")
public boolean addAll(Collection c) {
throw new UnsupportedOperationException();
}
@@ -594,6 +596,7 @@
* @return this implementation unconditionally throws {@code UnsupportedOperationException}
*/
+ @SuppressWarnings("rawtypes")
public boolean removeAll(Collection c) {
throw new UnsupportedOperationException();
}
@@ -605,6 +608,7 @@
* @throws UnsupportedOperationException thrown unconditionally by this implementation
* @return this implementation unconditionally throws {@code UnsupportedOperationException}
*/
+ @SuppressWarnings("rawtypes")
public boolean retainAll(Collection c) {
throw new UnsupportedOperationException();
}
@@ -763,7 +767,7 @@
}
synchronized(children) {
- for (Iterator i = children.keySet().iterator(); i.hasNext();) {
+ for (Iterator<Object> i = children.keySet().iterator(); i.hasNext();) {
Object c = i.next();
try {
@@ -790,7 +794,7 @@
// lets also tell the Children that can that they may not use their GUI's
synchronized(children) {
- for (Iterator i = children.keySet().iterator(); i.hasNext();) {
+ for (Iterator<Object> i = children.keySet().iterator(); i.hasNext();) {
Visibility v = getChildVisibility(i.next());
if (v != null) v.dontUseGui();
@@ -809,7 +813,7 @@
// lets also tell the Children that can that they may use their GUI's
synchronized(children) {
- for (Iterator i = children.keySet().iterator(); i.hasNext();) {
+ for (Iterator<Object> i = children.keySet().iterator(); i.hasNext();) {
Visibility v = getChildVisibility(i.next());
if (v != null) v.okToUseGui();
@@ -841,7 +845,7 @@
* of this <tt>BeanContext</tt>.
* @return an iterator for all the current BCSChild values
*/
- protected Iterator bcsChildren() { synchronized(children) { return children.values().iterator(); } }
+ protected Iterator<BCSChild> bcsChildren() { synchronized(children) { return children.values().iterator(); } }
/**
* called by writeObject after defaultWriteObject() but prior to
@@ -896,7 +900,7 @@
* @param coll the <tt>Collection</tt> to serialize
* @throws IOException if serialization failed
*/
- protected final void serialize(ObjectOutputStream oos, Collection coll) throws IOException {
+ protected final void serialize(ObjectOutputStream oos, Collection<?> coll) throws IOException {
int count = 0;
Object[] objects = coll.toArray();
@@ -926,6 +930,7 @@
* @throws IOException if deserialization failed
* @throws ClassNotFoundException if needed classes are not found
*/
+ @SuppressWarnings({"rawtypes", "unchecked"})
protected final void deserialize(ObjectInputStream ois, Collection coll) throws IOException, ClassNotFoundException {
int count = 0;
@@ -953,10 +958,10 @@
int count = 0;
synchronized(children) {
- Iterator i = children.entrySet().iterator();
+ Iterator<Map.Entry<Object, BCSChild>> i = children.entrySet().iterator();
while (i.hasNext() && count < serializable) {
- Map.Entry entry = (Map.Entry)i.next();
+ Map.Entry<Object, BCSChild> entry = i.next();
if (entry.getKey() instanceof Serializable) {
try {
@@ -1082,7 +1087,7 @@
if (serializable > 0 && this.equals(getBeanContextPeer()))
readChildren(ois);
- deserialize(ois, bcmListeners = new ArrayList(1));
+ deserialize(ois, bcmListeners = new ArrayList<>(1));
}
}
@@ -1101,7 +1106,7 @@
) {
if (!validatePendingRemove(source)) {
throw new PropertyVetoException("current BeanContext vetoes setBeanContext()", pce);
- } else ((BCSChild)children.get(source)).setRemovePending(true);
+ } else children.get(source).setRemovePending(true);
}
}
}
@@ -1117,13 +1122,13 @@
synchronized(children) {
if ("beanContext".equals(propertyName) &&
containsKey(source) &&
- ((BCSChild)children.get(source)).isRemovePending()) {
+ children.get(source).isRemovePending()) {
BeanContext bc = getBeanContextPeer();
if (bc.equals(pce.getOldValue()) && !bc.equals(pce.getNewValue())) {
remove(source, false);
} else {
- ((BCSChild)children.get(source)).setRemovePending(false);
+ children.get(source).setRemovePending(false);
}
}
}
@@ -1312,8 +1317,8 @@
*/
protected synchronized void initialize() {
- children = new HashMap(serializable + 1);
- bcmListeners = new ArrayList(1);
+ children = new HashMap<>(serializable + 1);
+ bcmListeners = new ArrayList<>(1);
childPCL = new PropertyChangeListener() {
@@ -1359,7 +1364,7 @@
* @param second the second object
* @return true if equal, false if not
*/
- protected static final boolean classEquals(Class first, Class second) {
+ protected static final boolean classEquals(Class<?> first, Class<?> second) {
return first.equals(second) || first.getName().equals(second.getName());
}
@@ -1373,7 +1378,7 @@
* all accesses to the <code> protected HashMap children </code> field
* shall be synchronized on that object.
*/
- protected transient HashMap children;
+ protected transient HashMap<Object, BCSChild> children;
private int serializable = 0; // children serializable
@@ -1381,7 +1386,7 @@
* all accesses to the <code> protected ArrayList bcmListeners </code> field
* shall be synchronized on that object.
*/
- protected transient ArrayList bcmListeners;
+ protected transient ArrayList<BeanContextMembershipListener> bcmListeners;
//