8044865: Fix raw and unchecked lint warnings in management-related code
authorsjiang
Thu, 12 Jun 2014 10:32:19 +0200
changeset 24871 224e298c3978
parent 24870 5d567113d043
child 24872 a59d03eeb59e
child 24962 a6927b2a7315
8044865: Fix raw and unchecked lint warnings in management-related code Reviewed-by: darcy, sla, egahlin, dfuchs
jdk/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java
jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java
jdk/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java
jdk/src/share/classes/com/sun/jmx/remote/security/MBeanServerFileAccessController.java
jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpRequestTree.java
jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java
jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java
jdk/src/share/classes/sun/tools/jconsole/ProxyClient.java
jdk/src/share/classes/sun/tools/jconsole/TimeComboBox.java
jdk/src/share/classes/sun/tools/jconsole/inspector/OperationEntry.java
jdk/src/share/classes/sun/tools/jconsole/inspector/TableSorter.java
jdk/src/share/classes/sun/tools/jmap/JMap.java
jdk/src/share/classes/sun/tools/jstack/JStack.java
jdk/src/share/classes/sun/tools/jstat/Alignment.java
jdk/src/share/classes/sun/tools/jstat/ColumnFormat.java
jdk/src/share/classes/sun/tools/jstat/Jstat.java
jdk/src/share/classes/sun/tools/jstat/Operator.java
jdk/src/share/classes/sun/tools/jstat/OptionFormat.java
jdk/src/share/classes/sun/tools/jstat/Parser.java
jdk/src/share/classes/sun/tools/jstat/RawOutputFormatter.java
jdk/src/share/classes/sun/tools/jstat/Scale.java
jdk/src/share/classes/sun/tools/jstat/SyntaxException.java
--- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java	Wed Jun 11 15:47:53 2014 +0200
+++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/Introspector.java	Thu Jun 12 10:32:19 2014 +0200
@@ -562,7 +562,7 @@
                 }
                 if (readMethod != null) {
                     ReflectUtil.checkPackageAccess(readMethod.getDeclaringClass());
-                    return MethodUtil.invoke(readMethod, complex, new Class[0]);
+                    return MethodUtil.invoke(readMethod, complex, new Class<?>[0]);
                 }
 
                 throw new AttributeNotFoundException(
--- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java	Wed Jun 11 15:47:53 2014 +0200
+++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java	Thu Jun 12 10:32:19 2014 +0200
@@ -757,7 +757,7 @@
         }
     }
 
-    private static void ensureClassAccess(Class clazz)
+    private static void ensureClassAccess(Class<?> clazz)
             throws IllegalAccessException
     {
         int mod = clazz.getModifiers();
--- a/jdk/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java	Wed Jun 11 15:47:53 2014 +0200
+++ b/jdk/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java	Thu Jun 12 10:32:19 2014 +0200
@@ -58,7 +58,7 @@
 
     private final AccessControlContext acc;
 
-    public ClientNotifForwarder(Map env) {
+    public ClientNotifForwarder(Map<String, ?> env) {
         this(null, env);
     }
 
--- a/jdk/src/share/classes/com/sun/jmx/remote/security/MBeanServerFileAccessController.java	Wed Jun 11 15:47:53 2014 +0200
+++ b/jdk/src/share/classes/com/sun/jmx/remote/security/MBeanServerFileAccessController.java	Thu Jun 12 10:32:19 2014 +0200
@@ -310,10 +310,10 @@
                     }
                 });
         if (s == null) return; /* security has not been enabled */
-        final Set principals = s.getPrincipals();
+        final Set<Principal> principals = s.getPrincipals();
         String newPropertyValue = null;
-        for (Iterator i = principals.iterator(); i.hasNext(); ) {
-            final Principal p = (Principal) i.next();
+        for (Iterator<Principal> i = principals.iterator(); i.hasNext(); ) {
+            final Principal p = i.next();
             Access access = accessMap.get(p.getName());
             if (access != null) {
                 boolean ok;
--- a/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpRequestTree.java	Wed Jun 11 15:47:53 2014 +0200
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/agent/SnmpRequestTree.java	Thu Jun 12 10:32:19 2014 +0200
@@ -535,7 +535,7 @@
 
                 // Save old vectors
                 SnmpOid[]     olde = entryoids;
-                Vector[]      oldl = entrylists;
+                Vector<SnmpVarBind>[]      oldl = entrylists;
                 boolean[]     oldn = isentrynew;
                 SnmpVarBind[] oldr = rowstatus;
 
--- a/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java	Wed Jun 11 15:47:53 2014 +0200
+++ b/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java	Thu Jun 12 10:32:19 2014 +0200
@@ -1215,7 +1215,7 @@
                         ReflectUtil.checkPackageAccess(className);
                         final ClassLoader targetClassLoader =
                             rmmbClass.getClassLoader();
-                        Class clz = Class.forName(className, false,
+                        Class<?> clz = Class.forName(className, false,
                                                     targetClassLoader);
                         if (!rmmbClass.isAssignableFrom(clz))
                             return null;
@@ -1673,12 +1673,12 @@
                             // inequality may come from type subclassing
                             boolean subtype;
                             try {
-                                final Class respClass = response.getClass();
+                                final Class<?> respClass = response.getClass();
                                 final Exception[] caughException = new Exception[1];
 
                                 AccessControlContext stack = AccessController.getContext();
 
-                                Class c = javaSecurityAccess.doIntersectionPrivilege(new PrivilegedAction<Class<?>>() {
+                                Class<?> c = javaSecurityAccess.doIntersectionPrivilege(new PrivilegedAction<Class<?>>() {
 
                                     @Override
                                     public Class<?> run() {
@@ -2855,7 +2855,7 @@
         AccessControlContext stack = AccessController.getContext();
         final ClassNotFoundException[] caughtException = new ClassNotFoundException[1];
 
-        Class c = javaSecurityAccess.doIntersectionPrivilege(new PrivilegedAction<Class<?>>() {
+        Class<?> c = javaSecurityAccess.doIntersectionPrivilege(new PrivilegedAction<Class<?>>() {
 
             @Override
             public Class<?> run() {
--- a/jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java	Wed Jun 11 15:47:53 2014 +0200
+++ b/jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java	Thu Jun 12 10:32:19 2014 +0200
@@ -2011,13 +2011,13 @@
             if (nullSubjectConnRef == null
                     || (conn = nullSubjectConnRef.get()) == null) {
                 conn = new RemoteMBeanServerConnection(null);
-                nullSubjectConnRef = new WeakReference(conn);
+                nullSubjectConnRef = new WeakReference<MBeanServerConnection>(conn);
             }
         } else {
             WeakReference<MBeanServerConnection> wr = rmbscMap.get(delegationSubject);
             if (wr == null || (conn = wr.get()) == null) {
                 conn = new RemoteMBeanServerConnection(delegationSubject);
-                rmbscMap.put(delegationSubject, new WeakReference(conn));
+                rmbscMap.put(delegationSubject, new WeakReference<MBeanServerConnection>(conn));
             }
         }
         return conn;
@@ -2115,7 +2115,7 @@
         PrivilegedExceptionAction<Constructor<?>> action =
                 new PrivilegedExceptionAction<Constructor<?>>() {
             public Constructor<?> run() throws Exception {
-                Class thisClass = RMIConnector.class;
+                Class<RMIConnector> thisClass = RMIConnector.class;
                 ClassLoader thisLoader = thisClass.getClassLoader();
                 ProtectionDomain thisProtectionDomain =
                         thisClass.getProtectionDomain();
@@ -2354,7 +2354,7 @@
             PrivilegedExceptionAction<Class<?>> action =
                 new PrivilegedExceptionAction<Class<?>>() {
               public Class<?> run() throws Exception {
-                Class thisClass = RMIConnector.class;
+                Class<RMIConnector> thisClass = RMIConnector.class;
                 ClassLoader thisLoader = thisClass.getClassLoader();
                 ProtectionDomain thisProtectionDomain =
                         thisClass.getProtectionDomain();
--- a/jdk/src/share/classes/sun/tools/jconsole/ProxyClient.java	Wed Jun 11 15:47:53 2014 +0200
+++ b/jdk/src/share/classes/sun/tools/jconsole/ProxyClient.java	Thu Jun 12 10:32:19 2014 +0200
@@ -954,7 +954,7 @@
             final InvocationHandler ih = new SnapshotInvocationHandler(mbsc);
             return (SnapshotMBeanServerConnection) Proxy.newProxyInstance(
                     Snapshot.class.getClassLoader(),
-                    new Class[] {SnapshotMBeanServerConnection.class},
+                    new Class<?>[] {SnapshotMBeanServerConnection.class},
                     ih);
         }
     }
--- a/jdk/src/share/classes/sun/tools/jconsole/TimeComboBox.java	Wed Jun 11 15:47:53 2014 +0200
+++ b/jdk/src/share/classes/sun/tools/jconsole/TimeComboBox.java	Thu Jun 12 10:32:19 2014 +0200
@@ -37,7 +37,7 @@
  * them.
  */
 @SuppressWarnings("serial")
-public class TimeComboBox extends JComboBox implements ItemListener, PropertyChangeListener {
+public class TimeComboBox extends JComboBox<String> implements ItemListener, PropertyChangeListener {
     private ArrayList<Plotter> plotters = new ArrayList<Plotter>();
 
     public TimeComboBox(Plotter... plotterArray) {
--- a/jdk/src/share/classes/sun/tools/jconsole/inspector/OperationEntry.java	Wed Jun 11 15:47:53 2014 +0200
+++ b/jdk/src/share/classes/sun/tools/jconsole/inspector/OperationEntry.java	Thu Jun 12 10:32:19 2014 +0200
@@ -32,7 +32,6 @@
 @SuppressWarnings("serial")
 public class OperationEntry extends JPanel {
     private MBeanOperationInfo operation;
-    private JComboBox sigs;
     private XTextField inputs[];
 
     public OperationEntry (MBeanOperationInfo operation,
--- a/jdk/src/share/classes/sun/tools/jconsole/inspector/TableSorter.java	Wed Jun 11 15:47:53 2014 +0200
+++ b/jdk/src/share/classes/sun/tools/jconsole/inspector/TableSorter.java	Thu Jun 12 10:32:19 2014 +0200
@@ -146,7 +146,7 @@
         // update row heights in XMBeanAttributes (required by expandable cells)
         if (attrs != null) {
             for (int i = 0; i < getRowCount(); i++) {
-                Vector data = (Vector) dataVector.elementAt(i);
+                Vector<?> data = (Vector) dataVector.elementAt(i);
                 attrs.updateRowHeight(data.elementAt(1), i);
             }
         }
@@ -217,17 +217,17 @@
             }
     }
 
-    private Vector getRow(int row) {
+    private Vector<?> getRow(int row) {
         return (Vector) dataVector.elementAt(row);
     }
 
     @SuppressWarnings("unchecked")
-    private void setRow(Vector data, int row) {
+    private void setRow(Vector<?> data, int row) {
         dataVector.setElementAt(data,row);
     }
 
     private void swap(int i, int j, int column) {
-        Vector data = getRow(i);
+        Vector<?> data = getRow(i);
         setRow(getRow(j),i);
         setRow(data,j);
 
--- a/jdk/src/share/classes/sun/tools/jmap/JMap.java	Wed Jun 11 15:47:53 2014 +0200
+++ b/jdk/src/share/classes/sun/tools/jmap/JMap.java	Thu Jun 12 10:32:19 2014 +0200
@@ -194,7 +194,7 @@
         }
 
         // invoke the main method with the arguments
-        Class[] argTypes = { String[].class } ;
+        Class<?>[] argTypes = { String[].class } ;
         Method m = c.getDeclaredMethod("main", argTypes);
 
         Object[] invokeArgs = { args };
--- a/jdk/src/share/classes/sun/tools/jstack/JStack.java	Wed Jun 11 15:47:53 2014 +0200
+++ b/jdk/src/share/classes/sun/tools/jstack/JStack.java	Thu Jun 12 10:32:19 2014 +0200
@@ -133,7 +133,7 @@
             args = prepend("-l", args);
         }
 
-        Class[] argTypes = { String[].class };
+        Class<?>[] argTypes = { String[].class };
         Method m = cl.getDeclaredMethod("main", argTypes);
 
         Object[] invokeArgs = { args };
--- a/jdk/src/share/classes/sun/tools/jstat/Alignment.java	Wed Jun 11 15:47:53 2014 +0200
+++ b/jdk/src/share/classes/sun/tools/jstat/Alignment.java	Thu Jun 12 10:32:19 2014 +0200
@@ -110,7 +110,7 @@
      *
      * @return     Set of Key Words for this enumeration.
      */
-    public static Set keySet() {
+    public static Set<String> keySet() {
         return map.keySet();
     }
 
--- a/jdk/src/share/classes/sun/tools/jstat/ColumnFormat.java	Wed Jun 11 15:47:53 2014 +0200
+++ b/jdk/src/share/classes/sun/tools/jstat/ColumnFormat.java	Thu Jun 12 10:32:19 2014 +0200
@@ -143,8 +143,8 @@
                 + ";format=" + format + ";width=" + width
                 + ";scale=" + scale.toString() + ";align=" + align.toString());
 
-        for (Iterator i = children.iterator();  i.hasNext(); /* empty */) {
-            OptionFormat of = (OptionFormat)i.next();
+        for (Iterator<OptionFormat> i = children.iterator();  i.hasNext(); /* empty */) {
+            OptionFormat of = i.next();
             of.printFormat(indentLevel+1);
         }
 
--- a/jdk/src/share/classes/sun/tools/jstat/Jstat.java	Wed Jun 11 15:47:53 2014 +0200
+++ b/jdk/src/share/classes/sun/tools/jstat/Jstat.java	Thu Jun 12 10:32:19 2014 +0200
@@ -116,8 +116,8 @@
             Collections.sort(logged, arguments.comparator());
             List<Monitor> constants = new ArrayList<Monitor>();
 
-            for (Iterator i = logged.iterator(); i.hasNext(); /* empty */) {
-                Monitor m = (Monitor)i.next();
+            for (Iterator<Monitor> i = logged.iterator(); i.hasNext(); /* empty */) {
+                Monitor m = i.next();
                 if (!(m.isSupported() || arguments.showUnsupported())) {
                     i.remove();
                     continue;
--- a/jdk/src/share/classes/sun/tools/jstat/Operator.java	Wed Jun 11 15:47:53 2014 +0200
+++ b/jdk/src/share/classes/sun/tools/jstat/Operator.java	Thu Jun 12 10:32:19 2014 +0200
@@ -105,7 +105,7 @@
      * @param   s  an string to match against Operator objects.
      * @return     The Operator object matching the given string.
      */
-    protected static Set keySet() {
+    protected static Set<?> keySet() {
         return map.keySet();
     }
 }
--- a/jdk/src/share/classes/sun/tools/jstat/OptionFormat.java	Wed Jun 11 15:47:53 2014 +0200
+++ b/jdk/src/share/classes/sun/tools/jstat/OptionFormat.java	Thu Jun 12 10:32:19 2014 +0200
@@ -77,13 +77,13 @@
 
     public void apply(Closure c) throws MonitorException {
 
-      for (Iterator i = children.iterator(); i.hasNext(); /* empty */) {
-          OptionFormat o = (OptionFormat)i.next();
+      for (Iterator<OptionFormat> i = children.iterator(); i.hasNext(); /* empty */) {
+          OptionFormat o = i.next();
           c.visit(o, i.hasNext());
       }
 
-      for (Iterator i = children.iterator(); i.hasNext(); /* empty */) {
-          OptionFormat o = (OptionFormat)i.next();
+      for (Iterator <OptionFormat>i = children.iterator(); i.hasNext(); /* empty */) {
+          OptionFormat o = i.next();
           o.apply(c);
       }
     }
--- a/jdk/src/share/classes/sun/tools/jstat/Parser.java	Wed Jun 11 15:47:53 2014 +0200
+++ b/jdk/src/share/classes/sun/tools/jstat/Parser.java	Thu Jun 12 10:32:19 2014 +0200
@@ -63,8 +63,8 @@
 
     private static final String START = OPTION;
 
-    private static final Set scaleKeyWords = Scale.keySet();
-    private static final Set alignKeyWords = Alignment.keySet();
+    private static final Set<String> scaleKeyWords = Scale.keySet();
+    private static final Set<String> alignKeyWords = Alignment.keySet();
     private static String[] otherKeyWords = {
         OPTION, COLUMN, DATA, HEADER, WIDTH, FORMAT, ALIGN, SCALE
     };
@@ -141,7 +141,7 @@
      * token is assumed to be of type TT_WORD, and the set is assumed
      * to contain String objects.
      */
-    private Token matchOne(Set keyWords) throws ParserException, IOException {
+    private Token matchOne(Set<String> keyWords) throws ParserException, IOException {
         if ((lookahead.ttype == StreamTokenizer.TT_WORD)
                 && keyWords.contains(lookahead.sval)) {
             Token t = lookahead;
--- a/jdk/src/share/classes/sun/tools/jstat/RawOutputFormatter.java	Wed Jun 11 15:47:53 2014 +0200
+++ b/jdk/src/share/classes/sun/tools/jstat/RawOutputFormatter.java	Thu Jun 12 10:32:19 2014 +0200
@@ -35,11 +35,11 @@
  * @since 1.5
  */
 public class RawOutputFormatter implements OutputFormatter {
-    private List logged;
+    private List<Monitor> logged;
     private String header;
     private boolean printStrings;
 
-    public RawOutputFormatter(List logged, boolean printStrings) {
+    public RawOutputFormatter(List<Monitor> logged, boolean printStrings) {
         this.logged = logged;
         this.printStrings = printStrings;
     }
@@ -48,8 +48,8 @@
         if (header == null) {
             // build the header string and prune out any unwanted monitors
             StringBuilder headerBuilder = new StringBuilder();
-            for (Iterator i = logged.iterator(); i.hasNext(); /* empty */ ) {
-                Monitor m = (Monitor)i.next();
+            for (Iterator<Monitor> i = logged.iterator(); i.hasNext(); /* empty */ ) {
+                Monitor m = i.next();
                 headerBuilder.append(m.getName() + " ");
             }
             header = headerBuilder.toString();
@@ -60,8 +60,8 @@
     public String getRow() throws MonitorException {
         StringBuilder row = new StringBuilder();
         int count = 0;
-        for (Iterator i = logged.iterator(); i.hasNext(); /* empty */ ) {
-            Monitor m = (Monitor)i.next();
+        for (Iterator<Monitor> i = logged.iterator(); i.hasNext(); /* empty */ ) {
+            Monitor m = i.next();
             if (count++ > 0) {
                 row.append(" ");
             }
--- a/jdk/src/share/classes/sun/tools/jstat/Scale.java	Wed Jun 11 15:47:53 2014 +0200
+++ b/jdk/src/share/classes/sun/tools/jstat/Scale.java	Thu Jun 12 10:32:19 2014 +0200
@@ -175,7 +175,7 @@
      * @param   s  an string to match against Scale objects.
      * @return     The Scale object matching the given string.
      */
-    protected static Set keySet() {
+    protected static Set<String> keySet() {
         return map.keySet();
     }
 
--- a/jdk/src/share/classes/sun/tools/jstat/SyntaxException.java	Wed Jun 11 15:47:53 2014 +0200
+++ b/jdk/src/share/classes/sun/tools/jstat/SyntaxException.java	Thu Jun 12 10:32:19 2014 +0200
@@ -62,14 +62,14 @@
                   + ", Found " + found.toMessage();
     }
 
-    public SyntaxException(int lineno, Set expected, Token found) {
+    public SyntaxException(int lineno, Set<String> expected, Token found) {
         StringBuilder msg = new StringBuilder();
 
         msg.append("Syntax error at line " + lineno + ": Expected one of \'");
 
         boolean first = true;
-        for (Iterator i = expected.iterator(); i.hasNext(); /* empty */) {
-            String keyWord = (String)i.next();
+        for (Iterator<String> i = expected.iterator(); i.hasNext(); /* empty */) {
+            String keyWord = i.next();
             if (first) {
                 msg.append(keyWord);
                 first = false;