summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew John Hughes <gnu_andrew@member.fsf.org>2008-08-25 22:29:15 +0000
committerAndrew John Hughes <gnu_andrew@member.fsf.org>2008-08-25 22:29:15 +0000
commitbb8cb9c04769df4025c51bf776727c89aefb72a4 (patch)
tree476d90d99df6596bd5ac2b71e3f25e7452f3240b
parent4e7bf172b26e5556dff6b134dbfa30fe6bc9cc5b (diff)
downloadclasspath-bb8cb9c04769df4025c51bf776727c89aefb72a4.tar.gz
Add generics to javax.management.
2008-08-25 Andrew John Hughes <gnu_andrew@member.fsf.org> * javax/management/MBeanPermission.java, * javax/management/MBeanServerDelegate.java, * javax/management/MBeanServerFactory.java, * javax/management/MBeanServerInvocationHandler.java, * javax/management/MBeanServerPermission.java: Fix warnings due to use of non-generic collections.
-rw-r--r--ChangeLog9
-rw-r--r--javax/management/MBeanPermission.java32
-rw-r--r--javax/management/MBeanServerDelegate.java7
-rw-r--r--javax/management/MBeanServerFactory.java7
-rw-r--r--javax/management/MBeanServerInvocationHandler.java4
-rw-r--r--javax/management/MBeanServerPermission.java9
6 files changed, 35 insertions, 33 deletions
diff --git a/ChangeLog b/ChangeLog
index fb9653900..3192fae89 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2008-08-25 Andrew John Hughes <gnu_andrew@member.fsf.org>
+
+ * javax/management/MBeanPermission.java,
+ * javax/management/MBeanServerDelegate.java,
+ * javax/management/MBeanServerFactory.java,
+ * javax/management/MBeanServerInvocationHandler.java,
+ * javax/management/MBeanServerPermission.java:
+ Fix warnings due to use of non-generic collections.
+
2008-08-25 Mario Torre <neugens@aicas.com>
* gnu/javax/rmi/CORBA/RmiUtilities.java (readValue): check if sender is
diff --git a/javax/management/MBeanPermission.java b/javax/management/MBeanPermission.java
index 1ee0e7104..076ac86f1 100644
--- a/javax/management/MBeanPermission.java
+++ b/javax/management/MBeanPermission.java
@@ -37,6 +37,8 @@ exception statement from your version. */
package javax.management;
+import gnu.java.lang.CPStringBuilder;
+
import java.security.Permission;
import java.io.IOException;
@@ -154,19 +156,19 @@ public class MBeanPermission
/**
* The list of actions as an ordered set.
*/
- private transient Set actionSet;
+ private transient Set<String> actionSet;
/**
* The set of valid actions.
*/
- private static final Set validSet;
+ private static final Set<String> validSet;
/**
* Initialise the set of valid actions.
*/
static
{
- validSet = new HashSet();
+ validSet = new HashSet<String>();
validSet.add("addNotificationListener");
validSet.add("getAttribute");
validSet.add("getClassLoader");
@@ -263,8 +265,8 @@ public class MBeanPermission
*/
public String getActions()
{
- Iterator it = actionSet.iterator();
- StringBuilder builder = new StringBuilder();
+ Iterator<String> it = actionSet.iterator();
+ CPStringBuilder builder = new CPStringBuilder();
while (it.hasNext())
{
builder.append(it.next());
@@ -323,10 +325,8 @@ public class MBeanPermission
NameHolder name = new NameHolder(getName());
if (!(name.equals(pName)))
return false;
- Iterator i = mp.getActionSet().iterator();
- while (i.hasNext())
+ for (String nextAction : mp.actionSet)
{
- String nextAction = (String) i.next();
boolean found = actions.contains(nextAction);
if (!found)
if (nextAction.equals("queryNames"))
@@ -502,23 +502,13 @@ public class MBeanPermission
}
/**
- * Returns the set of actions.
- *
- * @return the actions as an ordered set.
- */
- Set getActionSet()
- {
- return actionSet;
- }
-
- /**
* Updates the action set from the current value of
* the actions string.
*/
private void updateActionSet()
{
String[] actionsArray = actions.split(",");
- actionSet = new TreeSet();
+ actionSet = new TreeSet<String>();
for (int a = 0; a < actionsArray.length; ++a)
actionSet.add(actionsArray[a].trim());
}
@@ -548,10 +538,8 @@ public class MBeanPermission
*/
private void checkActions()
{
- Iterator it = actionSet.iterator();
- while (it.hasNext())
+ for (String action : actionSet)
{
- String action = (String) it.next();
if (!(validSet.contains(action)))
throw new IllegalArgumentException("Invalid action "
+ action + " found.");
diff --git a/javax/management/MBeanServerDelegate.java b/javax/management/MBeanServerDelegate.java
index 9e9d19111..1337e2dcc 100644
--- a/javax/management/MBeanServerDelegate.java
+++ b/javax/management/MBeanServerDelegate.java
@@ -69,7 +69,8 @@ public class MBeanServerDelegate
/**
* The listeners registered with the delegate.
*/
- private final List listeners = new ArrayList();
+ private final List<ListenerData> listeners =
+ new ArrayList<ListenerData>();
/**
* The sequence identifier used by the delegate.
@@ -293,10 +294,8 @@ public class MBeanServerDelegate
{
if (notification.getSequenceNumber() <= 0)
notification.setSequenceNumber(++seqNo);
- Iterator it = listeners.iterator();
- while (it.hasNext())
+ for (ListenerData ldata : listeners)
{
- ListenerData ldata = (ListenerData) it.next();
NotificationFilter filter = ldata.getFilter();
if (filter == null || filter.isNotificationEnabled(notification))
ldata.getListener().handleNotification(notification, ldata.getPassback());
diff --git a/javax/management/MBeanServerFactory.java b/javax/management/MBeanServerFactory.java
index a8dac9489..d798b0c45 100644
--- a/javax/management/MBeanServerFactory.java
+++ b/javax/management/MBeanServerFactory.java
@@ -89,7 +89,8 @@ public class MBeanServerFactory
/**
* The map of registered servers (identifiers to servers).
*/
- private static final Map<Object,MBeanServer> servers = new HashMap();
+ private static final Map<Object,MBeanServer> servers =
+ new HashMap<Object,MBeanServer>();
/**
* Private constructor to prevent instance creation.
@@ -212,7 +213,7 @@ public class MBeanServerFactory
if (sm != null)
sm.checkPermission(new MBeanServerPermission("findMBeanServer"));
if (id == null)
- return new ArrayList(servers.values());
+ return new ArrayList<MBeanServer>(servers.values());
ArrayList<MBeanServer> list = new ArrayList<MBeanServer>();
MBeanServer server = servers.get(id);
if (server != null)
@@ -342,7 +343,7 @@ public class MBeanServerFactory
cl = MBeanServerFactory.class.getClassLoader();
try
{
- Class bClass = Class.forName(builderClass, true, cl);
+ Class<?> bClass = Class.forName(builderClass, true, cl);
builder = (MBeanServerBuilder) bClass.newInstance();
}
catch (ClassNotFoundException e)
diff --git a/javax/management/MBeanServerInvocationHandler.java b/javax/management/MBeanServerInvocationHandler.java
index 948996764..acc8543f1 100644
--- a/javax/management/MBeanServerInvocationHandler.java
+++ b/javax/management/MBeanServerInvocationHandler.java
@@ -204,7 +204,7 @@ public class MBeanServerInvocationHandler
throws Throwable
{
String mName = method.getName();
- Class proxyClass = proxy.getClass();
+ Class<?> proxyClass = proxy.getClass();
if (mName.equals("toString"))
{
if (inInterface(mName, proxyClass))
@@ -352,6 +352,8 @@ public class MBeanServerInvocationHandler
* @return a proxy for the specified bean.
* @see JMX#newMBeanProxy(MBeanServerConnection,ObjectName,Class)
*/
+ // Suppress warnings as we know an instance of T will be returned.
+ @SuppressWarnings("unchecked")
public static <T> T newProxyInstance(MBeanServerConnection conn,
ObjectName name, Class<T> iface,
boolean broadcaster)
diff --git a/javax/management/MBeanServerPermission.java b/javax/management/MBeanServerPermission.java
index e62278144..55070ef9b 100644
--- a/javax/management/MBeanServerPermission.java
+++ b/javax/management/MBeanServerPermission.java
@@ -280,6 +280,7 @@ public class MBeanServerPermission
* @see #isReadOnly()
* @see #setReadOnly(boolean)
*/
+ @Override
public void add(Permission p)
{
if (isReadOnly())
@@ -327,7 +328,8 @@ public class MBeanServerPermission
*
* @return an enumeration over the collection permission.
*/
- public Enumeration elements()
+ @Override
+ public Enumeration<Permission> elements()
{
return new
MBeanServerPermissionEnumeration(collectionPermission);
@@ -341,7 +343,7 @@ public class MBeanServerPermission
* @since 1.5
*/
private class MBeanServerPermissionEnumeration
- implements Enumeration
+ implements Enumeration<Permission>
{
/**
@@ -381,7 +383,7 @@ public class MBeanServerPermission
*
* @return the next capability.
*/
- public Object nextElement()
+ public Permission nextElement()
{
if (hasMoreElements())
{
@@ -405,6 +407,7 @@ public class MBeanServerPermission
* @param p the permission to check for implication.
* @return true if this permission implies <code>p</code>.
*/
+ @Override
public boolean implies(Permission p)
{
return collectionPermission.implies(p);