8048874: Replace uses of 'new Byte', 'new Short' and 'new Character' with appropriate alternative across core classes
authorprappo
Tue, 01 Jul 2014 14:44:37 +0100
changeset 25187 08aff438def8
parent 25186 63e1a2ec30f5
child 25188 e680ab7f208e
8048874: Replace uses of 'new Byte', 'new Short' and 'new Character' with appropriate alternative across core classes Reviewed-by: chegar, psandoz, prappo Contributed-by: Otavio Santana <otaviojava@java.net>
jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java
jdk/src/share/classes/com/sun/jmx/snmp/SnmpString.java
jdk/src/share/classes/com/sun/jndi/toolkit/dir/SearchFilter.java
jdk/src/share/classes/com/sun/security/sasl/digest/DigestMD5Base.java
jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Client.java
jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Server.java
jdk/src/share/classes/com/sun/security/sasl/util/AbstractSaslImpl.java
jdk/src/share/classes/java/awt/Component.java
jdk/src/share/classes/java/awt/image/renderable/ParameterBlock.java
jdk/src/share/classes/java/beans/Statement.java
jdk/src/share/classes/javax/management/loading/MLet.java
jdk/src/share/classes/sun/management/snmp/jvminstr/JvmThreadInstanceEntryImpl.java
jdk/src/share/classes/sun/misc/ProxyGenerator.java
jdk/src/share/classes/sun/security/pkcs/PKCS9Attribute.java
jdk/src/share/classes/sun/security/x509/AVA.java
jdk/src/share/classes/sun/tools/jconsole/inspector/Utils.java
--- a/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Tue Jul 01 15:12:59 2014 +0100
+++ b/jdk/src/share/classes/com/sun/java/swing/plaf/windows/WindowsLookAndFeel.java	Tue Jul 01 14:44:37 2014 +0100
@@ -1102,8 +1102,7 @@
             "PasswordField.selectionBackground", SelectionBackgroundColor,
             "PasswordField.selectionForeground", SelectionTextColor,
             "PasswordField.caretForeground",WindowTextColor,
-            "PasswordField.echoChar", new XPValue(new Character((char)0x25CF),
-                                                  new Character('*')),
+            "PasswordField.echoChar", new XPValue((char)0x25CF, '*'),
 
             // *** ProgressBar
             "ProgressBar.font", ControlFont,
--- a/jdk/src/share/classes/com/sun/jmx/snmp/SnmpString.java	Tue Jul 01 15:12:59 2014 +0100
+++ b/jdk/src/share/classes/com/sun/jmx/snmp/SnmpString.java	Tue Jul 01 14:44:37 2014 +0100
@@ -140,7 +140,7 @@
     public Byte[] toByte() {
         Byte[] result = new Byte[value.length] ;
         for (int i = 0 ; i < value.length ; i++) {
-            result[i] = new Byte(value[i]) ;
+            result[i] = value[i];
         }
         return result ;
     }
--- a/jdk/src/share/classes/com/sun/jndi/toolkit/dir/SearchFilter.java	Tue Jul 01 15:12:59 2014 +0100
+++ b/jdk/src/share/classes/com/sun/jndi/toolkit/dir/SearchFilter.java	Tue Jul 01 14:44:37 2014 +0100
@@ -379,7 +379,7 @@
         // used for substring comparisons (where proto has "*" wildcards
         private boolean substringMatch(String proto, String value) {
             // simple case 1: "*" means attribute presence is being tested
-            if(proto.equals(new Character(WILDCARD_TOKEN).toString())) {
+            if(proto.equals(Character.toString(WILDCARD_TOKEN))) {
                 if(debug) {System.out.println("simple presence assertion");}
                 return true;
             }
--- a/jdk/src/share/classes/com/sun/security/sasl/digest/DigestMD5Base.java	Tue Jul 01 15:12:59 2014 +0100
+++ b/jdk/src/share/classes/com/sun/security/sasl/digest/DigestMD5Base.java	Tue Jul 01 14:44:37 2014 +0100
@@ -1460,7 +1460,7 @@
                     if (logger.isLoggable(Level.INFO)) {
                         logger.log(Level.INFO,
                             "DIGEST39:Incorrect padding: {0}",
-                            new Byte(msgWithPadding[msgWithPadding.length - 1]));
+                            msgWithPadding[msgWithPadding.length - 1]);
                     }
                     return EMPTY_BYTE_ARRAY;
                 }
--- a/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Client.java	Tue Jul 01 15:12:59 2014 +0100
+++ b/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Client.java	Tue Jul 01 14:44:37 2014 +0100
@@ -241,7 +241,7 @@
                         "KRB5CLNT05:Challenge [unwrapped]:", gssOutToken);
                 }
                 logger.log(Level.FINE, "KRB5CLNT06:Server protections: {0}",
-                    new Byte(gssOutToken[0]));
+                    gssOutToken[0]);
             }
 
             // Client selects preferred protection
@@ -293,7 +293,7 @@
             if (logger.isLoggable(Level.FINE)) {
                 logger.log(Level.FINE,
             "KRB5CLNT08:Selected protection: {0}; privacy: {1}; integrity: {2}",
-                    new Object[]{new Byte(selectedQop),
+                    new Object[]{selectedQop,
                                  Boolean.valueOf(privacy),
                                  Boolean.valueOf(integrity)});
             }
--- a/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Server.java	Tue Jul 01 15:12:59 2014 +0100
+++ b/jdk/src/share/classes/com/sun/security/sasl/gsskerb/GssKrb5Server.java	Tue Jul 01 14:44:37 2014 +0100
@@ -221,7 +221,7 @@
             if (logger.isLoggable(Level.FINE)) {
                 logger.log(Level.FINE,
                     "KRB5SRV06:Supported protections: {0}; recv max buf size: {1}",
-                    new Object[]{new Byte(allQop),
+                    new Object[]{allQop,
                                  new Integer(recvMaxBufSize)});
             }
 
@@ -288,7 +288,7 @@
             if (logger.isLoggable(Level.FINE)) {
                 logger.log(Level.FINE,
             "KRB5SRV10:Selected protection: {0}; privacy: {1}; integrity: {2}",
-                    new Object[]{new Byte(selectedQop),
+                    new Object[]{selectedQop,
                                  Boolean.valueOf(privacy),
                                  Boolean.valueOf(integrity)});
                 logger.log(Level.FINE,
--- a/jdk/src/share/classes/com/sun/security/sasl/util/AbstractSaslImpl.java	Tue Jul 01 15:12:59 2014 +0100
+++ b/jdk/src/share/classes/com/sun/security/sasl/util/AbstractSaslImpl.java	Tue Jul 01 14:44:37 2014 +0100
@@ -77,7 +77,7 @@
 
             if (logger.isLoggable(Level.FINE)) {
                 logger.logp(Level.FINE, myClassName, "constructor",
-                    "SASLIMPL02:Preferred qop mask: {0}", new Byte(allQop));
+                    "SASLIMPL02:Preferred qop mask: {0}", allQop);
 
                 if (qop.length > 0) {
                     StringBuilder str = new StringBuilder();
--- a/jdk/src/share/classes/java/awt/Component.java	Tue Jul 01 15:12:59 2014 +0100
+++ b/jdk/src/share/classes/java/awt/Component.java	Tue Jul 01 14:44:37 2014 +0100
@@ -8640,7 +8640,7 @@
         if (changeSupport == null || oldValue == newValue) {
             return;
         }
-        firePropertyChange(propertyName, new Character(oldValue), new Character(newValue));
+        firePropertyChange(propertyName, Character.valueOf(oldValue), Character.valueOf(newValue));
     }
 
     /**
--- a/jdk/src/share/classes/java/awt/image/renderable/ParameterBlock.java	Tue Jul 01 15:12:59 2014 +0100
+++ b/jdk/src/share/classes/java/awt/image/renderable/ParameterBlock.java	Tue Jul 01 14:44:37 2014 +0100
@@ -337,7 +337,7 @@
      *         the specified parameter.
      */
     public ParameterBlock add(byte b) {
-        return add(new Byte(b));
+        return add(Byte.valueOf(b));
     }
 
     /**
@@ -348,7 +348,7 @@
      *         the specified parameter.
      */
     public ParameterBlock add(char c) {
-        return add(new Character(c));
+        return add(Character.valueOf(c));
     }
 
     /**
@@ -359,7 +359,7 @@
      *         the specified parameter.
      */
     public ParameterBlock add(short s) {
-        return add(new Short(s));
+        return add(Short.valueOf(s));
     }
 
     /**
@@ -441,7 +441,7 @@
      *        the specified parameter.
      */
     public ParameterBlock set(byte b, int index) {
-        return set(new Byte(b), index);
+        return set(Byte.valueOf(b), index);
     }
 
     /**
@@ -457,7 +457,7 @@
      *        the specified parameter.
      */
     public ParameterBlock set(char c, int index) {
-        return set(new Character(c), index);
+        return set(Character.valueOf(c), index);
     }
 
     /**
@@ -473,7 +473,7 @@
      *        the specified parameter.
      */
     public ParameterBlock set(short s, int index) {
-        return set(new Short(s), index);
+        return set(Short.valueOf(s), index);
     }
 
     /**
--- a/jdk/src/share/classes/java/beans/Statement.java	Tue Jul 01 15:12:59 2014 +0100
+++ b/jdk/src/share/classes/java/beans/Statement.java	Tue Jul 01 14:44:37 2014 +0100
@@ -248,7 +248,7 @@
                 // ignored elsewhere.
                 if (target == Character.class && arguments.length == 1 &&
                     argClasses[0] == String.class) {
-                    return new Character(((String)arguments[0]).charAt(0));
+                    return ((String)arguments[0]).charAt(0);
                 }
                 try {
                     m = ConstructorFinder.findConstructor((Class)target, argClasses);
--- a/jdk/src/share/classes/javax/management/loading/MLet.java	Tue Jul 01 15:12:59 2014 +0100
+++ b/jdk/src/share/classes/javax/management/loading/MLet.java	Tue Jul 01 14:44:37 2014 +0100
@@ -1307,9 +1307,9 @@
         if (type.compareTo("java.lang.Boolean") == 0)
              return Boolean.valueOf(param);
         if (type.compareTo("java.lang.Byte") == 0)
-             return new Byte(param);
+             return Byte.valueOf(param);
         if (type.compareTo("java.lang.Short") == 0)
-             return new Short(param);
+             return Short.valueOf(param);
         if (type.compareTo("java.lang.Long") == 0)
              return Long.valueOf(param);
         if (type.compareTo("java.lang.Integer") == 0)
--- a/jdk/src/share/classes/sun/management/snmp/jvminstr/JvmThreadInstanceEntryImpl.java	Tue Jul 01 15:12:59 2014 +0100
+++ b/jdk/src/share/classes/sun/management/snmp/jvminstr/JvmThreadInstanceEntryImpl.java	Tue Jul 01 14:44:37 2014 +0100
@@ -139,7 +139,7 @@
                           "Unexpected exception: " + r);
                 log.debug("getJvmThreadInstState",r);
             }
-            Byte[] result = { new Byte(bitmap[0]), new Byte(bitmap[1]) };
+            Byte[] result = {bitmap[0], bitmap[1]};
             return result;
         }
     }
--- a/jdk/src/share/classes/sun/misc/ProxyGenerator.java	Tue Jul 01 15:12:59 2014 +0100
+++ b/jdk/src/share/classes/sun/misc/ProxyGenerator.java	Tue Jul 01 14:44:37 2014 +0100
@@ -1885,7 +1885,7 @@
                         "late constant pool addition: " + key);
                 }
                 short i = addEntry(new ValueEntry(key));
-                map.put(key, new Short(i));
+                map.put(key, i);
                 return i;
             }
         }
@@ -1903,7 +1903,7 @@
                     throw new InternalError("late constant pool addition");
                 }
                 short i = addEntry(e);
-                map.put(e, new Short(i));
+                map.put(e, i);
                 return i;
             }
         }
--- a/jdk/src/share/classes/sun/security/pkcs/PKCS9Attribute.java	Tue Jul 01 15:12:59 2014 +0100
+++ b/jdk/src/share/classes/sun/security/pkcs/PKCS9Attribute.java	Tue Jul 01 14:44:37 2014 +0100
@@ -309,26 +309,26 @@
      */
     private static final Byte[][] PKCS9_VALUE_TAGS = {
         null,
-        {new Byte(DerValue.tag_IA5String)},   // EMailAddress
-        {new Byte(DerValue.tag_IA5String),   // UnstructuredName
-         new Byte(DerValue.tag_PrintableString)},
-        {new Byte(DerValue.tag_ObjectId)},    // ContentType
-        {new Byte(DerValue.tag_OctetString)}, // MessageDigest
-        {new Byte(DerValue.tag_UtcTime)},     // SigningTime
-        {new Byte(DerValue.tag_Sequence)},    // Countersignature
-        {new Byte(DerValue.tag_PrintableString),
-         new Byte(DerValue.tag_T61String)},   // ChallengePassword
-        {new Byte(DerValue.tag_PrintableString),
-         new Byte(DerValue.tag_T61String)},   // UnstructuredAddress
-        {new Byte(DerValue.tag_SetOf)},       // ExtendedCertificateAttributes
-        {new Byte(DerValue.tag_Sequence)},    // issuerAndSerialNumber
+        {DerValue.tag_IA5String},   // EMailAddress
+        {DerValue.tag_IA5String,   // UnstructuredName
+         DerValue.tag_PrintableString},
+        {DerValue.tag_ObjectId},    // ContentType
+        {DerValue.tag_OctetString}, // MessageDigest
+        {DerValue.tag_UtcTime},     // SigningTime
+        {DerValue.tag_Sequence},    // Countersignature
+        {DerValue.tag_PrintableString,
+         DerValue.tag_T61String},   // ChallengePassword
+        {DerValue.tag_PrintableString,
+         DerValue.tag_T61String},   // UnstructuredAddress
+        {DerValue.tag_SetOf},       // ExtendedCertificateAttributes
+        {DerValue.tag_Sequence},    // issuerAndSerialNumber
         null,
         null,
         null,
-        {new Byte(DerValue.tag_Sequence)},    // extensionRequest
-        {new Byte(DerValue.tag_Sequence)},    // SMIMECapability
-        {new Byte(DerValue.tag_Sequence)},    // SigningCertificate
-        {new Byte(DerValue.tag_Sequence)}     // SignatureTimestampToken
+        {DerValue.tag_Sequence},    // extensionRequest
+        {DerValue.tag_Sequence},    // SMIMECapability
+        {DerValue.tag_Sequence},    // SigningCertificate
+        {DerValue.tag_Sequence}     // SignatureTimestampToken
     };
 
     private static final Class<?>[] VALUE_CLASSES = new Class<?>[18];
@@ -511,7 +511,7 @@
         // check for illegal element tags
         Byte tag;
         for (int i=0; i < elems.length; i++) {
-            tag = new Byte(elems[i].tag);
+            tag = elems[i].tag;
 
             if (indexOf(tag, PKCS9_VALUE_TAGS[index], 0) == -1)
                 throwTagException(tag);
--- a/jdk/src/share/classes/sun/security/x509/AVA.java	Tue Jul 01 15:12:59 2014 +0100
+++ b/jdk/src/share/classes/sun/security/x509/AVA.java	Tue Jul 01 14:44:37 2014 +0100
@@ -517,7 +517,7 @@
             if (hexDigits.indexOf(Character.toUpperCase((char)c2)) >= 0) {
                 int hi = Character.digit((char)c1, 16);
                 int lo = Character.digit((char)c2, 16);
-                return new Byte((byte)((hi<<4) + lo));
+                return (byte)((hi<<4) + lo);
             } else {
                 throw new IOException
                         ("escaped hex value must include two valid digits");
--- a/jdk/src/share/classes/sun/tools/jconsole/inspector/Utils.java	Tue Jul 01 15:12:59 2014 +0100
+++ b/jdk/src/share/classes/sun/tools/jconsole/inspector/Utils.java	Tue Jul 01 14:44:37 2014 +0100
@@ -342,14 +342,14 @@
         Object result;
         if (primitiveToWrapper.containsKey(type)) {
             if (type.equals(Character.TYPE.getName())) {
-                result = new Character(value.charAt(0));
+                result = value.charAt(0);
             } else {
                 result = newStringConstructor(
                         ((Class<?>) primitiveToWrapper.get(type)).getName(),
                         value);
             }
         } else if (type.equals(Character.class.getName())) {
-            result = new Character(value.charAt(0));
+            result = value.charAt(0);
         } else if (Number.class.isAssignableFrom(Utils.getClass(type))) {
             result = createNumberFromStringValue(value);
         } else if (value == null || value.equals("null")) {