6701459: Synchronization bug pattern found in javax.management.relation.RelationService
authoremcmanus
Wed, 14 May 2008 18:38:14 +0200
changeset 526 61ba2d5ea9da
parent 497 a39d2c31df28
child 527 a33264d48a84
6701459: Synchronization bug pattern found in javax.management.relation.RelationService Summary: Fixed this and many other problems found by FindBugs. Reviewed-by: dfuchs
jdk/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java
jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java
jdk/src/share/classes/com/sun/jmx/mbeanserver/Repository.java
jdk/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java
jdk/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java
jdk/src/share/classes/com/sun/jmx/remote/security/FileLoginModule.java
jdk/src/share/classes/com/sun/jmx/remote/security/JMXPluggableAuthenticator.java
jdk/src/share/classes/com/sun/jmx/remote/security/MBeanServerFileAccessController.java
jdk/src/share/classes/javax/management/NumericValueExp.java
jdk/src/share/classes/javax/management/ObjectName.java
jdk/src/share/classes/javax/management/StandardMBean.java
jdk/src/share/classes/javax/management/loading/MLet.java
jdk/src/share/classes/javax/management/loading/MLetParser.java
jdk/src/share/classes/javax/management/modelmbean/DescriptorSupport.java
jdk/src/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java
jdk/src/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java
jdk/src/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java
jdk/src/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java
jdk/src/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java
jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java
jdk/src/share/classes/javax/management/monitor/CounterMonitor.java
jdk/src/share/classes/javax/management/monitor/GaugeMonitor.java
jdk/src/share/classes/javax/management/monitor/Monitor.java
jdk/src/share/classes/javax/management/openmbean/ArrayType.java
jdk/src/share/classes/javax/management/openmbean/CompositeType.java
jdk/src/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java
jdk/src/share/classes/javax/management/openmbean/OpenMBeanConstructorInfoSupport.java
jdk/src/share/classes/javax/management/openmbean/OpenMBeanInfoSupport.java
jdk/src/share/classes/javax/management/openmbean/SimpleType.java
jdk/src/share/classes/javax/management/openmbean/TabularType.java
jdk/src/share/classes/javax/management/relation/RelationNotification.java
jdk/src/share/classes/javax/management/relation/RelationService.java
jdk/src/share/classes/javax/management/relation/RelationSupport.java
jdk/src/share/classes/javax/management/remote/JMXConnectorFactory.java
jdk/src/share/classes/javax/management/remote/JMXConnectorServerFactory.java
jdk/src/share/classes/javax/management/remote/JMXServiceURL.java
jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java
jdk/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java
jdk/src/share/classes/javax/management/timer/Timer.java
--- a/jdk/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java	Wed May 14 18:38:14 2008 +0200
@@ -233,7 +233,6 @@
                MBeanRegistrationException, MBeanException,
                NotCompliantMBeanException, InstanceNotFoundException {
 
-        ObjectName logicalName = name;
         Class theClass;
 
         if (className == null) {
@@ -519,8 +518,7 @@
                                                 QueryExp query) {
         // Query the MBeans on the repository
         //
-        Set<NamedObject> list = null;
-        list = repository.query(name, query);
+        Set<NamedObject> list = repository.query(name, query);
 
         if (queryByRepo) {
             // The repository performs the filtering
@@ -576,8 +574,7 @@
     private Set<ObjectName> queryNamesImpl(ObjectName name, QueryExp query) {
         // Query the MBeans on the repository
         //
-        Set<NamedObject> list = null;
-        list = repository.query(name, query);
+        Set<NamedObject> list = repository.query(name, query);
 
         if (queryByRepo) {
             // The repository performs the filtering
@@ -1042,7 +1039,7 @@
         if (registerFailed && moi instanceof DynamicMBean2)
             ((DynamicMBean2) moi).registerFailed();
         try {
-            moi.postRegister(new Boolean(registrationDone));
+            moi.postRegister(registrationDone);
         } catch (RuntimeException e) {
             throw new RuntimeMBeanException(e,
                       "RuntimeException thrown in postRegister method");
@@ -1094,8 +1091,7 @@
                 IllegalArgumentException("Object name cannot be null"),
                                "Exception occurred trying to get an MBean");
         }
-        DynamicMBean obj = null;
-        obj = repository.retrieve(name);
+        DynamicMBean obj = repository.retrieve(name);
         if (obj == null) {
             if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
                 MBEANSERVER_LOGGER.logp(Level.FINER,
@@ -1568,7 +1564,6 @@
             query.setMBeanServer(server);
             try {
                 for (NamedObject no : list) {
-                    final DynamicMBean obj = no.getObject();
                     boolean res;
                     try {
                         res = query.apply(no.getName());
--- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java	Wed May 14 18:38:14 2008 +0200
@@ -205,7 +205,7 @@
      */
     public Object instantiate(Class theClass)
         throws ReflectionException, MBeanException {
-        Object moi = null;
+        Object moi;
 
 
         // ------------------------------
@@ -265,7 +265,7 @@
         // ------------------------------
         // ------------------------------
         final Class[] tab;
-        Object moi= null;
+        Object moi;
         try {
             // Build the signature of the method
             //
@@ -283,8 +283,7 @@
         }
 
         // Query the metadata service to get the right constructor
-        Constructor cons = null;
-        cons = findConstructor(theClass, tab);
+        Constructor cons = findConstructor(theClass, tab);
 
         if (cons == null) {
             throw new ReflectionException(new
@@ -408,7 +407,7 @@
             throw new  RuntimeOperationsException(new
              IllegalArgumentException(), "Null className passed in parameter");
         }
-        Class theClass = null;
+        Class theClass;
         if (loaderName == null) {
             // Load the class using the agent class loader
             theClass = findClass(className, loader);
@@ -621,7 +620,7 @@
     static Class loadClass(String className, ClassLoader loader)
         throws ReflectionException {
 
-        Class theClass = null;
+        Class theClass;
         if (className == null) {
             throw new RuntimeOperationsException(new
                 IllegalArgumentException("The class name cannot be null"),
--- a/jdk/src/share/classes/com/sun/jmx/mbeanserver/Repository.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/mbeanserver/Repository.java	Wed May 14 18:38:14 2008 +0200
@@ -89,7 +89,6 @@
 
     /* This class is used to match an ObjectName against a pattern. */
     private final static class ObjectNamePattern {
-        private final char[]   domain;
         private final String[] keys;
         private final String[] values;
         private final String   properties;
@@ -106,8 +105,7 @@
          * @param pattern The ObjectName pattern under examination.
          **/
         public ObjectNamePattern(ObjectName pattern) {
-            this(pattern.getDomain(),
-                 pattern.isPropertyListPattern(),
+            this(pattern.isPropertyListPattern(),
                  pattern.isPropertyValuePattern(),
                  pattern.getCanonicalKeyPropertyListString(),
                  pattern.getKeyPropertyList(),
@@ -124,13 +122,11 @@
          * @param keyPropertyList pattern.getKeyPropertyList().
          * @param pattern The ObjectName pattern under examination.
          **/
-        ObjectNamePattern(String domain,
-                          boolean propertyListPattern,
+        ObjectNamePattern(boolean propertyListPattern,
                           boolean propertyValuePattern,
                           String canonicalProps,
                           Map<String,String> keyPropertyList,
                           ObjectName pattern) {
-            this.domain = domain.toCharArray();
             this.isPropertyListPattern = propertyListPattern;
             this.isPropertyValuePattern = propertyValuePattern;
             this.properties = canonicalProps;
@@ -538,7 +534,7 @@
         // "domain:*", "domain:[key=value],*" : names in the specified domain
 
         // Surely one of the most frequent case ... query on the whole world
-        ObjectName name = null;
+        ObjectName name;
         if (pattern == null ||
             pattern.getCanonicalName().length() == 0 ||
             pattern.equals(ObjectName.WILDCARD))
@@ -660,7 +656,7 @@
      * @return  Number of MBeans.
      */
     public Integer getCount() {
-        return new Integer(nbElements);
+        return nbElements;
     }
 
     /**
@@ -669,7 +665,7 @@
      *
      * @return  A string giving the name of the default domain name.
      */
-    public  String getDefaultDomain() {
+    public String getDefaultDomain() {
         return domain;
     }
 
--- a/jdk/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java	Wed May 14 18:38:14 2008 +0200
@@ -435,7 +435,6 @@
 
                     clientSequenceNumber = nr.getNextSequenceNumber();
 
-                    final int size = infoList.size();
                     listeners = new HashMap<Integer, ClientListenerInfo>();
 
                     for (int i = 0 ; i < len ; i++) {
@@ -792,9 +791,6 @@
 
     private Thread currentFetchThread;
 
-    // admin stuff
-    private boolean inited = false;
-
     // state
     /**
      * This state means that a thread is being created for fetching and forwarding notifications.
--- a/jdk/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java	Wed May 14 18:38:14 2008 +0200
@@ -269,7 +269,7 @@
                 ", the maxNotifications is " + maxNotifications);
         }
 
-        NotificationResult nr = null;
+        NotificationResult nr;
         final long t = Math.min(connectionTimeout, timeout);
         try {
             nr = notifBuffer.fetchNotifications(bufferFilter,
@@ -322,7 +322,7 @@
 
     private Integer getListenerID() {
         synchronized(listenerCounterLock) {
-            return new Integer(listenerCounter++);
+            return listenerCounter++;
         }
     }
 
@@ -336,7 +336,7 @@
         SecurityManager sm = System.getSecurityManager();
         if (sm != null) {
             AccessControlContext acc = AccessController.getContext();
-            ObjectInstance oi = null;
+            ObjectInstance oi;
             try {
                 oi = AccessController.doPrivileged(
                     new PrivilegedExceptionAction<ObjectInstance>() {
--- a/jdk/src/share/classes/com/sun/jmx/remote/security/FileLoginModule.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/remote/security/FileLoginModule.java	Wed May 14 18:38:14 2008 +0200
@@ -437,7 +437,7 @@
         // get the username and password
         getUsernamePassword(usePasswdFromSharedState);
 
-        String localPassword = null;
+        String localPassword;
 
         // userCredentials is initialized in login()
         if (((localPassword = userCredentials.getProperty(username)) == null) ||
@@ -487,10 +487,14 @@
                 throw ace;
             }
         }
-        BufferedInputStream bis = new BufferedInputStream(fis);
-        userCredentials = new Properties();
-        userCredentials.load(bis);
-        bis.close();
+        try {
+            BufferedInputStream bis = new BufferedInputStream(fis);
+            userCredentials = new Properties();
+            userCredentials.load(bis);
+            bis.close();
+        } finally {
+            fis.close();
+        }
     }
 
     /**
--- a/jdk/src/share/classes/com/sun/jmx/remote/security/JMXPluggableAuthenticator.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/remote/security/JMXPluggableAuthenticator.java	Wed May 14 18:38:14 2008 +0200
@@ -295,7 +295,7 @@
 private static class FileLoginConfig extends Configuration {
 
     // The JAAS configuration for file-based authentication
-    private static AppConfigurationEntry[] entries;
+    private AppConfigurationEntry[] entries;
 
     // The classname of the login module for file-based authentication
     private static final String FILE_LOGIN_MODULE =
--- a/jdk/src/share/classes/com/sun/jmx/remote/security/MBeanServerFileAccessController.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/com/sun/jmx/remote/security/MBeanServerFileAccessController.java	Wed May 14 18:38:14 2008 +0200
@@ -231,10 +231,13 @@
     private static Properties propertiesFromFile(String fname)
         throws IOException {
         FileInputStream fin = new FileInputStream(fname);
-        Properties p = new Properties();
-        p.load(fin);
-        fin.close();
-        return p;
+        try {
+            Properties p = new Properties();
+            p.load(fin);
+            return p;
+        } finally {
+            fin.close();
+        }
     }
 
     private void checkAccessLevel(String accessLevel) {
--- a/jdk/src/share/classes/javax/management/NumericValueExp.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/NumericValueExp.java	Wed May 14 18:38:14 2008 +0200
@@ -83,7 +83,7 @@
      * <p>The <b>serialVersionUID</b> of this class is <code>-4679739485102359104L</code>.
      */
     private static final ObjectStreamField[] serialPersistentFields;
-    private Number val = new Double(0);
+    private Number val = 0.0;
 
     private static boolean compat = false;
     static {
@@ -213,11 +213,11 @@
         }
         if (isLong)
         {
-          this.val = new Long(longVal);
+          this.val = longVal;
         }
         else
         {
-          this.val = new Double(doubleVal);
+          this.val = doubleVal;
         }
       }
       else
--- a/jdk/src/share/classes/javax/management/ObjectName.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/ObjectName.java	Wed May 14 18:38:14 2008 +0200
@@ -449,7 +449,7 @@
         // parses domain part
     domain_parsing:
         while (index < len) {
-            switch (c = name_chars[index]) {
+            switch (name_chars[index]) {
                 case ':' :
                     _domain_length = index++;
                     break domain_parsing;
@@ -619,7 +619,7 @@
                     case '\n' :
                         final String ichar = ((c1=='\n')?"\\n":""+c1);
                         throw new MalformedObjectNameException(
-                                                 "Invalid character '" + c1 +
+                                                 "Invalid character '" + ichar +
                                                  "' in value part of property");
                     default :
                         in_index++;
--- a/jdk/src/share/classes/javax/management/StandardMBean.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/StandardMBean.java	Wed May 14 18:38:14 2008 +0200
@@ -750,7 +750,7 @@
      * @return the Descriptor for the new MBeanInfo.
      */
     Descriptor getDescriptor(MBeanInfo info, boolean immutableInfo) {
-        ImmutableDescriptor desc = null;
+        ImmutableDescriptor desc;
         if (info == null ||
             info.getDescriptor() == null ||
             info.getDescriptor().getFieldNames().length == 0) {
--- a/jdk/src/share/classes/javax/management/loading/MLet.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/loading/MLet.java	Wed May 14 18:38:14 2008 +0200
@@ -591,8 +591,8 @@
              // Instantiate the class specified in the
              // CODE or OBJECT section of the MLet tag
              //
-             Object o = null;
-             ObjectInstance objInst = null;
+             Object o;
+             ObjectInstance objInst;
 
              if (code != null && serName != null) {
                  final String msg =
@@ -1131,11 +1131,17 @@
              return null;
          } finally {
              // Cleanup ...
-             if (tmpFile!=null) try {
-                 tmpFile.delete();
-             } catch (Exception x) {
-                 MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
-                         "getTmpDir", "Failed to delete temporary file", x);
+             if (tmpFile!=null) {
+                 try {
+                     boolean deleted = tmpFile.delete();
+                     if (!deleted) {
+                         MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
+                                 "getTmpDir", "Failed to delete temp file");
+                     }
+                 } catch (Exception x) {
+                     MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
+                             "getTmpDir", "Failed to delete temporary file", x);
+                 }
              }
         }
      }
@@ -1178,25 +1184,8 @@
     * Removes any white space from a string. This is used to
     * convert strings such as "Windows NT" to "WindowsNT".
     */
-     private String removeSpace(String s) {
-         s = s.trim();
-         int j = s.indexOf(' ');
-         if (j == -1) {
-             return s;
-         }
-         String temp = "";
-         int k = 0;
-         while (j != -1) {
-             s = s.substring(k);
-             j = s.indexOf(' ');
-             if (j != -1) {
-                 temp = temp + s.substring(0, j);
-             } else {
-                 temp = temp + s.substring(0);
-             }
-             k = j + 1;
-         }
-         return temp;
+     private static String removeSpace(String s) {
+         return s.trim().replace(" ", "");
      }
 
      /**
--- a/jdk/src/share/classes/javax/management/loading/MLetParser.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/loading/MLetParser.java	Wed May 14 18:38:14 2008 +0200
@@ -240,14 +240,12 @@
                                 MLET_LOGGER.logp(Level.FINER,
                                         MLetParser.class.getName(),
                                         mth, requiresCodeWarning);
-                                atts = null;
                                 throw new IOException(requiresCodeWarning);
                             }
                             if (atts.get("archive") == null) {
                                 MLET_LOGGER.logp(Level.FINER,
                                         MLetParser.class.getName(),
                                         mth, requiresJarsWarning);
-                                atts = null;
                                 throw new IOException(requiresJarsWarning);
                             }
                         }
@@ -265,7 +263,7 @@
     public List<MLetContent> parseURL(String urlname) throws IOException {
         // Parse the document
         //
-        URL url = null;
+        URL url;
         if (urlname.indexOf(':') <= 1) {
             String userDir = System.getProperty("user.dir");
             String prot;
--- a/jdk/src/share/classes/javax/management/modelmbean/DescriptorSupport.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/modelmbean/DescriptorSupport.java	Wed May 14 18:38:14 2008 +0200
@@ -591,8 +591,6 @@
         Set returnedSet = descriptorMap.entrySet();
 
         int i = 0;
-        Object currValue = null;
-        Map.Entry currElement = null;
 
         if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
             MODELMBEAN_LOGGER.logp(Level.FINEST,
@@ -600,7 +598,7 @@
                     "getFields()", "Returning " + numberOfEntries + " fields");
         }
         for (Iterator iter = returnedSet.iterator(); iter.hasNext(); i++) {
-            currElement = (Map.Entry) iter.next();
+            Map.Entry currElement = (Map.Entry) iter.next();
 
             if (currElement == null) {
                 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
@@ -609,7 +607,7 @@
                             "getFields()", "Element is null");
                 }
             } else {
-                currValue = currElement.getValue();
+                Object currValue = currElement.getValue();
                 if (currValue == null) {
                     responseFields[i] = currElement.getKey() + "=";
                 } else {
@@ -1127,7 +1125,7 @@
             final char c = entities[i].charAt(0);
             final String entity = entities[i].substring(1);
             charToEntityMap[c] = entity;
-            entityToCharMap.put(entity, new Character(c));
+            entityToCharMap.put(entity, c);
         }
     }
 
@@ -1325,13 +1323,11 @@
     // utility to convert to int, returns -2 if bogus.
 
     private long toNumeric(String inStr) {
-        long result = -2;
         try {
-            result = java.lang.Long.parseLong(inStr);
+            return java.lang.Long.parseLong(inStr);
         } catch (Exception e) {
             return -2;
         }
-        return result;
     }
 
 
--- a/jdk/src/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java	Wed May 14 18:38:14 2008 +0200
@@ -432,7 +432,7 @@
          */
         private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
 
-            Descriptor clone = null;
+            Descriptor clone;
             if (in == null) {
                 clone = new DescriptorSupport();
                 MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
--- a/jdk/src/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java	Wed May 14 18:38:14 2008 +0200
@@ -393,7 +393,7 @@
          * @exception RuntimeOperationsException if Descriptor is invalid
          */
         private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
-           Descriptor clone = null;
+           Descriptor clone;
             if (in == null) {
                 clone = new DescriptorSupport();
                 MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
--- a/jdk/src/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java	Wed May 14 18:38:14 2008 +0200
@@ -944,7 +944,7 @@
      * @exception RuntimeOperationsException if Descriptor is invalid
      */
     private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
-        Descriptor clone = null;
+        Descriptor clone;
         if (in == null) {
             clone = new DescriptorSupport();
             MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
--- a/jdk/src/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java	Wed May 14 18:38:14 2008 +0200
@@ -328,7 +328,7 @@
      * @exception RuntimeOperationsException if Descriptor is invalid
      */
     private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
-        Descriptor clone = null;
+        Descriptor clone;
         if (in == null) {
             clone = new DescriptorSupport();
             MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
--- a/jdk/src/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java	Wed May 14 18:38:14 2008 +0200
@@ -424,7 +424,7 @@
          */
         private Descriptor validDescriptor(final Descriptor in)
         throws RuntimeOperationsException {
-            Descriptor clone = null;
+            Descriptor clone;
             if (in == null) {
                 clone = new DescriptorSupport();
                 MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
--- a/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java	Wed May 14 18:38:14 2008 +0200
@@ -1425,9 +1425,7 @@
         }
 
         /* Check attributeDescriptor for getMethod */
-        ModelMBeanAttributeInfo attrInfo=null;
-        Descriptor attrDescr=null;
-        Object response = null;
+        Object response;
 
         try {
             if (modelMBeanInfo == null)
@@ -1435,14 +1433,14 @@
                       "getAttribute failed: ModelMBeanInfo not found for "+
                       attrName);
 
-            attrInfo = modelMBeanInfo.getAttribute(attrName);
+            ModelMBeanAttributeInfo attrInfo = modelMBeanInfo.getAttribute(attrName);
             Descriptor mmbDesc = modelMBeanInfo.getMBeanDescriptor();
 
             if (attrInfo == null)
                 throw new AttributeNotFoundException("getAttribute failed:"+
                       " ModelMBeanAttributeInfo not found for " + attrName);
 
-            attrDescr = attrInfo.getDescriptor();
+            Descriptor attrDescr = attrInfo.getDescriptor();
             if (attrDescr != null) {
                 if (!attrInfo.isReadable())
                     throw new AttributeNotFoundException(
@@ -1684,14 +1682,13 @@
             "getAttributes(String[])","Entry");
         }
 
-        AttributeList responseList = null;
         if (attrNames == null)
             throw new RuntimeOperationsException(new
                 IllegalArgumentException("attributeNames must not be null"),
                 "Exception occurred trying to get attributes of a "+
                 "RequiredModelMBean");
 
-        responseList = new AttributeList();
+        AttributeList responseList = new AttributeList();
         for (int i = 0; i < attrNames.length; i++) {
             try {
                 responseList.add(new Attribute(attrNames[i],
@@ -1833,8 +1830,6 @@
                 throw new AttributeNotFoundException("setAttribute failed: "
                                           + attrName + " is not writable ");
 
-            Object setResponse = null;
-
             String attrSetMethod = (String)
                 (attrDescr.getFieldValue("setMethod"));
             String attrGetMethod = (String)
@@ -1873,9 +1868,9 @@
                 }
                 updateDescriptor = true;
             } else {
-                setResponse = invoke(attrSetMethod,
-                                 (new Object[] {attrValue}),
-                                 (new String[] {attrType}) );
+                invoke(attrSetMethod,
+                       (new Object[] {attrValue}),
+                       (new String[] {attrType}) );
             }
 
             /* change cached value */
@@ -2023,8 +2018,6 @@
     private synchronized void writeToLog(String logFileName,
                                          String logEntry) throws Exception {
 
-        PrintStream logOut = null;
-        FileOutputStream fos = null;
         if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
             MODELMBEAN_LOGGER.logp(Level.FINER,
                     RequiredModelMBean.class.getName(),
@@ -2041,9 +2034,9 @@
             return;
         }
 
+        FileOutputStream fos = new FileOutputStream(logFileName, true);
         try {
-            fos = new FileOutputStream(logFileName, true);
-            logOut = new PrintStream(fos);
+            PrintStream logOut = new PrintStream(fos);
             logOut.println(logEntry);
             logOut.close();
             if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
@@ -2062,6 +2055,8 @@
                         logFileName);
             }
             throw e;
+        } finally {
+            fos.close();
         }
     }
 
--- a/jdk/src/share/classes/javax/management/monitor/CounterMonitor.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/monitor/CounterMonitor.java	Wed May 14 18:38:14 2008 +0200
@@ -740,16 +740,16 @@
                 //
                 switch (o.getType()) {
                     case INTEGER:
-                        o.setThreshold(new Integer((int)threshold_value));
+                        o.setThreshold(Integer.valueOf((int)threshold_value));
                         break;
                     case BYTE:
-                        o.setThreshold(new Byte((byte)threshold_value));
+                        o.setThreshold(Byte.valueOf((byte)threshold_value));
                         break;
                     case SHORT:
-                        o.setThreshold(new Short((short)threshold_value));
+                        o.setThreshold(Short.valueOf((short)threshold_value));
                         break;
                     case LONG:
-                        o.setThreshold(new Long(threshold_value));
+                        o.setThreshold(Long.valueOf(threshold_value));
                         break;
                     default:
                         // Should never occur...
@@ -810,10 +810,10 @@
             derived += modulus.longValue();
 
         switch (o.getType()) {
-        case INTEGER: o.setDerivedGauge(new Integer((int) derived)); break;
-        case BYTE: o.setDerivedGauge(new Byte((byte) derived)); break;
-        case SHORT: o.setDerivedGauge(new Short((short) derived)); break;
-        case LONG: o.setDerivedGauge(new Long(derived)); break;
+        case INTEGER: o.setDerivedGauge(Integer.valueOf((int) derived)); break;
+        case BYTE: o.setDerivedGauge(Byte.valueOf((byte) derived)); break;
+        case SHORT: o.setDerivedGauge(Short.valueOf((short) derived)); break;
+        case LONG: o.setDerivedGauge(Long.valueOf(derived)); break;
         default:
             // Should never occur...
             MONITOR_LOGGER.logp(Level.FINEST, CounterMonitor.class.getName(),
--- a/jdk/src/share/classes/javax/management/monitor/GaugeMonitor.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/monitor/GaugeMonitor.java	Wed May 14 18:38:14 2008 +0200
@@ -636,28 +636,28 @@
         Number der;
         switch (o.getType()) {
         case INTEGER:
-            der = new Integer(((Integer)scanGauge).intValue() -
-                              ((Integer)prev).intValue());
+            der = Integer.valueOf(((Integer)scanGauge).intValue() -
+                                  ((Integer)prev).intValue());
             break;
         case BYTE:
-            der = new Byte((byte)(((Byte)scanGauge).byteValue() -
-                                  ((Byte)prev).byteValue()));
+            der = Byte.valueOf((byte)(((Byte)scanGauge).byteValue() -
+                                      ((Byte)prev).byteValue()));
             break;
         case SHORT:
-            der = new Short((short)(((Short)scanGauge).shortValue() -
-                                    ((Short)prev).shortValue()));
+            der = Short.valueOf((short)(((Short)scanGauge).shortValue() -
+                                        ((Short)prev).shortValue()));
             break;
         case LONG:
-            der = new Long(((Long)scanGauge).longValue() -
-                           ((Long)prev).longValue());
+            der = Long.valueOf(((Long)scanGauge).longValue() -
+                               ((Long)prev).longValue());
             break;
         case FLOAT:
-            der = new Float(((Float)scanGauge).floatValue() -
-                            ((Float)prev).floatValue());
+            der = Float.valueOf(((Float)scanGauge).floatValue() -
+                                ((Float)prev).floatValue());
             break;
         case DOUBLE:
-            der = new Double(((Double)scanGauge).doubleValue() -
-                             ((Double)prev).doubleValue());
+            der = Double.valueOf(((Double)scanGauge).doubleValue() -
+                                 ((Double)prev).doubleValue());
             break;
         default:
             // Should never occur...
--- a/jdk/src/share/classes/javax/management/monitor/Monitor.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/monitor/Monitor.java	Wed May 14 18:38:14 2008 +0200
@@ -367,7 +367,7 @@
     /**
      * Constant used to initialize all the numeric values.
      */
-    static final Integer INTEGER_ZERO = new Integer(0);
+    static final Integer INTEGER_ZERO = 0;
 
 
     /*
@@ -1122,12 +1122,12 @@
      */
     private void monitor(ObservedObject o, int index, int an[]) {
 
-        String attribute = null;
+        String attribute;
         String notifType = null;
         String msg = null;
         Object derGauge = null;
         Object trigger = null;
-        ObjectName object = null;
+        ObjectName object;
         Comparable<?> value = null;
         MonitorNotification alarm = null;
 
@@ -1565,7 +1565,7 @@
         final ThreadGroup group;
         final AtomicInteger threadNumber = new AtomicInteger(1);
         final String namePrefix;
-        final String nameSuffix = "]";
+        static final String nameSuffix = "]";
 
         public DaemonThreadFactory(String poolName) {
             SecurityManager s = System.getSecurityManager();
--- a/jdk/src/share/classes/javax/management/openmbean/ArrayType.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/openmbean/ArrayType.java	Wed May 14 18:38:14 2008 +0200
@@ -726,7 +726,7 @@
             value += dimension;
             value += elementType.hashCode();
             value += Boolean.valueOf(primitiveArray).hashCode();
-            myHashCode = new Integer(value);
+            myHashCode = Integer.valueOf(value);
         }
 
         // return always the same hash code for this instance (immutable)
--- a/jdk/src/share/classes/javax/management/openmbean/CompositeType.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/openmbean/CompositeType.java	Wed May 14 18:38:14 2008 +0200
@@ -426,7 +426,7 @@
                 value += key.hashCode();
                 value += this.nameToType.get(key).hashCode();
             }
-            myHashCode = new Integer(value);
+            myHashCode = Integer.valueOf(value);
         }
 
         // return always the same hash code for this instance (immutable)
--- a/jdk/src/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java	Wed May 14 18:38:14 2008 +0200
@@ -769,7 +769,6 @@
                 "array with same dimensions";
             throw new IllegalArgumentException(msg);
         }
-        Class<?> targetComponentClass = targetArrayClass.getComponentType();
         OpenType<?> componentOpenType;
         if (dim == 1)
             componentOpenType = baseType;
--- a/jdk/src/share/classes/javax/management/openmbean/OpenMBeanConstructorInfoSupport.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/openmbean/OpenMBeanConstructorInfoSupport.java	Wed May 14 18:38:14 2008 +0200
@@ -252,7 +252,7 @@
             int value = 0;
             value += this.getName().hashCode();
             value += Arrays.asList(this.getSignature()).hashCode();
-            myHashCode = new Integer(value);
+            myHashCode = Integer.valueOf(value);
         }
 
         // return always the same hash code for this instance (immutable)
--- a/jdk/src/share/classes/javax/management/openmbean/OpenMBeanInfoSupport.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/openmbean/OpenMBeanInfoSupport.java	Wed May 14 18:38:14 2008 +0200
@@ -347,7 +347,7 @@
             value += arraySetHash(this.getConstructors());
             value += arraySetHash(this.getOperations());
             value += arraySetHash(this.getNotifications());
-            myHashCode = new Integer(value);
+            myHashCode = Integer.valueOf(value);
         }
 
         // return always the same hash code for this instance (immutable)
--- a/jdk/src/share/classes/javax/management/openmbean/SimpleType.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/openmbean/SimpleType.java	Wed May 14 18:38:14 2008 +0200
@@ -257,7 +257,7 @@
         // Calculate the hash code value if it has not yet been done (ie 1st call to hashCode())
         //
         if (myHashCode == null) {
-            myHashCode = new Integer(this.getClassName().hashCode());
+            myHashCode = Integer.valueOf(this.getClassName().hashCode());
         }
 
         // return always the same hash code for this instance (immutable)
--- a/jdk/src/share/classes/javax/management/openmbean/TabularType.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/openmbean/TabularType.java	Wed May 14 18:38:14 2008 +0200
@@ -332,7 +332,7 @@
             for (Iterator k = indexNames.iterator(); k.hasNext();  ) {
                 value += k.next().hashCode();
             }
-            myHashCode = new Integer(value);
+            myHashCode = Integer.valueOf(value);
         }
 
         // return always the same hash code for this instance (immutable)
--- a/jdk/src/share/classes/javax/management/relation/RelationNotification.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/relation/RelationNotification.java	Wed May 14 18:38:14 2008 +0200
@@ -369,7 +369,7 @@
      * @return a {@link List} of {@link ObjectName}.
      */
     public List<ObjectName> getMBeansToUnregister() {
-        List<ObjectName> result = null;
+        List<ObjectName> result;
         if (unregisterMBeanList != null) {
             result = new ArrayList<ObjectName>(unregisterMBeanList);
         } else {
@@ -397,7 +397,7 @@
      * @return the old value of the updated role.
      */
     public List<ObjectName> getOldRoleValue() {
-        List<ObjectName> result = null;
+        List<ObjectName> result;
         if (oldRoleValue != null) {
             result = new ArrayList<ObjectName>(oldRoleValue);
         } else {
@@ -412,7 +412,7 @@
      * @return the new value of the updated role.
      */
     public List<ObjectName> getNewRoleValue() {
-        List<ObjectName> result = null;
+        List<ObjectName> result;
         if (newRoleValue != null) {
             result = new ArrayList<ObjectName>(newRoleValue);
         } else {
--- a/jdk/src/share/classes/javax/management/relation/RelationService.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/relation/RelationService.java	Wed May 14 18:38:14 2008 +0200
@@ -35,6 +35,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.concurrent.atomic.AtomicLong;
 import java.util.logging.Level;
 
 import javax.management.Attribute;
@@ -122,7 +123,7 @@
     // Internal counter to provide sequence numbers for notifications sent by:
     // - the Relation Service
     // - a relation handled by the Relation Service
-    private Long myNtfSeqNbrCounter = new Long(0);
+    private final AtomicLong atomicSeqNo = new AtomicLong();
 
     // ObjectName used to register the Relation Service in the MBean Server
     private ObjectName myObjName = null;
@@ -256,19 +257,6 @@
         return;
     }
 
-    // Returns internal counter to be used for Sequence Numbers of
-    // notifications to be raised by:
-    // - a relation handled by this Relation Service (when updated)
-    // - the Relation Service
-    private Long getNotificationSequenceNumber() {
-        Long result = null;
-        synchronized(myNtfSeqNbrCounter) {
-            result = new Long(myNtfSeqNbrCounter.longValue() + 1);
-            myNtfSeqNbrCounter = new Long(result.longValue());
-        }
-        return result;
-    }
-
     //
     // Relation type handling
     //
@@ -369,7 +357,7 @@
      * @return ArrayList of relation type names (Strings)
      */
     public List<String> getAllRelationTypeNames() {
-        ArrayList<String> result = null;
+        ArrayList<String> result;
         synchronized(myRelType2ObjMap) {
             result = new ArrayList<String>(myRelType2ObjMap.keySet());
         }
@@ -684,7 +672,7 @@
         // Can throw InstanceNotFoundException (but detected above)
         // No MBeanException as no exception raised by this method, and no
         // ReflectionException
-        String relId = null;
+        String relId;
         try {
             relId = (String)(myMBeanServer.getAttribute(relationObjectName,
                                                         "RelationId"));
@@ -707,7 +695,7 @@
         // Can throw InstanceNotFoundException (but detected above)
         // No MBeanException as no exception raised by this method, no
         // ReflectionException
-        ObjectName relServObjName = null;
+        ObjectName relServObjName;
         try {
             relServObjName = (ObjectName)
                 (myMBeanServer.getAttribute(relationObjectName,
@@ -737,7 +725,7 @@
         // Can throw InstanceNotFoundException (but detected above)
         // No MBeanException as no exception raised by this method, no
         // ReflectionException
-        String relTypeName = null;
+        String relTypeName;
         try {
             relTypeName = (String)(myMBeanServer.getAttribute(relationObjectName,
                                                               "RelationTypeName"));
@@ -758,7 +746,7 @@
         // Can throw InstanceNotFoundException (but detected above)
         // No MBeanException as no exception raised by this method, no
         // ReflectionException
-        RoleList roleList = null;
+        RoleList roleList;
         try {
             roleList = (RoleList)(myMBeanServer.invoke(relationObjectName,
                                                        "retrieveAllRoles",
@@ -912,7 +900,7 @@
      * @return ArrayList of String
      */
     public List<String> getAllRelationIds() {
-        List<String> result = null;
+        List<String> result;
         synchronized(myRelId2ObjMap) {
             result = new ArrayList<String>(myRelId2ObjMap.keySet());
         }
@@ -948,7 +936,7 @@
         RELATION_LOGGER.entering(RelationService.class.getName(),
                 "checkRoleReading", new Object[] {roleName, relationTypeName});
 
-        Integer result = null;
+        Integer result;
 
         // Can throw a RelationTypeNotFoundException
         RelationType relType = getRelationType(relationTypeName);
@@ -965,7 +953,7 @@
                                    false);
 
         } catch (RoleInfoNotFoundException exc) {
-            result = new Integer(RoleStatus.NO_ROLE_WITH_NAME);
+            result = Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME);
         }
 
         RELATION_LOGGER.exiting(RelationService.class.getName(),
@@ -1021,13 +1009,13 @@
             writeChkFlag = false;
         }
 
-        RoleInfo roleInfo = null;
+        RoleInfo roleInfo;
         try {
             roleInfo = relType.getRoleInfo(roleName);
         } catch (RoleInfoNotFoundException exc) {
             RELATION_LOGGER.exiting(RelationService.class.getName(),
                     "checkRoleWriting");
-            return new Integer(RoleStatus.NO_ROLE_WITH_NAME);
+            return Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME);
         }
 
         Integer result = checkRoleInt(2,
@@ -1436,7 +1424,7 @@
 
         // Relation id to relation type name map
         // First retrieves the relation type name
-        String relTypeName = null;
+        String relTypeName;
         synchronized(myRelId2RelTypeMap) {
             relTypeName = myRelId2RelTypeMap.get(relationId);
             myRelId2RelTypeMap.remove(relationId);
@@ -1641,7 +1629,7 @@
 
                 // List of relation ids of interest regarding the selected
                 // relation type
-                List<String> relIdList = null;
+                List<String> relIdList;
                 if (relationTypeName == null) {
                     // Considers all relations
                     relIdList = new ArrayList<String>(allRelIdSet);
@@ -1655,7 +1643,7 @@
                     for (String currRelId : allRelIdSet) {
 
                         // Retrieves its relation type
-                        String currRelTypeName = null;
+                        String currRelTypeName;
                         synchronized(myRelId2RelTypeMap) {
                             currRelTypeName =
                                 myRelId2RelTypeMap.get(currRelId);
@@ -1952,7 +1940,7 @@
         // Can throw a RelationNotFoundException
         Object relObj = getRelation(relationId);
 
-        RoleResult result = null;
+        RoleResult result;
 
         if (relObj instanceof RelationSupport) {
             // Internal relation
@@ -2022,7 +2010,7 @@
         // Can throw a RelationNotFoundException
         Object relObj = getRelation(relationId);
 
-        RoleResult result = null;
+        RoleResult result;
 
         if (relObj instanceof RelationSupport) {
             // Internal relation
@@ -2073,7 +2061,7 @@
         // Can throw a RelationNotFoundException
         Object relObj = getRelation(relationId);
 
-        Integer result = null;
+        Integer result;
 
         if (relObj instanceof RelationSupport) {
             // Internal relation
@@ -2268,7 +2256,7 @@
         // Can throw a RelationNotFoundException
         Object relObj = getRelation(relationId);
 
-        RoleResult result = null;
+        RoleResult result;
 
         if (relObj instanceof RelationSupport) {
             // Internal relation
@@ -2390,7 +2378,7 @@
         // Can throw a RelationNotFoundException
         Object relObj = getRelation(relationId);
 
-        String result = null;
+        String result;
 
         if (relObj instanceof RelationSupport) {
             // Internal relation
@@ -2473,7 +2461,7 @@
 
                 // Note: do both tests as a relation can be an MBean and be
                 //       itself referenced in another relation :)
-                String relId = null;
+                String relId;
                 synchronized(myRelMBeanObjName2RelIdMap){
                     relId = myRelMBeanObjName2RelIdMap.get(mbeanName);
                 }
@@ -2511,9 +2499,6 @@
         RELATION_LOGGER.entering(RelationService.class.getName(),
                 "getNotificationInfo");
 
-        MBeanNotificationInfo[] ntfInfoArray =
-            new MBeanNotificationInfo[1];
-
         String ntfClass = "javax.management.relation.RelationNotification";
 
         String[] ntfTypes = new String[] {
@@ -2615,7 +2600,7 @@
                 "getRelationType", relationTypeName);
 
         // No null relation type accepted, so can use get()
-        RelationType relType = null;
+        RelationType relType;
         synchronized(myRelType2ObjMap) {
             relType = (myRelType2ObjMap.get(relationTypeName));
         }
@@ -2659,7 +2644,7 @@
                 "getRelation", relationId);
 
         // No null relation  accepted, so can use get()
-        Object rel = null;
+        Object rel;
         synchronized(myRelId2ObjMap) {
             rel = myRelId2ObjMap.get(relationId);
         }
@@ -3077,7 +3062,7 @@
                 // Retrieves corresponding role info
                 // Can throw a RoleInfoNotFoundException to be converted into a
                 // RoleNotFoundException
-                RoleInfo roleInfo = null;
+                RoleInfo roleInfo;
                 try {
                     roleInfo = relType.getRoleInfo(currRoleName);
                 } catch (RoleInfoNotFoundException exc) {
@@ -3227,7 +3212,7 @@
         if (!(roleName.equals(expName))) {
             RELATION_LOGGER.exiting(RelationService.class.getName(),
                     "checkRoleInt");
-            return new Integer(RoleStatus.NO_ROLE_WITH_NAME);
+            return Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME);
         }
 
         // Checks read access if required
@@ -3572,7 +3557,7 @@
         // Relation type name
         // Note: do not use getRelationTypeName() as if it is a relation MBean
         //       it is already unregistered.
-        String relTypeName = null;
+        String relTypeName;
         synchronized(myRelId2RelTypeMap) {
             relTypeName = (myRelId2RelTypeMap.get(relationId));
         }
@@ -3609,7 +3594,7 @@
         }
 
         // Sequence number
-        Long seqNbr = getNotificationSequenceNumber();
+        Long seqNo = atomicSeqNo.incrementAndGet();
 
         // Timestamp
         Date currDate = new Date();
@@ -3625,7 +3610,7 @@
             // Creation or removal
             ntf = new RelationNotification(ntfType,
                                            this,
-                                           seqNbr.longValue(),
+                                           seqNo.longValue(),
                                            timeStamp,
                                            message,
                                            relationId,
@@ -3640,7 +3625,7 @@
                 // Update
                 ntf = new RelationNotification(ntfType,
                                                this,
-                                               seqNbr.longValue(),
+                                               seqNo.longValue(),
                                                timeStamp,
                                                message,
                                                relationId,
@@ -3732,7 +3717,7 @@
             //
             // Shall not throw RelationTypeNotFoundException or
             // RoleInfoNotFoundException
-            RoleInfo currRoleInfo = null;
+            RoleInfo currRoleInfo;
             try {
                 currRoleInfo = getRoleInfo(currRelTypeName,
                                            currRoleName);
--- a/jdk/src/share/classes/javax/management/relation/RelationSupport.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/relation/RelationSupport.java	Wed May 14 18:38:14 2008 +0200
@@ -34,6 +34,7 @@
 import java.util.Map;
 import java.util.List;
 
+import java.util.concurrent.atomic.AtomicBoolean;
 import static com.sun.jmx.defaults.JmxProperties.RELATION_LOGGER;
 import static com.sun.jmx.mbeanserver.Util.cast;
 import javax.management.InstanceNotFoundException;
@@ -110,7 +111,7 @@
     private Map<String,Role> myRoleName2ValueMap = new HashMap<String,Role>();
 
     // Flag to indicate if the object has been added in the Relation Service
-    private Boolean myInRelServFlg = null;
+    private final AtomicBoolean myInRelServFlg = new AtomicBoolean();
 
     //
     // Constructors
@@ -403,7 +404,7 @@
                 "getRoleCardinality", roleName);
 
         // Try to retrieve the role
-        Role role = null;
+        Role role;
         synchronized(myRoleName2ValueMap) {
             // No null Role is allowed, so direct use of get()
             role = (myRoleName2ValueMap.get(roleName));
@@ -427,7 +428,7 @@
 
         RELATION_LOGGER.exiting(RelationSupport.class.getName(),
                 "getRoleCardinality");
-        return new Integer(roleValue.size());
+        return roleValue.size();
     }
 
     /**
@@ -701,11 +702,7 @@
      * the Relation Service.
      */
     public Boolean isInRelationService() {
-        Boolean result = null;
-        synchronized(myInRelServFlg) {
-            result = Boolean.valueOf(myInRelServFlg.booleanValue());
-        }
-        return result;
+        return myInRelServFlg.get();
     }
 
     public void setRelationServiceManagementFlag(Boolean flag)
@@ -715,10 +712,7 @@
             String excMsg = "Invalid parameter.";
             throw new IllegalArgumentException(excMsg);
         }
-        synchronized(myInRelServFlg) {
-            myInRelServFlg = Boolean.valueOf(flag.booleanValue());
-        }
-        return;
+        myInRelServFlg.set(flag);
     }
 
     //
@@ -790,7 +784,7 @@
 
         int pbType = 0;
 
-        Role role = null;
+        Role role;
         synchronized(myRoleName2ValueMap) {
             // No null Role is allowed, so direct use of get()
             role = (myRoleName2ValueMap.get(roleName));
@@ -801,7 +795,7 @@
 
         } else {
             // Checks if the role is readable
-            Integer status = null;
+            Integer status;
 
             if (relationServCallFlg) {
 
@@ -851,7 +845,7 @@
             pbType = status.intValue();
         }
 
-        Object result = null;
+        Object result;
 
         if (pbType == 0) {
             // Role can be retrieved
@@ -937,7 +931,7 @@
         for (int i = 0; i < roleNameArray.length; i++) {
             String currRoleName = roleNameArray[i];
 
-            Object currResult = null;
+            Object currResult;
 
             // Can throw RelationServiceNotRegisteredException
             //
@@ -1102,13 +1096,13 @@
         // handle initialization of role when creating the relation
         // (roles provided in the RoleList parameter are directly set but
         // roles automatically initialized are set using setRole())
-        Role role = null;
+        Role role;
         synchronized(myRoleName2ValueMap) {
             role = (myRoleName2ValueMap.get(roleName));
         }
 
         List<ObjectName> oldRoleValue;
-        Boolean initFlg = null;
+        Boolean initFlg;
 
         if (role == null) {
             initFlg = true;
@@ -1122,7 +1116,7 @@
         // Checks if the role can be set: is writable (except if
         // initialization) and correct value
         try {
-            Integer status = null;
+            Integer status;
 
             if (relationServCallFlg) {
 
@@ -1314,7 +1308,7 @@
             Object[] params = new Object[3];
             params[0] = myRelId;
             params[1] = newRole;
-            params[2] = ((ArrayList)oldRoleValue);
+            params[2] = oldRoleValue;
             String[] signature = new String[3];
             signature[0] = "java.lang.String";
             signature[1] = "javax.management.relation.Role";
@@ -1598,7 +1592,6 @@
         myRelTypeName = relationTypeName;
         // Can throw InvalidRoleValueException
         initRoleMap(list);
-        myInRelServFlg = Boolean.FALSE;
 
         RELATION_LOGGER.exiting(RelationSupport.class.getName(), "initMembers");
         return;
@@ -1710,7 +1703,7 @@
                 roleName, relationServCallFlg, relationServ});
 
         // Retrieves current role value
-        Role role = null;
+        Role role;
         synchronized(myRoleName2ValueMap) {
             role = (myRoleName2ValueMap.get(roleName));
         }
--- a/jdk/src/share/classes/javax/management/remote/JMXConnectorFactory.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/remote/JMXConnectorFactory.java	Wed May 14 18:38:14 2008 +0200
@@ -435,7 +435,7 @@
 
         Iterator<JMXConnectorProvider> providers =
                 getProviderIterator(JMXConnectorProvider.class, loader);
-        JMXConnector connection = null;
+        JMXConnector connection;
         IOException exception = null;
         while(providers.hasNext()) {
             try {
@@ -450,7 +450,7 @@
                                  "] Service provider exception: " + e);
                 if (!(e instanceof MalformedURLException)) {
                     if (exception == null) {
-                        if (exception instanceof IOException) {
+                        if (e instanceof IOException) {
                             exception = (IOException) e;
                         } else {
                             exception = EnvHelp.initCause(
--- a/jdk/src/share/classes/javax/management/remote/JMXConnectorServerFactory.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/remote/JMXConnectorServerFactory.java	Wed May 14 18:38:14 2008 +0200
@@ -215,12 +215,10 @@
                 JMXConnectorFactory.
                 getProviderIterator(JMXConnectorServerProvider.class, loader);
 
-        JMXConnectorServer connection = null;
         IOException exception = null;
         while (providers.hasNext()) {
             try {
-                connection = providers.next().newJMXConnectorServer(url, map, mbs);
-                return connection;
+                return providers.next().newJMXConnectorServer(url, map, mbs);
             } catch (JMXProviderException e) {
                 throw e;
             } catch (Exception e) {
@@ -230,7 +228,7 @@
                                  "] Service provider exception: " + e);
                 if (!(e instanceof MalformedURLException)) {
                     if (exception == null) {
-                        if (exception instanceof IOException) {
+                        if (e instanceof IOException) {
                             exception = (IOException) e;
                         } else {
                             exception = EnvHelp.initCause(
--- a/jdk/src/share/classes/javax/management/remote/JMXServiceURL.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/remote/JMXServiceURL.java	Wed May 14 18:38:14 2008 +0200
@@ -162,8 +162,6 @@
                                             requiredPrefix);
         }
 
-        int[] ptr = new int[1];
-
         // Parse the protocol name
         final int protoStart = requiredPrefixLength;
         final int protoEnd = indexOf(serviceURL, ':', protoStart);
@@ -664,11 +662,6 @@
         hostNameBitSet.set('.');
     }
 
-    private static void addCharsToBitSet(BitSet set, String chars) {
-        for (int i = 0; i < chars.length(); i++)
-            set.set(chars.charAt(i));
-    }
-
     /**
      * The value returned by {@link #getProtocol()}.
      */
--- a/jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/remote/rmi/RMIConnector.java	Wed May 14 18:38:14 2008 +0200
@@ -1376,12 +1376,12 @@
 
         protected Integer addListenerForMBeanRemovedNotif()
                 throws IOException, InstanceNotFoundException {
-            MarshalledObject<NotificationFilter> sFilter = null;
             NotificationFilterSupport clientFilter =
                 new NotificationFilterSupport();
             clientFilter.enableType(
                 MBeanServerNotification.UNREGISTRATION_NOTIFICATION);
-            sFilter = new MarshalledObject<NotificationFilter>(clientFilter);
+            MarshalledObject<NotificationFilter> sFilter =
+                new MarshalledObject<NotificationFilter>(clientFilter);
 
             Integer[] listenerIDs;
             final ObjectName[] names =
@@ -1434,7 +1434,7 @@
                                               connectionId,
                                               clientNotifCounter++,
                                               message,
-                                              new Long(number));
+                                              Long.valueOf(number));
             sendNotification(n);
         }
     }
@@ -1593,7 +1593,7 @@
 
         protected void doStart() throws IOException {
             // Get RMIServer stub from directory or URL encoding if needed.
-            RMIServer stub = null;
+            RMIServer stub;
             try {
                 stub = (rmiServer!=null)?rmiServer:
                     findRMIServer(jmxServiceURL, env);
@@ -2532,7 +2532,7 @@
      * A static WeakReference to an {@link org.omg.CORBA.ORB ORB} to
      * connect unconnected stubs.
      **/
-    private static WeakReference<ORB> orb = null;
+    private static volatile WeakReference<ORB> orb = null;
 
     // TRACES & DEBUG
     //---------------
--- a/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java	Wed May 14 18:38:14 2008 +0200
@@ -365,7 +365,7 @@
                 // Access file property specified, create an instance
                 // of the MBeanServerFileAccessController class
                 //
-                MBeanServerForwarder mbsf = null;
+                MBeanServerForwarder mbsf;
                 try {
                     mbsf = new MBeanServerFileAccessController(accessFile);
                 } catch (IOException e) {
--- a/jdk/src/share/classes/javax/management/timer/Timer.java	Mon May 12 18:06:23 2008 -0700
+++ b/jdk/src/share/classes/javax/management/timer/Timer.java	Wed May 14 18:38:14 2008 +0200
@@ -344,13 +344,11 @@
         //
         if (isActive == true) {
 
-            TimerAlarmClock alarmClock;
-
             for (Object[] obj : timerTable.values()) {
 
                 // Stop all the TimerAlarmClock.
                 //
-                alarmClock = (TimerAlarmClock)obj[ALARM_CLOCK_INDEX];
+                TimerAlarmClock alarmClock = (TimerAlarmClock)obj[ALARM_CLOCK_INDEX];
                 if (alarmClock != null) {
 //                     alarmClock.interrupt();
 //                     try {
@@ -364,7 +362,6 @@
 //                     //
 
                     alarmClock.cancel();
-                    alarmClock = null;
                 }
             }
 
@@ -458,8 +455,7 @@
 
         // Create and add the timer notification into the timer table.
         //
-        Integer notifID = null;
-        notifID = new Integer(++counterID);
+        Integer notifID = new Integer(++counterID);
 
         // The sequenceNumber and the timeStamp attributes are updated
         // when the notification is emitted by the timer.
@@ -486,8 +482,8 @@
 
         obj[TIMER_NOTIF_INDEX] = (Object)notif;
         obj[TIMER_DATE_INDEX] = (Object)d;
-        obj[TIMER_PERIOD_INDEX] = (Object) new Long(period);
-        obj[TIMER_NB_OCCUR_INDEX] = (Object) new Long(nbOccurences);
+        obj[TIMER_PERIOD_INDEX] = (Object) period;
+        obj[TIMER_NB_OCCUR_INDEX] = (Object) nbOccurences;
         obj[ALARM_CLOCK_INDEX] = (Object)alarmClock;
         obj[FIXED_RATE_INDEX] = Boolean.valueOf(fixedRate);
 
@@ -678,7 +674,6 @@
 //             // Remove the reference on the TimerAlarmClock.
 //             //
             alarmClock.cancel();
-            alarmClock = null;
         }
 
         // Remove the timer notification from the timer table.
@@ -755,7 +750,6 @@
                   //
 //             }
             alarmClock.cancel();
-            alarmClock = null;
         }
 
         // Remove all the timer notifications from the timer table.
@@ -906,8 +900,7 @@
 
         Object[] obj = timerTable.get(id);
         if (obj != null) {
-            Long period = (Long)obj[TIMER_PERIOD_INDEX];
-            return (new Long(period.longValue()));
+            return (Long)obj[TIMER_PERIOD_INDEX];
         }
         return null;
     }
@@ -924,8 +917,7 @@
 
         Object[] obj = timerTable.get(id);
         if (obj != null) {
-            Long nbOccurences = (Long)obj[TIMER_NB_OCCUR_INDEX];
-            return (new Long(nbOccurences.longValue()));
+            return (Long)obj[TIMER_NB_OCCUR_INDEX];
         }
         return null;
     }
@@ -1096,7 +1088,7 @@
             if ((nbOccurences.longValue() == 0) || (nbOccurences.longValue() > 1)) {
 
                 date.setTime(date.getTime() + period.longValue());
-                obj[TIMER_NB_OCCUR_INDEX] = new Long(java.lang.Math.max(0L, (nbOccurences.longValue() - 1)));
+                obj[TIMER_NB_OCCUR_INDEX] = Long.valueOf(java.lang.Math.max(0L, (nbOccurences.longValue() - 1)));
                 nbOccurences = (Long)obj[TIMER_NB_OCCUR_INDEX];
 
                 if (isActive == true) {
@@ -1146,9 +1138,6 @@
 //                         // Ignore...
 //                     }
                     alarmClock.cancel();
-                    // Remove the reference on the TimerAlarmClock.
-                    //
-                    alarmClock = null;
                 }
                 timerTable.remove(notifID);
             }
@@ -1165,10 +1154,6 @@
 //                 }
 
                    alarmClock.cancel();
-
-                // Remove the reference on the TimerAlarmClock.
-                //
-                alarmClock = null;
             }
             timerTable.remove(notifID);
         }