1.1 --- a/.hgtags Wed May 21 10:59:07 2008 +0400
1.2 +++ b/.hgtags Tue Jun 03 11:18:33 2008 -0700
1.3 @@ -1,3 +1,4 @@
1.4 37a05a11f281b4d238e2f9e7ebb67c63f64d0e77 jdk7-b24
1.5 75fca0b0ab83ab1392e615910cea020f66535390 jdk7-b25
1.6 fb57027902e04ecafceae31a605e69b436c23d57 jdk7-b26
1.7 +3e599d98875ddf919c8ea11cff9b3a99ba631a9b jdk7-b27
2.1 --- a/make/common/shared/Defs-utils.gmk Wed May 21 10:59:07 2008 +0400
2.2 +++ b/make/common/shared/Defs-utils.gmk Tue Jun 03 11:18:33 2008 -0700
2.3 @@ -148,13 +148,15 @@
2.4 ECHO = $(UNIXCOMMAND_PATH)echo -e
2.5 ZIPEXE = $(UNIXCOMMAND_PATH)zip
2.6 UNZIP = $(UNIXCOMMAND_PATH)unzip
2.7 + # Some CYGWIN nawk versions require BINMODE=w for proper '\r' interpretation
2.8 + NAWK = $(UNIXCOMMAND_PATH)awk -v BINMODE=w
2.9 else
2.10 ZIPEXE = $(UTILS_DEVTOOL_PATH)zip
2.11 UNZIP = $(UTILS_DEVTOOL_PATH)unzip
2.12 + NAWK = $(UNIXCOMMAND_PATH)awk
2.13 endif
2.14 # Re-define some utilities
2.15 LEX =# override GNU Make intrinsic: no lex on windows
2.16 - NAWK = $(UNIXCOMMAND_PATH)awk
2.17 endif
2.18
2.19 # Linux specific
3.1 --- a/make/java/java/Makefile Wed May 21 10:59:07 2008 +0400
3.2 +++ b/make/java/java/Makefile Tue Jun 03 11:18:33 2008 -0700
3.3 @@ -394,7 +394,7 @@
3.4 $(GENSRCDIR)/sun/util/CoreResourceBundleControl.java: \
3.5 $(SHARE_SRC)/classes/sun/util/CoreResourceBundleControl-XLocales.java $(LOCALES_GEN_SH)
3.6 @$(prep-target)
3.7 - NAWK=$(NAWK) SED=$(SED) $(SH) $(LOCALES_GEN_SH) "$(JRE_NONEXIST_LOCALES)" \
3.8 + NAWK="$(NAWK)" SED="$(SED)" $(SH) $(LOCALES_GEN_SH) "$(JRE_NONEXIST_LOCALES)" \
3.9 $< $@
3.10 clean::
3.11 $(RM) $(GENSRCDIR)/sun/util/CoreResourceBundleControl.java
4.1 --- a/make/java/nio/Makefile Wed May 21 10:59:07 2008 +0400
4.2 +++ b/make/java/nio/Makefile Tue Jun 03 11:18:33 2008 -0700
4.3 @@ -191,7 +191,7 @@
4.4
4.5 GEN_BUFFER_SH = genBuffer.sh
4.6
4.7 -GEN_BUFFER_CMD = SPP="$(SPP_CMD)" NAWK=$(NAWK) SED=$(SED) SH=$(SH) \
4.8 +GEN_BUFFER_CMD = SPP="$(SPP_CMD)" NAWK="$(NAWK)" SED="$(SED)" SH="$(SH)" \
4.9 $(SH) $(GEN_BUFFER_SH)
4.10
4.11 # Public abstract buffer classes
4.12 @@ -582,7 +582,7 @@
4.13
4.14 GEN_CODER_SH = genCoder.sh
4.15
4.16 -GEN_CODER_CMD = SPP="$(SPP_CMD)" SED=$(SED) NAWK=$(NAWK) SH=$(SH) $(SH) $(GEN_CODER_SH)
4.17 +GEN_CODER_CMD = SPP="$(SPP_CMD)" SED="$(SED)" NAWK="$(NAWK)" SH="$(SH)" $(SH) $(GEN_CODER_SH)
4.18
4.19 $(CS_GEN)/CharsetDecoder.java: $(CS_SRC)/Charset-X-Coder.java $(GEN_CODER_SH)
4.20 $(prep-target)
4.21 @@ -602,7 +602,7 @@
4.22
4.23 GEN_EX_SH = genExceptions.sh
4.24
4.25 -GEN_EX_CMD = NAWK=$(NAWK) SH=$(SH) $(SH) $(GEN_EX_SH)
4.26 +GEN_EX_CMD = NAWK="$(NAWK)" SH="$(SH)" $(SH) $(GEN_EX_SH)
4.27
4.28 $(CH_GEN)/%Exception.java: genExceptions.sh $(CH_SRC)/exceptions
4.29 $(prep-target)
4.30 @@ -635,7 +635,7 @@
4.31 $(HASHER_JARFILE) $(SCS_SRC)/standard-charsets
4.32 $(prep-target)
4.33 @$(RM) $@.temp
4.34 - NAWK=$(NAWK) TEMPDIR=$(TEMPDIR) SH=$(SH) \
4.35 + NAWK="$(NAWK)" TEMPDIR="$(TEMPDIR)" SH="$(SH)" \
4.36 HASHER="$(BOOT_JAVA_CMD) -jar $(HASHER_JARFILE)" \
4.37 $(SH) -e genCharsetProvider.sh $(SCS_SRC)/standard-charsets $(SCS_GEN)
4.38
5.1 --- a/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java Wed May 21 10:59:07 2008 +0400
5.2 +++ b/src/share/classes/com/sun/jmx/interceptor/DefaultMBeanServerInterceptor.java Tue Jun 03 11:18:33 2008 -0700
5.3 @@ -233,7 +233,6 @@
5.4 MBeanRegistrationException, MBeanException,
5.5 NotCompliantMBeanException, InstanceNotFoundException {
5.6
5.7 - ObjectName logicalName = name;
5.8 Class theClass;
5.9
5.10 if (className == null) {
5.11 @@ -519,8 +518,7 @@
5.12 QueryExp query) {
5.13 // Query the MBeans on the repository
5.14 //
5.15 - Set<NamedObject> list = null;
5.16 - list = repository.query(name, query);
5.17 + Set<NamedObject> list = repository.query(name, query);
5.18
5.19 if (queryByRepo) {
5.20 // The repository performs the filtering
5.21 @@ -576,8 +574,7 @@
5.22 private Set<ObjectName> queryNamesImpl(ObjectName name, QueryExp query) {
5.23 // Query the MBeans on the repository
5.24 //
5.25 - Set<NamedObject> list = null;
5.26 - list = repository.query(name, query);
5.27 + Set<NamedObject> list = repository.query(name, query);
5.28
5.29 if (queryByRepo) {
5.30 // The repository performs the filtering
5.31 @@ -1042,7 +1039,7 @@
5.32 if (registerFailed && moi instanceof DynamicMBean2)
5.33 ((DynamicMBean2) moi).registerFailed();
5.34 try {
5.35 - moi.postRegister(new Boolean(registrationDone));
5.36 + moi.postRegister(registrationDone);
5.37 } catch (RuntimeException e) {
5.38 throw new RuntimeMBeanException(e,
5.39 "RuntimeException thrown in postRegister method");
5.40 @@ -1094,8 +1091,7 @@
5.41 IllegalArgumentException("Object name cannot be null"),
5.42 "Exception occurred trying to get an MBean");
5.43 }
5.44 - DynamicMBean obj = null;
5.45 - obj = repository.retrieve(name);
5.46 + DynamicMBean obj = repository.retrieve(name);
5.47 if (obj == null) {
5.48 if (MBEANSERVER_LOGGER.isLoggable(Level.FINER)) {
5.49 MBEANSERVER_LOGGER.logp(Level.FINER,
5.50 @@ -1568,7 +1564,6 @@
5.51 query.setMBeanServer(server);
5.52 try {
5.53 for (NamedObject no : list) {
5.54 - final DynamicMBean obj = no.getObject();
5.55 boolean res;
5.56 try {
5.57 res = query.apply(no.getName());
6.1 --- a/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java Wed May 21 10:59:07 2008 +0400
6.2 +++ b/src/share/classes/com/sun/jmx/mbeanserver/MBeanInstantiator.java Tue Jun 03 11:18:33 2008 -0700
6.3 @@ -205,7 +205,7 @@
6.4 */
6.5 public Object instantiate(Class theClass)
6.6 throws ReflectionException, MBeanException {
6.7 - Object moi = null;
6.8 + Object moi;
6.9
6.10
6.11 // ------------------------------
6.12 @@ -265,7 +265,7 @@
6.13 // ------------------------------
6.14 // ------------------------------
6.15 final Class[] tab;
6.16 - Object moi= null;
6.17 + Object moi;
6.18 try {
6.19 // Build the signature of the method
6.20 //
6.21 @@ -283,8 +283,7 @@
6.22 }
6.23
6.24 // Query the metadata service to get the right constructor
6.25 - Constructor cons = null;
6.26 - cons = findConstructor(theClass, tab);
6.27 + Constructor cons = findConstructor(theClass, tab);
6.28
6.29 if (cons == null) {
6.30 throw new ReflectionException(new
6.31 @@ -408,7 +407,7 @@
6.32 throw new RuntimeOperationsException(new
6.33 IllegalArgumentException(), "Null className passed in parameter");
6.34 }
6.35 - Class theClass = null;
6.36 + Class theClass;
6.37 if (loaderName == null) {
6.38 // Load the class using the agent class loader
6.39 theClass = findClass(className, loader);
6.40 @@ -621,7 +620,7 @@
6.41 static Class loadClass(String className, ClassLoader loader)
6.42 throws ReflectionException {
6.43
6.44 - Class theClass = null;
6.45 + Class theClass;
6.46 if (className == null) {
6.47 throw new RuntimeOperationsException(new
6.48 IllegalArgumentException("The class name cannot be null"),
7.1 --- a/src/share/classes/com/sun/jmx/mbeanserver/Repository.java Wed May 21 10:59:07 2008 +0400
7.2 +++ b/src/share/classes/com/sun/jmx/mbeanserver/Repository.java Tue Jun 03 11:18:33 2008 -0700
7.3 @@ -89,7 +89,6 @@
7.4
7.5 /* This class is used to match an ObjectName against a pattern. */
7.6 private final static class ObjectNamePattern {
7.7 - private final char[] domain;
7.8 private final String[] keys;
7.9 private final String[] values;
7.10 private final String properties;
7.11 @@ -106,8 +105,7 @@
7.12 * @param pattern The ObjectName pattern under examination.
7.13 **/
7.14 public ObjectNamePattern(ObjectName pattern) {
7.15 - this(pattern.getDomain(),
7.16 - pattern.isPropertyListPattern(),
7.17 + this(pattern.isPropertyListPattern(),
7.18 pattern.isPropertyValuePattern(),
7.19 pattern.getCanonicalKeyPropertyListString(),
7.20 pattern.getKeyPropertyList(),
7.21 @@ -124,13 +122,11 @@
7.22 * @param keyPropertyList pattern.getKeyPropertyList().
7.23 * @param pattern The ObjectName pattern under examination.
7.24 **/
7.25 - ObjectNamePattern(String domain,
7.26 - boolean propertyListPattern,
7.27 + ObjectNamePattern(boolean propertyListPattern,
7.28 boolean propertyValuePattern,
7.29 String canonicalProps,
7.30 Map<String,String> keyPropertyList,
7.31 ObjectName pattern) {
7.32 - this.domain = domain.toCharArray();
7.33 this.isPropertyListPattern = propertyListPattern;
7.34 this.isPropertyValuePattern = propertyValuePattern;
7.35 this.properties = canonicalProps;
7.36 @@ -538,7 +534,7 @@
7.37 // "domain:*", "domain:[key=value],*" : names in the specified domain
7.38
7.39 // Surely one of the most frequent case ... query on the whole world
7.40 - ObjectName name = null;
7.41 + ObjectName name;
7.42 if (pattern == null ||
7.43 pattern.getCanonicalName().length() == 0 ||
7.44 pattern.equals(ObjectName.WILDCARD))
7.45 @@ -660,7 +656,7 @@
7.46 * @return Number of MBeans.
7.47 */
7.48 public Integer getCount() {
7.49 - return new Integer(nbElements);
7.50 + return nbElements;
7.51 }
7.52
7.53 /**
7.54 @@ -669,7 +665,7 @@
7.55 *
7.56 * @return A string giving the name of the default domain name.
7.57 */
7.58 - public String getDefaultDomain() {
7.59 + public String getDefaultDomain() {
7.60 return domain;
7.61 }
7.62
8.1 --- a/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java Wed May 21 10:59:07 2008 +0400
8.2 +++ b/src/share/classes/com/sun/jmx/remote/internal/ClientNotifForwarder.java Tue Jun 03 11:18:33 2008 -0700
8.3 @@ -435,7 +435,6 @@
8.4
8.5 clientSequenceNumber = nr.getNextSequenceNumber();
8.6
8.7 - final int size = infoList.size();
8.8 listeners = new HashMap<Integer, ClientListenerInfo>();
8.9
8.10 for (int i = 0 ; i < len ; i++) {
8.11 @@ -792,9 +791,6 @@
8.12
8.13 private Thread currentFetchThread;
8.14
8.15 - // admin stuff
8.16 - private boolean inited = false;
8.17 -
8.18 // state
8.19 /**
8.20 * This state means that a thread is being created for fetching and forwarding notifications.
9.1 --- a/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java Wed May 21 10:59:07 2008 +0400
9.2 +++ b/src/share/classes/com/sun/jmx/remote/internal/ServerNotifForwarder.java Tue Jun 03 11:18:33 2008 -0700
9.3 @@ -269,7 +269,7 @@
9.4 ", the maxNotifications is " + maxNotifications);
9.5 }
9.6
9.7 - NotificationResult nr = null;
9.8 + NotificationResult nr;
9.9 final long t = Math.min(connectionTimeout, timeout);
9.10 try {
9.11 nr = notifBuffer.fetchNotifications(bufferFilter,
9.12 @@ -322,7 +322,7 @@
9.13
9.14 private Integer getListenerID() {
9.15 synchronized(listenerCounterLock) {
9.16 - return new Integer(listenerCounter++);
9.17 + return listenerCounter++;
9.18 }
9.19 }
9.20
9.21 @@ -336,7 +336,7 @@
9.22 SecurityManager sm = System.getSecurityManager();
9.23 if (sm != null) {
9.24 AccessControlContext acc = AccessController.getContext();
9.25 - ObjectInstance oi = null;
9.26 + ObjectInstance oi;
9.27 try {
9.28 oi = AccessController.doPrivileged(
9.29 new PrivilegedExceptionAction<ObjectInstance>() {
10.1 --- a/src/share/classes/com/sun/jmx/remote/security/FileLoginModule.java Wed May 21 10:59:07 2008 +0400
10.2 +++ b/src/share/classes/com/sun/jmx/remote/security/FileLoginModule.java Tue Jun 03 11:18:33 2008 -0700
10.3 @@ -437,7 +437,7 @@
10.4 // get the username and password
10.5 getUsernamePassword(usePasswdFromSharedState);
10.6
10.7 - String localPassword = null;
10.8 + String localPassword;
10.9
10.10 // userCredentials is initialized in login()
10.11 if (((localPassword = userCredentials.getProperty(username)) == null) ||
10.12 @@ -487,10 +487,14 @@
10.13 throw ace;
10.14 }
10.15 }
10.16 - BufferedInputStream bis = new BufferedInputStream(fis);
10.17 - userCredentials = new Properties();
10.18 - userCredentials.load(bis);
10.19 - bis.close();
10.20 + try {
10.21 + BufferedInputStream bis = new BufferedInputStream(fis);
10.22 + userCredentials = new Properties();
10.23 + userCredentials.load(bis);
10.24 + bis.close();
10.25 + } finally {
10.26 + fis.close();
10.27 + }
10.28 }
10.29
10.30 /**
11.1 --- a/src/share/classes/com/sun/jmx/remote/security/JMXPluggableAuthenticator.java Wed May 21 10:59:07 2008 +0400
11.2 +++ b/src/share/classes/com/sun/jmx/remote/security/JMXPluggableAuthenticator.java Tue Jun 03 11:18:33 2008 -0700
11.3 @@ -295,7 +295,7 @@
11.4 private static class FileLoginConfig extends Configuration {
11.5
11.6 // The JAAS configuration for file-based authentication
11.7 - private static AppConfigurationEntry[] entries;
11.8 + private AppConfigurationEntry[] entries;
11.9
11.10 // The classname of the login module for file-based authentication
11.11 private static final String FILE_LOGIN_MODULE =
12.1 --- a/src/share/classes/com/sun/jmx/remote/security/MBeanServerFileAccessController.java Wed May 21 10:59:07 2008 +0400
12.2 +++ b/src/share/classes/com/sun/jmx/remote/security/MBeanServerFileAccessController.java Tue Jun 03 11:18:33 2008 -0700
12.3 @@ -231,10 +231,13 @@
12.4 private static Properties propertiesFromFile(String fname)
12.5 throws IOException {
12.6 FileInputStream fin = new FileInputStream(fname);
12.7 - Properties p = new Properties();
12.8 - p.load(fin);
12.9 - fin.close();
12.10 - return p;
12.11 + try {
12.12 + Properties p = new Properties();
12.13 + p.load(fin);
12.14 + return p;
12.15 + } finally {
12.16 + fin.close();
12.17 + }
12.18 }
12.19
12.20 private void checkAccessLevel(String accessLevel) {
13.1 --- a/src/share/classes/javax/management/NumericValueExp.java Wed May 21 10:59:07 2008 +0400
13.2 +++ b/src/share/classes/javax/management/NumericValueExp.java Tue Jun 03 11:18:33 2008 -0700
13.3 @@ -83,7 +83,7 @@
13.4 * <p>The <b>serialVersionUID</b> of this class is <code>-4679739485102359104L</code>.
13.5 */
13.6 private static final ObjectStreamField[] serialPersistentFields;
13.7 - private Number val = new Double(0);
13.8 + private Number val = 0.0;
13.9
13.10 private static boolean compat = false;
13.11 static {
13.12 @@ -213,11 +213,11 @@
13.13 }
13.14 if (isLong)
13.15 {
13.16 - this.val = new Long(longVal);
13.17 + this.val = longVal;
13.18 }
13.19 else
13.20 {
13.21 - this.val = new Double(doubleVal);
13.22 + this.val = doubleVal;
13.23 }
13.24 }
13.25 else
14.1 --- a/src/share/classes/javax/management/ObjectName.java Wed May 21 10:59:07 2008 +0400
14.2 +++ b/src/share/classes/javax/management/ObjectName.java Tue Jun 03 11:18:33 2008 -0700
14.3 @@ -449,7 +449,7 @@
14.4 // parses domain part
14.5 domain_parsing:
14.6 while (index < len) {
14.7 - switch (c = name_chars[index]) {
14.8 + switch (name_chars[index]) {
14.9 case ':' :
14.10 _domain_length = index++;
14.11 break domain_parsing;
14.12 @@ -619,7 +619,7 @@
14.13 case '\n' :
14.14 final String ichar = ((c1=='\n')?"\\n":""+c1);
14.15 throw new MalformedObjectNameException(
14.16 - "Invalid character '" + c1 +
14.17 + "Invalid character '" + ichar +
14.18 "' in value part of property");
14.19 default :
14.20 in_index++;
15.1 --- a/src/share/classes/javax/management/StandardMBean.java Wed May 21 10:59:07 2008 +0400
15.2 +++ b/src/share/classes/javax/management/StandardMBean.java Tue Jun 03 11:18:33 2008 -0700
15.3 @@ -750,7 +750,7 @@
15.4 * @return the Descriptor for the new MBeanInfo.
15.5 */
15.6 Descriptor getDescriptor(MBeanInfo info, boolean immutableInfo) {
15.7 - ImmutableDescriptor desc = null;
15.8 + ImmutableDescriptor desc;
15.9 if (info == null ||
15.10 info.getDescriptor() == null ||
15.11 info.getDescriptor().getFieldNames().length == 0) {
16.1 --- a/src/share/classes/javax/management/loading/MLet.java Wed May 21 10:59:07 2008 +0400
16.2 +++ b/src/share/classes/javax/management/loading/MLet.java Tue Jun 03 11:18:33 2008 -0700
16.3 @@ -591,8 +591,8 @@
16.4 // Instantiate the class specified in the
16.5 // CODE or OBJECT section of the MLet tag
16.6 //
16.7 - Object o = null;
16.8 - ObjectInstance objInst = null;
16.9 + Object o;
16.10 + ObjectInstance objInst;
16.11
16.12 if (code != null && serName != null) {
16.13 final String msg =
16.14 @@ -1131,11 +1131,17 @@
16.15 return null;
16.16 } finally {
16.17 // Cleanup ...
16.18 - if (tmpFile!=null) try {
16.19 - tmpFile.delete();
16.20 - } catch (Exception x) {
16.21 - MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
16.22 - "getTmpDir", "Failed to delete temporary file", x);
16.23 + if (tmpFile!=null) {
16.24 + try {
16.25 + boolean deleted = tmpFile.delete();
16.26 + if (!deleted) {
16.27 + MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
16.28 + "getTmpDir", "Failed to delete temp file");
16.29 + }
16.30 + } catch (Exception x) {
16.31 + MLET_LOGGER.logp(Level.FINEST, MLet.class.getName(),
16.32 + "getTmpDir", "Failed to delete temporary file", x);
16.33 + }
16.34 }
16.35 }
16.36 }
16.37 @@ -1178,25 +1184,8 @@
16.38 * Removes any white space from a string. This is used to
16.39 * convert strings such as "Windows NT" to "WindowsNT".
16.40 */
16.41 - private String removeSpace(String s) {
16.42 - s = s.trim();
16.43 - int j = s.indexOf(' ');
16.44 - if (j == -1) {
16.45 - return s;
16.46 - }
16.47 - String temp = "";
16.48 - int k = 0;
16.49 - while (j != -1) {
16.50 - s = s.substring(k);
16.51 - j = s.indexOf(' ');
16.52 - if (j != -1) {
16.53 - temp = temp + s.substring(0, j);
16.54 - } else {
16.55 - temp = temp + s.substring(0);
16.56 - }
16.57 - k = j + 1;
16.58 - }
16.59 - return temp;
16.60 + private static String removeSpace(String s) {
16.61 + return s.trim().replace(" ", "");
16.62 }
16.63
16.64 /**
17.1 --- a/src/share/classes/javax/management/loading/MLetParser.java Wed May 21 10:59:07 2008 +0400
17.2 +++ b/src/share/classes/javax/management/loading/MLetParser.java Tue Jun 03 11:18:33 2008 -0700
17.3 @@ -240,14 +240,12 @@
17.4 MLET_LOGGER.logp(Level.FINER,
17.5 MLetParser.class.getName(),
17.6 mth, requiresCodeWarning);
17.7 - atts = null;
17.8 throw new IOException(requiresCodeWarning);
17.9 }
17.10 if (atts.get("archive") == null) {
17.11 MLET_LOGGER.logp(Level.FINER,
17.12 MLetParser.class.getName(),
17.13 mth, requiresJarsWarning);
17.14 - atts = null;
17.15 throw new IOException(requiresJarsWarning);
17.16 }
17.17 }
17.18 @@ -265,7 +263,7 @@
17.19 public List<MLetContent> parseURL(String urlname) throws IOException {
17.20 // Parse the document
17.21 //
17.22 - URL url = null;
17.23 + URL url;
17.24 if (urlname.indexOf(':') <= 1) {
17.25 String userDir = System.getProperty("user.dir");
17.26 String prot;
18.1 --- a/src/share/classes/javax/management/modelmbean/DescriptorSupport.java Wed May 21 10:59:07 2008 +0400
18.2 +++ b/src/share/classes/javax/management/modelmbean/DescriptorSupport.java Tue Jun 03 11:18:33 2008 -0700
18.3 @@ -591,8 +591,6 @@
18.4 Set returnedSet = descriptorMap.entrySet();
18.5
18.6 int i = 0;
18.7 - Object currValue = null;
18.8 - Map.Entry currElement = null;
18.9
18.10 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
18.11 MODELMBEAN_LOGGER.logp(Level.FINEST,
18.12 @@ -600,7 +598,7 @@
18.13 "getFields()", "Returning " + numberOfEntries + " fields");
18.14 }
18.15 for (Iterator iter = returnedSet.iterator(); iter.hasNext(); i++) {
18.16 - currElement = (Map.Entry) iter.next();
18.17 + Map.Entry currElement = (Map.Entry) iter.next();
18.18
18.19 if (currElement == null) {
18.20 if (MODELMBEAN_LOGGER.isLoggable(Level.FINEST)) {
18.21 @@ -609,7 +607,7 @@
18.22 "getFields()", "Element is null");
18.23 }
18.24 } else {
18.25 - currValue = currElement.getValue();
18.26 + Object currValue = currElement.getValue();
18.27 if (currValue == null) {
18.28 responseFields[i] = currElement.getKey() + "=";
18.29 } else {
18.30 @@ -1127,7 +1125,7 @@
18.31 final char c = entities[i].charAt(0);
18.32 final String entity = entities[i].substring(1);
18.33 charToEntityMap[c] = entity;
18.34 - entityToCharMap.put(entity, new Character(c));
18.35 + entityToCharMap.put(entity, c);
18.36 }
18.37 }
18.38
18.39 @@ -1325,13 +1323,11 @@
18.40 // utility to convert to int, returns -2 if bogus.
18.41
18.42 private long toNumeric(String inStr) {
18.43 - long result = -2;
18.44 try {
18.45 - result = java.lang.Long.parseLong(inStr);
18.46 + return java.lang.Long.parseLong(inStr);
18.47 } catch (Exception e) {
18.48 return -2;
18.49 }
18.50 - return result;
18.51 }
18.52
18.53
19.1 --- a/src/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java Wed May 21 10:59:07 2008 +0400
19.2 +++ b/src/share/classes/javax/management/modelmbean/ModelMBeanAttributeInfo.java Tue Jun 03 11:18:33 2008 -0700
19.3 @@ -432,7 +432,7 @@
19.4 */
19.5 private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
19.6
19.7 - Descriptor clone = null;
19.8 + Descriptor clone;
19.9 if (in == null) {
19.10 clone = new DescriptorSupport();
19.11 MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
20.1 --- a/src/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java Wed May 21 10:59:07 2008 +0400
20.2 +++ b/src/share/classes/javax/management/modelmbean/ModelMBeanConstructorInfo.java Tue Jun 03 11:18:33 2008 -0700
20.3 @@ -393,7 +393,7 @@
20.4 * @exception RuntimeOperationsException if Descriptor is invalid
20.5 */
20.6 private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
20.7 - Descriptor clone = null;
20.8 + Descriptor clone;
20.9 if (in == null) {
20.10 clone = new DescriptorSupport();
20.11 MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
21.1 --- a/src/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java Wed May 21 10:59:07 2008 +0400
21.2 +++ b/src/share/classes/javax/management/modelmbean/ModelMBeanInfoSupport.java Tue Jun 03 11:18:33 2008 -0700
21.3 @@ -944,7 +944,7 @@
21.4 * @exception RuntimeOperationsException if Descriptor is invalid
21.5 */
21.6 private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
21.7 - Descriptor clone = null;
21.8 + Descriptor clone;
21.9 if (in == null) {
21.10 clone = new DescriptorSupport();
21.11 MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
22.1 --- a/src/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java Wed May 21 10:59:07 2008 +0400
22.2 +++ b/src/share/classes/javax/management/modelmbean/ModelMBeanNotificationInfo.java Tue Jun 03 11:18:33 2008 -0700
22.3 @@ -328,7 +328,7 @@
22.4 * @exception RuntimeOperationsException if Descriptor is invalid
22.5 */
22.6 private Descriptor validDescriptor(final Descriptor in) throws RuntimeOperationsException {
22.7 - Descriptor clone = null;
22.8 + Descriptor clone;
22.9 if (in == null) {
22.10 clone = new DescriptorSupport();
22.11 MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
23.1 --- a/src/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java Wed May 21 10:59:07 2008 +0400
23.2 +++ b/src/share/classes/javax/management/modelmbean/ModelMBeanOperationInfo.java Tue Jun 03 11:18:33 2008 -0700
23.3 @@ -424,7 +424,7 @@
23.4 */
23.5 private Descriptor validDescriptor(final Descriptor in)
23.6 throws RuntimeOperationsException {
23.7 - Descriptor clone = null;
23.8 + Descriptor clone;
23.9 if (in == null) {
23.10 clone = new DescriptorSupport();
23.11 MODELMBEAN_LOGGER.finer("Null Descriptor, creating new.");
24.1 --- a/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java Wed May 21 10:59:07 2008 +0400
24.2 +++ b/src/share/classes/javax/management/modelmbean/RequiredModelMBean.java Tue Jun 03 11:18:33 2008 -0700
24.3 @@ -1425,9 +1425,7 @@
24.4 }
24.5
24.6 /* Check attributeDescriptor for getMethod */
24.7 - ModelMBeanAttributeInfo attrInfo=null;
24.8 - Descriptor attrDescr=null;
24.9 - Object response = null;
24.10 + Object response;
24.11
24.12 try {
24.13 if (modelMBeanInfo == null)
24.14 @@ -1435,14 +1433,14 @@
24.15 "getAttribute failed: ModelMBeanInfo not found for "+
24.16 attrName);
24.17
24.18 - attrInfo = modelMBeanInfo.getAttribute(attrName);
24.19 + ModelMBeanAttributeInfo attrInfo = modelMBeanInfo.getAttribute(attrName);
24.20 Descriptor mmbDesc = modelMBeanInfo.getMBeanDescriptor();
24.21
24.22 if (attrInfo == null)
24.23 throw new AttributeNotFoundException("getAttribute failed:"+
24.24 " ModelMBeanAttributeInfo not found for " + attrName);
24.25
24.26 - attrDescr = attrInfo.getDescriptor();
24.27 + Descriptor attrDescr = attrInfo.getDescriptor();
24.28 if (attrDescr != null) {
24.29 if (!attrInfo.isReadable())
24.30 throw new AttributeNotFoundException(
24.31 @@ -1684,14 +1682,13 @@
24.32 "getAttributes(String[])","Entry");
24.33 }
24.34
24.35 - AttributeList responseList = null;
24.36 if (attrNames == null)
24.37 throw new RuntimeOperationsException(new
24.38 IllegalArgumentException("attributeNames must not be null"),
24.39 "Exception occurred trying to get attributes of a "+
24.40 "RequiredModelMBean");
24.41
24.42 - responseList = new AttributeList();
24.43 + AttributeList responseList = new AttributeList();
24.44 for (int i = 0; i < attrNames.length; i++) {
24.45 try {
24.46 responseList.add(new Attribute(attrNames[i],
24.47 @@ -1833,8 +1830,6 @@
24.48 throw new AttributeNotFoundException("setAttribute failed: "
24.49 + attrName + " is not writable ");
24.50
24.51 - Object setResponse = null;
24.52 -
24.53 String attrSetMethod = (String)
24.54 (attrDescr.getFieldValue("setMethod"));
24.55 String attrGetMethod = (String)
24.56 @@ -1873,9 +1868,9 @@
24.57 }
24.58 updateDescriptor = true;
24.59 } else {
24.60 - setResponse = invoke(attrSetMethod,
24.61 - (new Object[] {attrValue}),
24.62 - (new String[] {attrType}) );
24.63 + invoke(attrSetMethod,
24.64 + (new Object[] {attrValue}),
24.65 + (new String[] {attrType}) );
24.66 }
24.67
24.68 /* change cached value */
24.69 @@ -2023,8 +2018,6 @@
24.70 private synchronized void writeToLog(String logFileName,
24.71 String logEntry) throws Exception {
24.72
24.73 - PrintStream logOut = null;
24.74 - FileOutputStream fos = null;
24.75 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
24.76 MODELMBEAN_LOGGER.logp(Level.FINER,
24.77 RequiredModelMBean.class.getName(),
24.78 @@ -2041,9 +2034,9 @@
24.79 return;
24.80 }
24.81
24.82 + FileOutputStream fos = new FileOutputStream(logFileName, true);
24.83 try {
24.84 - fos = new FileOutputStream(logFileName, true);
24.85 - logOut = new PrintStream(fos);
24.86 + PrintStream logOut = new PrintStream(fos);
24.87 logOut.println(logEntry);
24.88 logOut.close();
24.89 if (MODELMBEAN_LOGGER.isLoggable(Level.FINER)) {
24.90 @@ -2062,6 +2055,8 @@
24.91 logFileName);
24.92 }
24.93 throw e;
24.94 + } finally {
24.95 + fos.close();
24.96 }
24.97 }
24.98
25.1 --- a/src/share/classes/javax/management/monitor/CounterMonitor.java Wed May 21 10:59:07 2008 +0400
25.2 +++ b/src/share/classes/javax/management/monitor/CounterMonitor.java Tue Jun 03 11:18:33 2008 -0700
25.3 @@ -740,16 +740,16 @@
25.4 //
25.5 switch (o.getType()) {
25.6 case INTEGER:
25.7 - o.setThreshold(new Integer((int)threshold_value));
25.8 + o.setThreshold(Integer.valueOf((int)threshold_value));
25.9 break;
25.10 case BYTE:
25.11 - o.setThreshold(new Byte((byte)threshold_value));
25.12 + o.setThreshold(Byte.valueOf((byte)threshold_value));
25.13 break;
25.14 case SHORT:
25.15 - o.setThreshold(new Short((short)threshold_value));
25.16 + o.setThreshold(Short.valueOf((short)threshold_value));
25.17 break;
25.18 case LONG:
25.19 - o.setThreshold(new Long(threshold_value));
25.20 + o.setThreshold(Long.valueOf(threshold_value));
25.21 break;
25.22 default:
25.23 // Should never occur...
25.24 @@ -810,10 +810,10 @@
25.25 derived += modulus.longValue();
25.26
25.27 switch (o.getType()) {
25.28 - case INTEGER: o.setDerivedGauge(new Integer((int) derived)); break;
25.29 - case BYTE: o.setDerivedGauge(new Byte((byte) derived)); break;
25.30 - case SHORT: o.setDerivedGauge(new Short((short) derived)); break;
25.31 - case LONG: o.setDerivedGauge(new Long(derived)); break;
25.32 + case INTEGER: o.setDerivedGauge(Integer.valueOf((int) derived)); break;
25.33 + case BYTE: o.setDerivedGauge(Byte.valueOf((byte) derived)); break;
25.34 + case SHORT: o.setDerivedGauge(Short.valueOf((short) derived)); break;
25.35 + case LONG: o.setDerivedGauge(Long.valueOf(derived)); break;
25.36 default:
25.37 // Should never occur...
25.38 MONITOR_LOGGER.logp(Level.FINEST, CounterMonitor.class.getName(),
26.1 --- a/src/share/classes/javax/management/monitor/GaugeMonitor.java Wed May 21 10:59:07 2008 +0400
26.2 +++ b/src/share/classes/javax/management/monitor/GaugeMonitor.java Tue Jun 03 11:18:33 2008 -0700
26.3 @@ -636,28 +636,28 @@
26.4 Number der;
26.5 switch (o.getType()) {
26.6 case INTEGER:
26.7 - der = new Integer(((Integer)scanGauge).intValue() -
26.8 - ((Integer)prev).intValue());
26.9 + der = Integer.valueOf(((Integer)scanGauge).intValue() -
26.10 + ((Integer)prev).intValue());
26.11 break;
26.12 case BYTE:
26.13 - der = new Byte((byte)(((Byte)scanGauge).byteValue() -
26.14 - ((Byte)prev).byteValue()));
26.15 + der = Byte.valueOf((byte)(((Byte)scanGauge).byteValue() -
26.16 + ((Byte)prev).byteValue()));
26.17 break;
26.18 case SHORT:
26.19 - der = new Short((short)(((Short)scanGauge).shortValue() -
26.20 - ((Short)prev).shortValue()));
26.21 + der = Short.valueOf((short)(((Short)scanGauge).shortValue() -
26.22 + ((Short)prev).shortValue()));
26.23 break;
26.24 case LONG:
26.25 - der = new Long(((Long)scanGauge).longValue() -
26.26 - ((Long)prev).longValue());
26.27 + der = Long.valueOf(((Long)scanGauge).longValue() -
26.28 + ((Long)prev).longValue());
26.29 break;
26.30 case FLOAT:
26.31 - der = new Float(((Float)scanGauge).floatValue() -
26.32 - ((Float)prev).floatValue());
26.33 + der = Float.valueOf(((Float)scanGauge).floatValue() -
26.34 + ((Float)prev).floatValue());
26.35 break;
26.36 case DOUBLE:
26.37 - der = new Double(((Double)scanGauge).doubleValue() -
26.38 - ((Double)prev).doubleValue());
26.39 + der = Double.valueOf(((Double)scanGauge).doubleValue() -
26.40 + ((Double)prev).doubleValue());
26.41 break;
26.42 default:
26.43 // Should never occur...
27.1 --- a/src/share/classes/javax/management/monitor/Monitor.java Wed May 21 10:59:07 2008 +0400
27.2 +++ b/src/share/classes/javax/management/monitor/Monitor.java Tue Jun 03 11:18:33 2008 -0700
27.3 @@ -367,7 +367,7 @@
27.4 /**
27.5 * Constant used to initialize all the numeric values.
27.6 */
27.7 - static final Integer INTEGER_ZERO = new Integer(0);
27.8 + static final Integer INTEGER_ZERO = 0;
27.9
27.10
27.11 /*
27.12 @@ -1122,12 +1122,12 @@
27.13 */
27.14 private void monitor(ObservedObject o, int index, int an[]) {
27.15
27.16 - String attribute = null;
27.17 + String attribute;
27.18 String notifType = null;
27.19 String msg = null;
27.20 Object derGauge = null;
27.21 Object trigger = null;
27.22 - ObjectName object = null;
27.23 + ObjectName object;
27.24 Comparable<?> value = null;
27.25 MonitorNotification alarm = null;
27.26
27.27 @@ -1565,7 +1565,7 @@
27.28 final ThreadGroup group;
27.29 final AtomicInteger threadNumber = new AtomicInteger(1);
27.30 final String namePrefix;
27.31 - final String nameSuffix = "]";
27.32 + static final String nameSuffix = "]";
27.33
27.34 public DaemonThreadFactory(String poolName) {
27.35 SecurityManager s = System.getSecurityManager();
28.1 --- a/src/share/classes/javax/management/openmbean/ArrayType.java Wed May 21 10:59:07 2008 +0400
28.2 +++ b/src/share/classes/javax/management/openmbean/ArrayType.java Tue Jun 03 11:18:33 2008 -0700
28.3 @@ -726,7 +726,7 @@
28.4 value += dimension;
28.5 value += elementType.hashCode();
28.6 value += Boolean.valueOf(primitiveArray).hashCode();
28.7 - myHashCode = new Integer(value);
28.8 + myHashCode = Integer.valueOf(value);
28.9 }
28.10
28.11 // return always the same hash code for this instance (immutable)
29.1 --- a/src/share/classes/javax/management/openmbean/CompositeType.java Wed May 21 10:59:07 2008 +0400
29.2 +++ b/src/share/classes/javax/management/openmbean/CompositeType.java Tue Jun 03 11:18:33 2008 -0700
29.3 @@ -426,7 +426,7 @@
29.4 value += key.hashCode();
29.5 value += this.nameToType.get(key).hashCode();
29.6 }
29.7 - myHashCode = new Integer(value);
29.8 + myHashCode = Integer.valueOf(value);
29.9 }
29.10
29.11 // return always the same hash code for this instance (immutable)
30.1 --- a/src/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java Wed May 21 10:59:07 2008 +0400
30.2 +++ b/src/share/classes/javax/management/openmbean/OpenMBeanAttributeInfoSupport.java Tue Jun 03 11:18:33 2008 -0700
30.3 @@ -769,7 +769,6 @@
30.4 "array with same dimensions";
30.5 throw new IllegalArgumentException(msg);
30.6 }
30.7 - Class<?> targetComponentClass = targetArrayClass.getComponentType();
30.8 OpenType<?> componentOpenType;
30.9 if (dim == 1)
30.10 componentOpenType = baseType;
31.1 --- a/src/share/classes/javax/management/openmbean/OpenMBeanConstructorInfoSupport.java Wed May 21 10:59:07 2008 +0400
31.2 +++ b/src/share/classes/javax/management/openmbean/OpenMBeanConstructorInfoSupport.java Tue Jun 03 11:18:33 2008 -0700
31.3 @@ -252,7 +252,7 @@
31.4 int value = 0;
31.5 value += this.getName().hashCode();
31.6 value += Arrays.asList(this.getSignature()).hashCode();
31.7 - myHashCode = new Integer(value);
31.8 + myHashCode = Integer.valueOf(value);
31.9 }
31.10
31.11 // return always the same hash code for this instance (immutable)
32.1 --- a/src/share/classes/javax/management/openmbean/OpenMBeanInfoSupport.java Wed May 21 10:59:07 2008 +0400
32.2 +++ b/src/share/classes/javax/management/openmbean/OpenMBeanInfoSupport.java Tue Jun 03 11:18:33 2008 -0700
32.3 @@ -347,7 +347,7 @@
32.4 value += arraySetHash(this.getConstructors());
32.5 value += arraySetHash(this.getOperations());
32.6 value += arraySetHash(this.getNotifications());
32.7 - myHashCode = new Integer(value);
32.8 + myHashCode = Integer.valueOf(value);
32.9 }
32.10
32.11 // return always the same hash code for this instance (immutable)
33.1 --- a/src/share/classes/javax/management/openmbean/OpenMBeanOperationInfoSupport.java Wed May 21 10:59:07 2008 +0400
33.2 +++ b/src/share/classes/javax/management/openmbean/OpenMBeanOperationInfoSupport.java Tue Jun 03 11:18:33 2008 -0700
33.3 @@ -352,7 +352,7 @@
33.4 value += Arrays.asList(this.getSignature()).hashCode();
33.5 value += this.getReturnOpenType().hashCode();
33.6 value += this.getImpact();
33.7 - myHashCode = new Integer(value);
33.8 + myHashCode = Integer.valueOf(value);
33.9 }
33.10
33.11 // return always the same hash code for this instance (immutable)
34.1 --- a/src/share/classes/javax/management/openmbean/SimpleType.java Wed May 21 10:59:07 2008 +0400
34.2 +++ b/src/share/classes/javax/management/openmbean/SimpleType.java Tue Jun 03 11:18:33 2008 -0700
34.3 @@ -257,7 +257,7 @@
34.4 // Calculate the hash code value if it has not yet been done (ie 1st call to hashCode())
34.5 //
34.6 if (myHashCode == null) {
34.7 - myHashCode = new Integer(this.getClassName().hashCode());
34.8 + myHashCode = Integer.valueOf(this.getClassName().hashCode());
34.9 }
34.10
34.11 // return always the same hash code for this instance (immutable)
35.1 --- a/src/share/classes/javax/management/openmbean/TabularType.java Wed May 21 10:59:07 2008 +0400
35.2 +++ b/src/share/classes/javax/management/openmbean/TabularType.java Tue Jun 03 11:18:33 2008 -0700
35.3 @@ -332,7 +332,7 @@
35.4 for (Iterator k = indexNames.iterator(); k.hasNext(); ) {
35.5 value += k.next().hashCode();
35.6 }
35.7 - myHashCode = new Integer(value);
35.8 + myHashCode = Integer.valueOf(value);
35.9 }
35.10
35.11 // return always the same hash code for this instance (immutable)
36.1 --- a/src/share/classes/javax/management/relation/RelationNotification.java Wed May 21 10:59:07 2008 +0400
36.2 +++ b/src/share/classes/javax/management/relation/RelationNotification.java Tue Jun 03 11:18:33 2008 -0700
36.3 @@ -369,7 +369,7 @@
36.4 * @return a {@link List} of {@link ObjectName}.
36.5 */
36.6 public List<ObjectName> getMBeansToUnregister() {
36.7 - List<ObjectName> result = null;
36.8 + List<ObjectName> result;
36.9 if (unregisterMBeanList != null) {
36.10 result = new ArrayList<ObjectName>(unregisterMBeanList);
36.11 } else {
36.12 @@ -397,7 +397,7 @@
36.13 * @return the old value of the updated role.
36.14 */
36.15 public List<ObjectName> getOldRoleValue() {
36.16 - List<ObjectName> result = null;
36.17 + List<ObjectName> result;
36.18 if (oldRoleValue != null) {
36.19 result = new ArrayList<ObjectName>(oldRoleValue);
36.20 } else {
36.21 @@ -412,7 +412,7 @@
36.22 * @return the new value of the updated role.
36.23 */
36.24 public List<ObjectName> getNewRoleValue() {
36.25 - List<ObjectName> result = null;
36.26 + List<ObjectName> result;
36.27 if (newRoleValue != null) {
36.28 result = new ArrayList<ObjectName>(newRoleValue);
36.29 } else {
37.1 --- a/src/share/classes/javax/management/relation/RelationService.java Wed May 21 10:59:07 2008 +0400
37.2 +++ b/src/share/classes/javax/management/relation/RelationService.java Tue Jun 03 11:18:33 2008 -0700
37.3 @@ -35,6 +35,7 @@
37.4 import java.util.List;
37.5 import java.util.Map;
37.6 import java.util.Set;
37.7 +import java.util.concurrent.atomic.AtomicLong;
37.8 import java.util.logging.Level;
37.9
37.10 import javax.management.Attribute;
37.11 @@ -122,7 +123,7 @@
37.12 // Internal counter to provide sequence numbers for notifications sent by:
37.13 // - the Relation Service
37.14 // - a relation handled by the Relation Service
37.15 - private Long myNtfSeqNbrCounter = new Long(0);
37.16 + private final AtomicLong atomicSeqNo = new AtomicLong();
37.17
37.18 // ObjectName used to register the Relation Service in the MBean Server
37.19 private ObjectName myObjName = null;
37.20 @@ -256,19 +257,6 @@
37.21 return;
37.22 }
37.23
37.24 - // Returns internal counter to be used for Sequence Numbers of
37.25 - // notifications to be raised by:
37.26 - // - a relation handled by this Relation Service (when updated)
37.27 - // - the Relation Service
37.28 - private Long getNotificationSequenceNumber() {
37.29 - Long result = null;
37.30 - synchronized(myNtfSeqNbrCounter) {
37.31 - result = new Long(myNtfSeqNbrCounter.longValue() + 1);
37.32 - myNtfSeqNbrCounter = new Long(result.longValue());
37.33 - }
37.34 - return result;
37.35 - }
37.36 -
37.37 //
37.38 // Relation type handling
37.39 //
37.40 @@ -369,7 +357,7 @@
37.41 * @return ArrayList of relation type names (Strings)
37.42 */
37.43 public List<String> getAllRelationTypeNames() {
37.44 - ArrayList<String> result = null;
37.45 + ArrayList<String> result;
37.46 synchronized(myRelType2ObjMap) {
37.47 result = new ArrayList<String>(myRelType2ObjMap.keySet());
37.48 }
37.49 @@ -684,7 +672,7 @@
37.50 // Can throw InstanceNotFoundException (but detected above)
37.51 // No MBeanException as no exception raised by this method, and no
37.52 // ReflectionException
37.53 - String relId = null;
37.54 + String relId;
37.55 try {
37.56 relId = (String)(myMBeanServer.getAttribute(relationObjectName,
37.57 "RelationId"));
37.58 @@ -707,7 +695,7 @@
37.59 // Can throw InstanceNotFoundException (but detected above)
37.60 // No MBeanException as no exception raised by this method, no
37.61 // ReflectionException
37.62 - ObjectName relServObjName = null;
37.63 + ObjectName relServObjName;
37.64 try {
37.65 relServObjName = (ObjectName)
37.66 (myMBeanServer.getAttribute(relationObjectName,
37.67 @@ -737,7 +725,7 @@
37.68 // Can throw InstanceNotFoundException (but detected above)
37.69 // No MBeanException as no exception raised by this method, no
37.70 // ReflectionException
37.71 - String relTypeName = null;
37.72 + String relTypeName;
37.73 try {
37.74 relTypeName = (String)(myMBeanServer.getAttribute(relationObjectName,
37.75 "RelationTypeName"));
37.76 @@ -758,7 +746,7 @@
37.77 // Can throw InstanceNotFoundException (but detected above)
37.78 // No MBeanException as no exception raised by this method, no
37.79 // ReflectionException
37.80 - RoleList roleList = null;
37.81 + RoleList roleList;
37.82 try {
37.83 roleList = (RoleList)(myMBeanServer.invoke(relationObjectName,
37.84 "retrieveAllRoles",
37.85 @@ -912,7 +900,7 @@
37.86 * @return ArrayList of String
37.87 */
37.88 public List<String> getAllRelationIds() {
37.89 - List<String> result = null;
37.90 + List<String> result;
37.91 synchronized(myRelId2ObjMap) {
37.92 result = new ArrayList<String>(myRelId2ObjMap.keySet());
37.93 }
37.94 @@ -948,7 +936,7 @@
37.95 RELATION_LOGGER.entering(RelationService.class.getName(),
37.96 "checkRoleReading", new Object[] {roleName, relationTypeName});
37.97
37.98 - Integer result = null;
37.99 + Integer result;
37.100
37.101 // Can throw a RelationTypeNotFoundException
37.102 RelationType relType = getRelationType(relationTypeName);
37.103 @@ -965,7 +953,7 @@
37.104 false);
37.105
37.106 } catch (RoleInfoNotFoundException exc) {
37.107 - result = new Integer(RoleStatus.NO_ROLE_WITH_NAME);
37.108 + result = Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME);
37.109 }
37.110
37.111 RELATION_LOGGER.exiting(RelationService.class.getName(),
37.112 @@ -1021,13 +1009,13 @@
37.113 writeChkFlag = false;
37.114 }
37.115
37.116 - RoleInfo roleInfo = null;
37.117 + RoleInfo roleInfo;
37.118 try {
37.119 roleInfo = relType.getRoleInfo(roleName);
37.120 } catch (RoleInfoNotFoundException exc) {
37.121 RELATION_LOGGER.exiting(RelationService.class.getName(),
37.122 "checkRoleWriting");
37.123 - return new Integer(RoleStatus.NO_ROLE_WITH_NAME);
37.124 + return Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME);
37.125 }
37.126
37.127 Integer result = checkRoleInt(2,
37.128 @@ -1436,7 +1424,7 @@
37.129
37.130 // Relation id to relation type name map
37.131 // First retrieves the relation type name
37.132 - String relTypeName = null;
37.133 + String relTypeName;
37.134 synchronized(myRelId2RelTypeMap) {
37.135 relTypeName = myRelId2RelTypeMap.get(relationId);
37.136 myRelId2RelTypeMap.remove(relationId);
37.137 @@ -1641,7 +1629,7 @@
37.138
37.139 // List of relation ids of interest regarding the selected
37.140 // relation type
37.141 - List<String> relIdList = null;
37.142 + List<String> relIdList;
37.143 if (relationTypeName == null) {
37.144 // Considers all relations
37.145 relIdList = new ArrayList<String>(allRelIdSet);
37.146 @@ -1655,7 +1643,7 @@
37.147 for (String currRelId : allRelIdSet) {
37.148
37.149 // Retrieves its relation type
37.150 - String currRelTypeName = null;
37.151 + String currRelTypeName;
37.152 synchronized(myRelId2RelTypeMap) {
37.153 currRelTypeName =
37.154 myRelId2RelTypeMap.get(currRelId);
37.155 @@ -1952,7 +1940,7 @@
37.156 // Can throw a RelationNotFoundException
37.157 Object relObj = getRelation(relationId);
37.158
37.159 - RoleResult result = null;
37.160 + RoleResult result;
37.161
37.162 if (relObj instanceof RelationSupport) {
37.163 // Internal relation
37.164 @@ -2022,7 +2010,7 @@
37.165 // Can throw a RelationNotFoundException
37.166 Object relObj = getRelation(relationId);
37.167
37.168 - RoleResult result = null;
37.169 + RoleResult result;
37.170
37.171 if (relObj instanceof RelationSupport) {
37.172 // Internal relation
37.173 @@ -2073,7 +2061,7 @@
37.174 // Can throw a RelationNotFoundException
37.175 Object relObj = getRelation(relationId);
37.176
37.177 - Integer result = null;
37.178 + Integer result;
37.179
37.180 if (relObj instanceof RelationSupport) {
37.181 // Internal relation
37.182 @@ -2268,7 +2256,7 @@
37.183 // Can throw a RelationNotFoundException
37.184 Object relObj = getRelation(relationId);
37.185
37.186 - RoleResult result = null;
37.187 + RoleResult result;
37.188
37.189 if (relObj instanceof RelationSupport) {
37.190 // Internal relation
37.191 @@ -2390,7 +2378,7 @@
37.192 // Can throw a RelationNotFoundException
37.193 Object relObj = getRelation(relationId);
37.194
37.195 - String result = null;
37.196 + String result;
37.197
37.198 if (relObj instanceof RelationSupport) {
37.199 // Internal relation
37.200 @@ -2473,7 +2461,7 @@
37.201
37.202 // Note: do both tests as a relation can be an MBean and be
37.203 // itself referenced in another relation :)
37.204 - String relId = null;
37.205 + String relId;
37.206 synchronized(myRelMBeanObjName2RelIdMap){
37.207 relId = myRelMBeanObjName2RelIdMap.get(mbeanName);
37.208 }
37.209 @@ -2511,9 +2499,6 @@
37.210 RELATION_LOGGER.entering(RelationService.class.getName(),
37.211 "getNotificationInfo");
37.212
37.213 - MBeanNotificationInfo[] ntfInfoArray =
37.214 - new MBeanNotificationInfo[1];
37.215 -
37.216 String ntfClass = "javax.management.relation.RelationNotification";
37.217
37.218 String[] ntfTypes = new String[] {
37.219 @@ -2615,7 +2600,7 @@
37.220 "getRelationType", relationTypeName);
37.221
37.222 // No null relation type accepted, so can use get()
37.223 - RelationType relType = null;
37.224 + RelationType relType;
37.225 synchronized(myRelType2ObjMap) {
37.226 relType = (myRelType2ObjMap.get(relationTypeName));
37.227 }
37.228 @@ -2659,7 +2644,7 @@
37.229 "getRelation", relationId);
37.230
37.231 // No null relation accepted, so can use get()
37.232 - Object rel = null;
37.233 + Object rel;
37.234 synchronized(myRelId2ObjMap) {
37.235 rel = myRelId2ObjMap.get(relationId);
37.236 }
37.237 @@ -3077,7 +3062,7 @@
37.238 // Retrieves corresponding role info
37.239 // Can throw a RoleInfoNotFoundException to be converted into a
37.240 // RoleNotFoundException
37.241 - RoleInfo roleInfo = null;
37.242 + RoleInfo roleInfo;
37.243 try {
37.244 roleInfo = relType.getRoleInfo(currRoleName);
37.245 } catch (RoleInfoNotFoundException exc) {
37.246 @@ -3227,7 +3212,7 @@
37.247 if (!(roleName.equals(expName))) {
37.248 RELATION_LOGGER.exiting(RelationService.class.getName(),
37.249 "checkRoleInt");
37.250 - return new Integer(RoleStatus.NO_ROLE_WITH_NAME);
37.251 + return Integer.valueOf(RoleStatus.NO_ROLE_WITH_NAME);
37.252 }
37.253
37.254 // Checks read access if required
37.255 @@ -3236,7 +3221,7 @@
37.256 if (!isReadable) {
37.257 RELATION_LOGGER.exiting(RelationService.class.getName(),
37.258 "checkRoleInt");
37.259 - return new Integer(RoleStatus.ROLE_NOT_READABLE);
37.260 + return Integer.valueOf(RoleStatus.ROLE_NOT_READABLE);
37.261 } else {
37.262 // End of check :)
37.263 RELATION_LOGGER.exiting(RelationService.class.getName(),
37.264 @@ -3572,7 +3557,7 @@
37.265 // Relation type name
37.266 // Note: do not use getRelationTypeName() as if it is a relation MBean
37.267 // it is already unregistered.
37.268 - String relTypeName = null;
37.269 + String relTypeName;
37.270 synchronized(myRelId2RelTypeMap) {
37.271 relTypeName = (myRelId2RelTypeMap.get(relationId));
37.272 }
37.273 @@ -3609,7 +3594,7 @@
37.274 }
37.275
37.276 // Sequence number
37.277 - Long seqNbr = getNotificationSequenceNumber();
37.278 + Long seqNo = atomicSeqNo.incrementAndGet();
37.279
37.280 // Timestamp
37.281 Date currDate = new Date();
37.282 @@ -3625,7 +3610,7 @@
37.283 // Creation or removal
37.284 ntf = new RelationNotification(ntfType,
37.285 this,
37.286 - seqNbr.longValue(),
37.287 + seqNo.longValue(),
37.288 timeStamp,
37.289 message,
37.290 relationId,
37.291 @@ -3640,7 +3625,7 @@
37.292 // Update
37.293 ntf = new RelationNotification(ntfType,
37.294 this,
37.295 - seqNbr.longValue(),
37.296 + seqNo.longValue(),
37.297 timeStamp,
37.298 message,
37.299 relationId,
37.300 @@ -3732,7 +3717,7 @@
37.301 //
37.302 // Shall not throw RelationTypeNotFoundException or
37.303 // RoleInfoNotFoundException
37.304 - RoleInfo currRoleInfo = null;
37.305 + RoleInfo currRoleInfo;
37.306 try {
37.307 currRoleInfo = getRoleInfo(currRelTypeName,
37.308 currRoleName);
38.1 --- a/src/share/classes/javax/management/relation/RelationSupport.java Wed May 21 10:59:07 2008 +0400
38.2 +++ b/src/share/classes/javax/management/relation/RelationSupport.java Tue Jun 03 11:18:33 2008 -0700
38.3 @@ -34,6 +34,7 @@
38.4 import java.util.Map;
38.5 import java.util.List;
38.6
38.7 +import java.util.concurrent.atomic.AtomicBoolean;
38.8 import static com.sun.jmx.defaults.JmxProperties.RELATION_LOGGER;
38.9 import static com.sun.jmx.mbeanserver.Util.cast;
38.10 import javax.management.InstanceNotFoundException;
38.11 @@ -110,7 +111,7 @@
38.12 private Map<String,Role> myRoleName2ValueMap = new HashMap<String,Role>();
38.13
38.14 // Flag to indicate if the object has been added in the Relation Service
38.15 - private Boolean myInRelServFlg = null;
38.16 + private final AtomicBoolean myInRelServFlg = new AtomicBoolean();
38.17
38.18 //
38.19 // Constructors
38.20 @@ -403,7 +404,7 @@
38.21 "getRoleCardinality", roleName);
38.22
38.23 // Try to retrieve the role
38.24 - Role role = null;
38.25 + Role role;
38.26 synchronized(myRoleName2ValueMap) {
38.27 // No null Role is allowed, so direct use of get()
38.28 role = (myRoleName2ValueMap.get(roleName));
38.29 @@ -427,7 +428,7 @@
38.30
38.31 RELATION_LOGGER.exiting(RelationSupport.class.getName(),
38.32 "getRoleCardinality");
38.33 - return new Integer(roleValue.size());
38.34 + return roleValue.size();
38.35 }
38.36
38.37 /**
38.38 @@ -701,11 +702,7 @@
38.39 * the Relation Service.
38.40 */
38.41 public Boolean isInRelationService() {
38.42 - Boolean result = null;
38.43 - synchronized(myInRelServFlg) {
38.44 - result = Boolean.valueOf(myInRelServFlg.booleanValue());
38.45 - }
38.46 - return result;
38.47 + return myInRelServFlg.get();
38.48 }
38.49
38.50 public void setRelationServiceManagementFlag(Boolean flag)
38.51 @@ -715,10 +712,7 @@
38.52 String excMsg = "Invalid parameter.";
38.53 throw new IllegalArgumentException(excMsg);
38.54 }
38.55 - synchronized(myInRelServFlg) {
38.56 - myInRelServFlg = Boolean.valueOf(flag.booleanValue());
38.57 - }
38.58 - return;
38.59 + myInRelServFlg.set(flag);
38.60 }
38.61
38.62 //
38.63 @@ -790,7 +784,7 @@
38.64
38.65 int pbType = 0;
38.66
38.67 - Role role = null;
38.68 + Role role;
38.69 synchronized(myRoleName2ValueMap) {
38.70 // No null Role is allowed, so direct use of get()
38.71 role = (myRoleName2ValueMap.get(roleName));
38.72 @@ -801,7 +795,7 @@
38.73
38.74 } else {
38.75 // Checks if the role is readable
38.76 - Integer status = null;
38.77 + Integer status;
38.78
38.79 if (relationServCallFlg) {
38.80
38.81 @@ -851,7 +845,7 @@
38.82 pbType = status.intValue();
38.83 }
38.84
38.85 - Object result = null;
38.86 + Object result;
38.87
38.88 if (pbType == 0) {
38.89 // Role can be retrieved
38.90 @@ -937,7 +931,7 @@
38.91 for (int i = 0; i < roleNameArray.length; i++) {
38.92 String currRoleName = roleNameArray[i];
38.93
38.94 - Object currResult = null;
38.95 + Object currResult;
38.96
38.97 // Can throw RelationServiceNotRegisteredException
38.98 //
38.99 @@ -1102,13 +1096,13 @@
38.100 // handle initialization of role when creating the relation
38.101 // (roles provided in the RoleList parameter are directly set but
38.102 // roles automatically initialized are set using setRole())
38.103 - Role role = null;
38.104 + Role role;
38.105 synchronized(myRoleName2ValueMap) {
38.106 role = (myRoleName2ValueMap.get(roleName));
38.107 }
38.108
38.109 List<ObjectName> oldRoleValue;
38.110 - Boolean initFlg = null;
38.111 + Boolean initFlg;
38.112
38.113 if (role == null) {
38.114 initFlg = true;
38.115 @@ -1122,7 +1116,7 @@
38.116 // Checks if the role can be set: is writable (except if
38.117 // initialization) and correct value
38.118 try {
38.119 - Integer status = null;
38.120 + Integer status;
38.121
38.122 if (relationServCallFlg) {
38.123
38.124 @@ -1314,7 +1308,7 @@
38.125 Object[] params = new Object[3];
38.126 params[0] = myRelId;
38.127 params[1] = newRole;
38.128 - params[2] = ((ArrayList)oldRoleValue);
38.129 + params[2] = oldRoleValue;
38.130 String[] signature = new String[3];
38.131 signature[0] = "java.lang.String";
38.132 signature[1] = "javax.management.relation.Role";
38.133 @@ -1598,7 +1592,6 @@
38.134 myRelTypeName = relationTypeName;
38.135 // Can throw InvalidRoleValueException
38.136 initRoleMap(list);
38.137 - myInRelServFlg = Boolean.FALSE;
38.138
38.139 RELATION_LOGGER.exiting(RelationSupport.class.getName(), "initMembers");
38.140 return;
38.141 @@ -1710,7 +1703,7 @@
38.142 roleName, relationServCallFlg, relationServ});
38.143
38.144 // Retrieves current role value
38.145 - Role role = null;
38.146 + Role role;
38.147 synchronized(myRoleName2ValueMap) {
38.148 role = (myRoleName2ValueMap.get(roleName));
38.149 }
39.1 --- a/src/share/classes/javax/management/remote/JMXConnectorFactory.java Wed May 21 10:59:07 2008 +0400
39.2 +++ b/src/share/classes/javax/management/remote/JMXConnectorFactory.java Tue Jun 03 11:18:33 2008 -0700
39.3 @@ -435,7 +435,7 @@
39.4
39.5 Iterator<JMXConnectorProvider> providers =
39.6 getProviderIterator(JMXConnectorProvider.class, loader);
39.7 - JMXConnector connection = null;
39.8 + JMXConnector connection;
39.9 IOException exception = null;
39.10 while(providers.hasNext()) {
39.11 try {
39.12 @@ -450,7 +450,7 @@
39.13 "] Service provider exception: " + e);
39.14 if (!(e instanceof MalformedURLException)) {
39.15 if (exception == null) {
39.16 - if (exception instanceof IOException) {
39.17 + if (e instanceof IOException) {
39.18 exception = (IOException) e;
39.19 } else {
39.20 exception = EnvHelp.initCause(
40.1 --- a/src/share/classes/javax/management/remote/JMXConnectorServerFactory.java Wed May 21 10:59:07 2008 +0400
40.2 +++ b/src/share/classes/javax/management/remote/JMXConnectorServerFactory.java Tue Jun 03 11:18:33 2008 -0700
40.3 @@ -215,12 +215,10 @@
40.4 JMXConnectorFactory.
40.5 getProviderIterator(JMXConnectorServerProvider.class, loader);
40.6
40.7 - JMXConnectorServer connection = null;
40.8 IOException exception = null;
40.9 while (providers.hasNext()) {
40.10 try {
40.11 - connection = providers.next().newJMXConnectorServer(url, map, mbs);
40.12 - return connection;
40.13 + return providers.next().newJMXConnectorServer(url, map, mbs);
40.14 } catch (JMXProviderException e) {
40.15 throw e;
40.16 } catch (Exception e) {
40.17 @@ -230,7 +228,7 @@
40.18 "] Service provider exception: " + e);
40.19 if (!(e instanceof MalformedURLException)) {
40.20 if (exception == null) {
40.21 - if (exception instanceof IOException) {
40.22 + if (e instanceof IOException) {
40.23 exception = (IOException) e;
40.24 } else {
40.25 exception = EnvHelp.initCause(
41.1 --- a/src/share/classes/javax/management/remote/JMXServiceURL.java Wed May 21 10:59:07 2008 +0400
41.2 +++ b/src/share/classes/javax/management/remote/JMXServiceURL.java Tue Jun 03 11:18:33 2008 -0700
41.3 @@ -162,8 +162,6 @@
41.4 requiredPrefix);
41.5 }
41.6
41.7 - int[] ptr = new int[1];
41.8 -
41.9 // Parse the protocol name
41.10 final int protoStart = requiredPrefixLength;
41.11 final int protoEnd = indexOf(serviceURL, ':', protoStart);
41.12 @@ -664,11 +662,6 @@
41.13 hostNameBitSet.set('.');
41.14 }
41.15
41.16 - private static void addCharsToBitSet(BitSet set, String chars) {
41.17 - for (int i = 0; i < chars.length(); i++)
41.18 - set.set(chars.charAt(i));
41.19 - }
41.20 -
41.21 /**
41.22 * The value returned by {@link #getProtocol()}.
41.23 */
42.1 --- a/src/share/classes/javax/management/remote/rmi/RMIConnector.java Wed May 21 10:59:07 2008 +0400
42.2 +++ b/src/share/classes/javax/management/remote/rmi/RMIConnector.java Tue Jun 03 11:18:33 2008 -0700
42.3 @@ -1376,12 +1376,12 @@
42.4
42.5 protected Integer addListenerForMBeanRemovedNotif()
42.6 throws IOException, InstanceNotFoundException {
42.7 - MarshalledObject<NotificationFilter> sFilter = null;
42.8 NotificationFilterSupport clientFilter =
42.9 new NotificationFilterSupport();
42.10 clientFilter.enableType(
42.11 MBeanServerNotification.UNREGISTRATION_NOTIFICATION);
42.12 - sFilter = new MarshalledObject<NotificationFilter>(clientFilter);
42.13 + MarshalledObject<NotificationFilter> sFilter =
42.14 + new MarshalledObject<NotificationFilter>(clientFilter);
42.15
42.16 Integer[] listenerIDs;
42.17 final ObjectName[] names =
42.18 @@ -1434,7 +1434,7 @@
42.19 connectionId,
42.20 clientNotifCounter++,
42.21 message,
42.22 - new Long(number));
42.23 + Long.valueOf(number));
42.24 sendNotification(n);
42.25 }
42.26 }
42.27 @@ -1593,7 +1593,7 @@
42.28
42.29 protected void doStart() throws IOException {
42.30 // Get RMIServer stub from directory or URL encoding if needed.
42.31 - RMIServer stub = null;
42.32 + RMIServer stub;
42.33 try {
42.34 stub = (rmiServer!=null)?rmiServer:
42.35 findRMIServer(jmxServiceURL, env);
42.36 @@ -2532,7 +2532,7 @@
42.37 * A static WeakReference to an {@link org.omg.CORBA.ORB ORB} to
42.38 * connect unconnected stubs.
42.39 **/
42.40 - private static WeakReference<ORB> orb = null;
42.41 + private static volatile WeakReference<ORB> orb = null;
42.42
42.43 // TRACES & DEBUG
42.44 //---------------
43.1 --- a/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java Wed May 21 10:59:07 2008 +0400
43.2 +++ b/src/share/classes/javax/management/remote/rmi/RMIConnectorServer.java Tue Jun 03 11:18:33 2008 -0700
43.3 @@ -365,7 +365,7 @@
43.4 // Access file property specified, create an instance
43.5 // of the MBeanServerFileAccessController class
43.6 //
43.7 - MBeanServerForwarder mbsf = null;
43.8 + MBeanServerForwarder mbsf;
43.9 try {
43.10 mbsf = new MBeanServerFileAccessController(accessFile);
43.11 } catch (IOException e) {
44.1 --- a/src/share/classes/javax/management/timer/Timer.java Wed May 21 10:59:07 2008 +0400
44.2 +++ b/src/share/classes/javax/management/timer/Timer.java Tue Jun 03 11:18:33 2008 -0700
44.3 @@ -344,13 +344,11 @@
44.4 //
44.5 if (isActive == true) {
44.6
44.7 - TimerAlarmClock alarmClock;
44.8 -
44.9 for (Object[] obj : timerTable.values()) {
44.10
44.11 // Stop all the TimerAlarmClock.
44.12 //
44.13 - alarmClock = (TimerAlarmClock)obj[ALARM_CLOCK_INDEX];
44.14 + TimerAlarmClock alarmClock = (TimerAlarmClock)obj[ALARM_CLOCK_INDEX];
44.15 if (alarmClock != null) {
44.16 // alarmClock.interrupt();
44.17 // try {
44.18 @@ -364,7 +362,6 @@
44.19 // //
44.20
44.21 alarmClock.cancel();
44.22 - alarmClock = null;
44.23 }
44.24 }
44.25
44.26 @@ -458,8 +455,7 @@
44.27
44.28 // Create and add the timer notification into the timer table.
44.29 //
44.30 - Integer notifID = null;
44.31 - notifID = new Integer(++counterID);
44.32 + Integer notifID = Integer.valueOf(++counterID);
44.33
44.34 // The sequenceNumber and the timeStamp attributes are updated
44.35 // when the notification is emitted by the timer.
44.36 @@ -486,8 +482,8 @@
44.37
44.38 obj[TIMER_NOTIF_INDEX] = (Object)notif;
44.39 obj[TIMER_DATE_INDEX] = (Object)d;
44.40 - obj[TIMER_PERIOD_INDEX] = (Object) new Long(period);
44.41 - obj[TIMER_NB_OCCUR_INDEX] = (Object) new Long(nbOccurences);
44.42 + obj[TIMER_PERIOD_INDEX] = (Object) period;
44.43 + obj[TIMER_NB_OCCUR_INDEX] = (Object) nbOccurences;
44.44 obj[ALARM_CLOCK_INDEX] = (Object)alarmClock;
44.45 obj[FIXED_RATE_INDEX] = Boolean.valueOf(fixedRate);
44.46
44.47 @@ -678,7 +674,6 @@
44.48 // // Remove the reference on the TimerAlarmClock.
44.49 // //
44.50 alarmClock.cancel();
44.51 - alarmClock = null;
44.52 }
44.53
44.54 // Remove the timer notification from the timer table.
44.55 @@ -755,7 +750,6 @@
44.56 //
44.57 // }
44.58 alarmClock.cancel();
44.59 - alarmClock = null;
44.60 }
44.61
44.62 // Remove all the timer notifications from the timer table.
44.63 @@ -906,8 +900,7 @@
44.64
44.65 Object[] obj = timerTable.get(id);
44.66 if (obj != null) {
44.67 - Long period = (Long)obj[TIMER_PERIOD_INDEX];
44.68 - return (new Long(period.longValue()));
44.69 + return (Long)obj[TIMER_PERIOD_INDEX];
44.70 }
44.71 return null;
44.72 }
44.73 @@ -924,8 +917,7 @@
44.74
44.75 Object[] obj = timerTable.get(id);
44.76 if (obj != null) {
44.77 - Long nbOccurences = (Long)obj[TIMER_NB_OCCUR_INDEX];
44.78 - return (new Long(nbOccurences.longValue()));
44.79 + return (Long)obj[TIMER_NB_OCCUR_INDEX];
44.80 }
44.81 return null;
44.82 }
44.83 @@ -1096,7 +1088,7 @@
44.84 if ((nbOccurences.longValue() == 0) || (nbOccurences.longValue() > 1)) {
44.85
44.86 date.setTime(date.getTime() + period.longValue());
44.87 - obj[TIMER_NB_OCCUR_INDEX] = new Long(java.lang.Math.max(0L, (nbOccurences.longValue() - 1)));
44.88 + obj[TIMER_NB_OCCUR_INDEX] = Long.valueOf(java.lang.Math.max(0L, (nbOccurences.longValue() - 1)));
44.89 nbOccurences = (Long)obj[TIMER_NB_OCCUR_INDEX];
44.90
44.91 if (isActive == true) {
44.92 @@ -1146,9 +1138,6 @@
44.93 // // Ignore...
44.94 // }
44.95 alarmClock.cancel();
44.96 - // Remove the reference on the TimerAlarmClock.
44.97 - //
44.98 - alarmClock = null;
44.99 }
44.100 timerTable.remove(notifID);
44.101 }
44.102 @@ -1165,10 +1154,6 @@
44.103 // }
44.104
44.105 alarmClock.cancel();
44.106 -
44.107 - // Remove the reference on the TimerAlarmClock.
44.108 - //
44.109 - alarmClock = null;
44.110 }
44.111 timerTable.remove(notifID);
44.112 }
45.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
45.2 +++ b/test/javax/management/relation/RelationNotificationSeqNoTest.java Tue Jun 03 11:18:33 2008 -0700
45.3 @@ -0,0 +1,112 @@
45.4 +/*
45.5 + * Copyright 2005 Sun Microsystems, Inc. All Rights Reserved.
45.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
45.7 + *
45.8 + * This code is free software; you can redistribute it and/or modify it
45.9 + * under the terms of the GNU General Public License version 2 only, as
45.10 + * published by the Free Software Foundation.
45.11 + *
45.12 + * This code is distributed in the hope that it will be useful, but WITHOUT
45.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
45.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
45.15 + * version 2 for more details (a copy is included in the LICENSE file that
45.16 + * accompanied this code).
45.17 + *
45.18 + * You should have received a copy of the GNU General Public License version
45.19 + * 2 along with this work; if not, write to the Free Software Foundation,
45.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
45.21 + *
45.22 + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
45.23 + * CA 95054 USA or visit www.sun.com if you need additional information or
45.24 + * have any questions.
45.25 + */
45.26 +
45.27 +/*
45.28 + * @test
45.29 + * @bug 6701459
45.30 + * @summary Test sequence numbers in RelationService notifications.
45.31 + * @author Eamonn McManus
45.32 + */
45.33 +
45.34 +/*
45.35 + * Bug 6701459 is for a synchronization problem that is very unlikely to occur
45.36 + * in practice and it would be very hard to test it. Instead we just check that
45.37 + * the fix has not introduced any obviously-wrong behavior in the sequence
45.38 + * numbers.
45.39 + */
45.40 +
45.41 +import java.util.Arrays;
45.42 +import java.util.concurrent.ArrayBlockingQueue;
45.43 +import java.util.concurrent.BlockingQueue;
45.44 +import javax.management.JMX;
45.45 +import javax.management.MBeanServer;
45.46 +import javax.management.MBeanServerFactory;
45.47 +import javax.management.Notification;
45.48 +import javax.management.NotificationListener;
45.49 +import javax.management.ObjectName;
45.50 +import javax.management.relation.RelationServiceMBean;
45.51 +import javax.management.relation.Role;
45.52 +import javax.management.relation.RoleInfo;
45.53 +import javax.management.relation.RoleList;
45.54 +
45.55 +public class RelationNotificationSeqNoTest {
45.56 + public static void main(String[] args) throws Exception {
45.57 + MBeanServer mbs = MBeanServerFactory.newMBeanServer();
45.58 + ObjectName relSvcName = new ObjectName("a:type=relationService");
45.59 + RelationServiceMBean relSvc =
45.60 + JMX.newMBeanProxy(mbs, relSvcName, RelationServiceMBean.class);
45.61 + mbs.createMBean("javax.management.relation.RelationService",
45.62 + relSvcName,
45.63 + new Object[] {Boolean.TRUE},
45.64 + new String[] {"boolean"});
45.65 +
45.66 + final BlockingQueue<Notification> q =
45.67 + new ArrayBlockingQueue<Notification>(100);
45.68 + NotificationListener qListener = new NotificationListener() {
45.69 + public void handleNotification(Notification notification,
45.70 + Object handback) {
45.71 + q.add(notification);
45.72 + }
45.73 + };
45.74 + mbs.addNotificationListener(relSvcName, qListener, null, null);
45.75 +
45.76 + RoleInfo leftInfo =
45.77 + new RoleInfo("left", "javax.management.timer.TimerMBean");
45.78 + RoleInfo rightInfo =
45.79 + new RoleInfo("right", "javax.management.timer.Timer");
45.80 + relSvc.createRelationType("typeName", new RoleInfo[] {leftInfo, rightInfo});
45.81 + ObjectName timer1 = new ObjectName("a:type=timer,number=1");
45.82 + ObjectName timer2 = new ObjectName("a:type=timer,number=2");
45.83 + mbs.createMBean("javax.management.timer.Timer", timer1);
45.84 + mbs.createMBean("javax.management.timer.Timer", timer2);
45.85 +
45.86 + Role leftRole =
45.87 + new Role("left", Arrays.asList(new ObjectName[] {timer1}));
45.88 + Role rightRole =
45.89 + new Role("right", Arrays.asList(new ObjectName[] {timer2}));
45.90 + RoleList roles =
45.91 + new RoleList(Arrays.asList(new Role[] {leftRole, rightRole}));
45.92 +
45.93 + final int NREPEAT = 10;
45.94 +
45.95 + for (int i = 0; i < NREPEAT; i++) {
45.96 + relSvc.createRelation("relationName", "typeName", roles);
45.97 + relSvc.removeRelation("relationName");
45.98 + }
45.99 +
45.100 + Notification firstNotif = q.remove();
45.101 + long seqNo = firstNotif.getSequenceNumber();
45.102 + for (int i = 0; i < NREPEAT * 2 - 1; i++) {
45.103 + Notification n = q.remove();
45.104 + long nSeqNo = n.getSequenceNumber();
45.105 + if (nSeqNo != seqNo + 1) {
45.106 + throw new Exception(
45.107 + "TEST FAILED: expected seqNo " + (seqNo + 1) + "; got " +
45.108 + nSeqNo);
45.109 + }
45.110 + seqNo++;
45.111 + }
45.112 + System.out.println("TEST PASSED: got " + (NREPEAT * 2) + " notifications " +
45.113 + "with contiguous sequence numbers");
45.114 + }
45.115 +}