8048874: Replace uses of 'new Byte', 'new Short' and 'new Character' with appropriate alternative across core classes

Reviewed-by: chegar, psandoz, prappo
This commit is contained in:
Otavio Santana 2014-07-01 14:44:37 +01:00 committed by Pavel Rappo
parent 4da668378d
commit 5a0450feea
16 changed files with 43 additions and 44 deletions

View File

@ -1102,8 +1102,7 @@ public class WindowsLookAndFeel extends BasicLookAndFeel
"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,

View File

@ -140,7 +140,7 @@ public class SnmpString extends SnmpValue {
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 ;
}

View File

@ -379,7 +379,7 @@ public class SearchFilter implements AttrFilter {
// 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;
}

View File

@ -1460,7 +1460,7 @@ abstract class DigestMD5Base extends AbstractSaslImpl {
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;
}

View File

@ -241,7 +241,7 @@ final class GssKrb5Client extends GssKrb5Base implements SaslClient {
"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 @@ final class GssKrb5Client extends GssKrb5Base implements SaslClient {
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)});
}

View File

@ -221,7 +221,7 @@ final class GssKrb5Server extends GssKrb5Base implements SaslServer {
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 @@ final class GssKrb5Server extends GssKrb5Base implements SaslServer {
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,

View File

@ -77,7 +77,7 @@ public abstract class AbstractSaslImpl {
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();

View File

@ -8640,7 +8640,7 @@ public abstract class Component implements ImageObserver, MenuContainer,
if (changeSupport == null || oldValue == newValue) {
return;
}
firePropertyChange(propertyName, new Character(oldValue), new Character(newValue));
firePropertyChange(propertyName, Character.valueOf(oldValue), Character.valueOf(newValue));
}
/**

View File

@ -337,7 +337,7 @@ public class ParameterBlock implements Cloneable, Serializable {
* the specified parameter.
*/
public ParameterBlock add(byte b) {
return add(new Byte(b));
return add(Byte.valueOf(b));
}
/**
@ -348,7 +348,7 @@ public class ParameterBlock implements Cloneable, Serializable {
* the specified parameter.
*/
public ParameterBlock add(char c) {
return add(new Character(c));
return add(Character.valueOf(c));
}
/**
@ -359,7 +359,7 @@ public class ParameterBlock implements Cloneable, Serializable {
* the specified parameter.
*/
public ParameterBlock add(short s) {
return add(new Short(s));
return add(Short.valueOf(s));
}
/**
@ -441,7 +441,7 @@ public class ParameterBlock implements Cloneable, Serializable {
* 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 @@ public class ParameterBlock implements Cloneable, Serializable {
* 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 @@ public class ParameterBlock implements Cloneable, Serializable {
* the specified parameter.
*/
public ParameterBlock set(short s, int index) {
return set(new Short(s), index);
return set(Short.valueOf(s), index);
}
/**

View File

@ -248,7 +248,7 @@ public class Statement {
// 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);

View File

@ -1307,9 +1307,9 @@ public class MLet extends java.net.URLClassLoader
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)

View File

@ -139,7 +139,7 @@ public class JvmThreadInstanceEntryImpl
"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;
}
}

View File

@ -1885,7 +1885,7 @@ public class ProxyGenerator {
"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 @@ public class ProxyGenerator {
throw new InternalError("late constant pool addition");
}
short i = addEntry(e);
map.put(e, new Short(i));
map.put(e, i);
return i;
}
}

View File

@ -309,26 +309,26 @@ public class PKCS9Attribute implements DerEncoder {
*/
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 @@ public class PKCS9Attribute implements DerEncoder {
// 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);

View File

@ -517,7 +517,7 @@ public class AVA implements DerEncoder {
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");

View File

@ -342,14 +342,14 @@ public class Utils {
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")) {