Rewrite all backwards comparisons.
Strictly, all the ones I could find. This is everything with 0 or null on the
left-hand side.
Note that this touches several incorrect bounds checks, which I haven't fixed:
I'm going to come back and finish that independent cleanup separately.
Change-Id: Ibdb054b53df9aace47c7d2a00ff19122190053e8
diff --git a/luni/src/main/java/java/io/CharArrayWriter.java b/luni/src/main/java/java/io/CharArrayWriter.java
index 8bca96f..4efd5a3 100644
--- a/luni/src/main/java/java/io/CharArrayWriter.java
+++ b/luni/src/main/java/java/io/CharArrayWriter.java
@@ -279,11 +279,10 @@
*/
@Override
public CharArrayWriter append(CharSequence csq) {
- if (null == csq) {
- append(TOKEN_NULL, 0, TOKEN_NULL.length());
- } else {
- append(csq, 0, csq.length());
+ if (csq == null) {
+ csq = "null";
}
+ append(csq, 0, csq.length());
return this;
}
@@ -312,8 +311,8 @@
*/
@Override
public CharArrayWriter append(CharSequence csq, int start, int end) {
- if (null == csq) {
- csq = TOKEN_NULL;
+ if (csq == null) {
+ csq = "null";
}
String output = csq.subSequence(start, end).toString();
write(output, 0, output.length());
diff --git a/luni/src/main/java/java/io/ObjectInputStream.java b/luni/src/main/java/java/io/ObjectInputStream.java
index 14b83b6..afeb929 100644
--- a/luni/src/main/java/java/io/ObjectInputStream.java
+++ b/luni/src/main/java/java/io/ObjectInputStream.java
@@ -1203,7 +1203,7 @@
private void readFieldValues(Object obj, ObjectStreamClass classDesc) throws OptionalDataException, ClassNotFoundException, IOException {
// Now we must read all fields and assign them to the receiver
ObjectStreamField[] fields = classDesc.getLoadFields();
- fields = (null == fields ? ObjectStreamClass.NO_FIELDS : fields);
+ fields = (fields == null) ? ObjectStreamClass.NO_FIELDS : fields;
Class<?> declaringClass = classDesc.forClass();
if (declaringClass == null && mustResolve) {
throw new ClassNotFoundException(classDesc.getName());
@@ -1812,7 +1812,7 @@
// Resolve the field signatures using the class loader of the
// resolved class
ObjectStreamField[] fields = newClassDesc.getLoadFields();
- fields = (null == fields ? ObjectStreamClass.NO_FIELDS : fields);
+ fields = (fields == null) ? ObjectStreamClass.NO_FIELDS : fields;
ClassLoader loader = newClassDesc.forClass() == null ? callerClassLoader
: newClassDesc.forClass().getClassLoader();
for (ObjectStreamField element : fields) {
@@ -1875,7 +1875,7 @@
* descriptors. If called outside of readObject, the descriptorHandle
* might be null.
*/
- descriptorHandle = (null == descriptorHandle ? nextHandle() : descriptorHandle);
+ descriptorHandle = (descriptorHandle == null) ? nextHandle() : descriptorHandle;
registerObjectRead(newClassDesc, descriptorHandle, false);
readFieldDescriptors(newClassDesc);
@@ -2520,14 +2520,14 @@
throws IOException, ClassNotFoundException {
// fastpath: obtain cached value
Class<?> cls = osClass.forClass();
- if (null == cls) {
+ if (cls == null) {
// slowpath: resolve the class
String className = osClass.getName();
// if it is primitive class, for example, long.class
cls = PRIMITIVE_CLASSES.get(className);
- if (null == cls) {
+ if (cls == null) {
// not primitive class
// Use the first non-null ClassLoader on the stack. If null, use
// the system class loader
diff --git a/luni/src/main/java/java/io/ObjectOutputStream.java b/luni/src/main/java/java/io/ObjectOutputStream.java
index d074350..3d173fa 100644
--- a/luni/src/main/java/java/io/ObjectOutputStream.java
+++ b/luni/src/main/java/java/io/ObjectOutputStream.java
@@ -1834,7 +1834,7 @@
output.writeByte(TC_ENDBLOCKDATA);
// write super class
ObjectStreamClass superClassDesc = classDesc.getSuperclass();
- if (null != superClassDesc) {
+ if (superClassDesc != null) {
// super class is also enum
superClassDesc.setFlags((byte) (SC_SERIALIZABLE | SC_ENUM));
writeEnumDesc(superClassDesc.forClass(), superClassDesc, unshared);
diff --git a/luni/src/main/java/java/io/PrintStream.java b/luni/src/main/java/java/io/PrintStream.java
index d1b4f94..42e6750 100644
--- a/luni/src/main/java/java/io/PrintStream.java
+++ b/luni/src/main/java/java/io/PrintStream.java
@@ -35,9 +35,6 @@
* has occurred in this stream.
*/
public class PrintStream extends FilterOutputStream implements Appendable, Closeable {
-
- private static final String TOKEN_NULL = "null";
-
/**
* indicates whether or not this PrintStream has incurred an error.
*/
@@ -734,8 +731,8 @@
* @return this stream.
*/
public PrintStream append(CharSequence csq) {
- if (null == csq) {
- print(TOKEN_NULL);
+ if (csq == null) {
+ print("null");
} else {
print(csq.toString());
}
@@ -764,11 +761,10 @@
* the length of {@code csq}.
*/
public PrintStream append(CharSequence csq, int start, int end) {
- if (null == csq) {
- print(TOKEN_NULL.substring(start, end));
- } else {
- print(csq.subSequence(start, end).toString());
+ if (csq == null) {
+ csq = "null";
}
+ print(csq.subSequence(start, end).toString());
return this;
}
}
diff --git a/luni/src/main/java/java/io/PrintWriter.java b/luni/src/main/java/java/io/PrintWriter.java
index da54b48..3bc14b8 100644
--- a/luni/src/main/java/java/io/PrintWriter.java
+++ b/luni/src/main/java/java/io/PrintWriter.java
@@ -752,11 +752,10 @@
*/
@Override
public PrintWriter append(CharSequence csq) {
- if (null == csq) {
- append(TOKEN_NULL, 0, TOKEN_NULL.length());
- } else {
- append(csq, 0, csq.length());
+ if (csq == null) {
+ csq = "null";
}
+ append(csq, 0, csq.length());
return this;
}
@@ -783,8 +782,8 @@
*/
@Override
public PrintWriter append(CharSequence csq, int start, int end) {
- if (null == csq) {
- csq = TOKEN_NULL;
+ if (csq == null) {
+ csq = "null";
}
String output = csq.subSequence(start, end).toString();
write(output, 0, output.length());
diff --git a/luni/src/main/java/java/io/Reader.java b/luni/src/main/java/java/io/Reader.java
index 4c4ce06..940a4ec 100644
--- a/luni/src/main/java/java/io/Reader.java
+++ b/luni/src/main/java/java/io/Reader.java
@@ -263,9 +263,6 @@
* if {@code target} is read-only.
*/
public int read(CharBuffer target) throws IOException {
- if (null == target) {
- throw new NullPointerException();
- }
int length = target.length();
char[] buf = new char[length];
length = Math.min(length, read(buf));
diff --git a/luni/src/main/java/java/io/StreamTokenizer.java b/luni/src/main/java/java/io/StreamTokenizer.java
index c740a7c..36c42bf 100644
--- a/luni/src/main/java/java/io/StreamTokenizer.java
+++ b/luni/src/main/java/java/io/StreamTokenizer.java
@@ -205,7 +205,7 @@
* the character to be considered a comment character.
*/
public void commentChar(int ch) {
- if (0 <= ch && ch < tokenTypes.length) {
+ if (ch >= 0 && ch < tokenTypes.length) {
tokenTypes[ch] = TOKEN_COMMENT;
}
}
@@ -486,7 +486,7 @@
* the character to be considered an ordinary character.
*/
public void ordinaryChar(int ch) {
- if (0 <= ch && ch < tokenTypes.length) {
+ if (ch >= 0 && ch < tokenTypes.length) {
tokenTypes[ch] = 0;
}
}
@@ -541,7 +541,7 @@
* the character to be considered a quote character.
*/
public void quoteChar(int ch) {
- if (0 <= ch && ch < tokenTypes.length) {
+ if (ch >= 0 && ch < tokenTypes.length) {
tokenTypes[ch] = TOKEN_QUOTE;
}
}
diff --git a/luni/src/main/java/java/io/StringWriter.java b/luni/src/main/java/java/io/StringWriter.java
index 6fb0dda..e87c9eb 100644
--- a/luni/src/main/java/java/io/StringWriter.java
+++ b/luni/src/main/java/java/io/StringWriter.java
@@ -204,11 +204,10 @@
*/
@Override
public StringWriter append(CharSequence csq) {
- if (null == csq) {
- write(TOKEN_NULL);
- } else {
- write(csq.toString());
+ if (csq == null) {
+ csq = "null";
}
+ write(csq.toString());
return this;
}
@@ -235,8 +234,8 @@
*/
@Override
public StringWriter append(CharSequence csq, int start, int end) {
- if (null == csq) {
- csq = TOKEN_NULL;
+ if (csq == null) {
+ csq = "null";
}
String output = csq.subSequence(start, end).toString();
write(output, 0, output.length());
diff --git a/luni/src/main/java/java/io/Writer.java b/luni/src/main/java/java/io/Writer.java
index 84b90dbb..d1ff429 100644
--- a/luni/src/main/java/java/io/Writer.java
+++ b/luni/src/main/java/java/io/Writer.java
@@ -35,9 +35,6 @@
* @see Reader
*/
public abstract class Writer implements Appendable, Closeable, Flushable {
-
- static final String TOKEN_NULL = "null";
-
/**
* The object used to synchronize access to the writer.
*/
@@ -207,11 +204,10 @@
* if this writer is closed or another I/O error occurs.
*/
public Writer append(CharSequence csq) throws IOException {
- if (null == csq) {
- write(TOKEN_NULL);
- } else {
- write(csq.toString());
+ if (csq == null) {
+ csq = "null";
}
+ write(csq.toString());
return this;
}
@@ -238,13 +234,11 @@
* either {@code start} or {@code end} are greater or equal than
* the length of {@code csq}.
*/
- public Writer append(CharSequence csq, int start, int end)
- throws IOException {
- if (null == csq) {
- write(TOKEN_NULL.substring(start, end));
- } else {
- write(csq.subSequence(start, end).toString());
+ public Writer append(CharSequence csq, int start, int end) throws IOException {
+ if (csq == null) {
+ csq = "null";
}
+ write(csq.subSequence(start, end).toString());
return this;
}
diff --git a/luni/src/main/java/java/lang/AbstractStringBuilder.java b/luni/src/main/java/java/lang/AbstractStringBuilder.java
index df63cbb..558c1fb 100644
--- a/luni/src/main/java/java/lang/AbstractStringBuilder.java
+++ b/luni/src/main/java/java/lang/AbstractStringBuilder.java
@@ -311,7 +311,7 @@
}
final void insert0(int index, char[] chars) {
- if (0 > index || index > count) {
+ if (index < 0 || index > count) {
throw indexAndLength(index);
}
if (chars.length != 0) {
@@ -322,9 +322,9 @@
}
final void insert0(int index, char[] chars, int start, int length) {
- if (0 <= index && index <= count) {
+ if (index >= 0 && index <= count) {
// start + length could overflow, start/length maybe MaxInt
- if (start >= 0 && 0 <= length && length <= chars.length - start) {
+ if (start >= 0 && length >= 0 && length <= chars.length - start) {
if (length != 0) {
move(length, index);
System.arraycopy(chars, start, value, index, length);
@@ -338,7 +338,7 @@
}
final void insert0(int index, char ch) {
- if (0 > index || index > count) {
+ if (index < 0 || index > count) {
// RI compatible exception type
throw new ArrayIndexOutOfBoundsException("index=" + index + ", length=" + count);
}
@@ -348,7 +348,7 @@
}
final void insert0(int index, String string) {
- if (0 <= index && index <= count) {
+ if (index >= 0 && index <= count) {
if (string == null) {
string = "null";
}
@@ -540,7 +540,7 @@
* current {@link #length()}.
*/
public void setCharAt(int index, char ch) {
- if (0 > index || index >= count) {
+ if (index < 0 || index >= count) {
throw indexAndLength(index);
}
if (shared) {
@@ -594,7 +594,7 @@
* {@link #length()}.
*/
public String substring(int start) {
- if (0 <= start && start <= count) {
+ if (start >= 0 && start <= count) {
if (start == count) {
return "";
}
@@ -619,7 +619,7 @@
* {@code end} is greater than the current {@link #length()}.
*/
public String substring(int start, int end) {
- if (0 <= start && start <= end && end <= count) {
+ if (start >= 0 && start <= end && end <= count) {
if (start == end) {
return "";
}
diff --git a/luni/src/main/java/java/lang/Character.java b/luni/src/main/java/java/lang/Character.java
index 3fb1e82..323fe0f 100644
--- a/luni/src/main/java/java/lang/Character.java
+++ b/luni/src/main/java/java/lang/Character.java
@@ -2422,7 +2422,7 @@
*/
public static char forDigit(int digit, int radix) {
if (MIN_RADIX <= radix && radix <= MAX_RADIX) {
- if (0 <= digit && digit < radix) {
+ if (digit >= 0 && digit < radix) {
return (char) (digit < 10 ? digit + '0' : digit + 'a' - 10);
}
}
diff --git a/luni/src/main/java/java/lang/String.java b/luni/src/main/java/java/lang/String.java
index 0364eba..15c6886 100644
--- a/luni/src/main/java/java/lang/String.java
+++ b/luni/src/main/java/java/lang/String.java
@@ -584,7 +584,7 @@
* if {@code index < 0} or {@code index >= length()}.
*/
public char charAt(int index) {
- if (0 <= index && index < count) {
+ if (index >= 0 && index < count) {
return value[offset + index];
}
throw indexAndLength(index);
@@ -848,7 +848,7 @@
*/
@Deprecated
public void getBytes(int start, int end, byte[] data, int index) {
- if (0 <= start && start <= end && end <= count) {
+ if (start >= 0 && start <= end && end <= count) {
end += offset;
try {
for (int i = offset + start; i < end; i++) {
@@ -936,7 +936,7 @@
*/
public void getChars(int start, int end, char[] buffer, int index) {
// NOTE last character not copied!
- if (0 <= start && start <= end && end <= count) {
+ if (start >= 0 && start <= end && end <= count) {
System.arraycopy(value, start + offset, buffer, index, end - start);
} else {
// We throw StringIndexOutOfBoundsException rather than System.arraycopy's AIOOBE.
@@ -948,7 +948,7 @@
/**
* Version of getChars without bounds checks, for use by other classes
* within the java.lang package only. The caller is responsible for
- * ensuring that 0 <= start && start <= end && end <= count.
+ * ensuring that start >= 0 && start <= end && end <= count.
*/
void _getChars(int start, int end, char[] buffer, int index) {
// NOTE last character not copied!
@@ -1529,7 +1529,7 @@
if (start == 0) {
return this;
}
- if (0 <= start && start <= count) {
+ if (start >= 0 && start <= count) {
return new String(offset + start, count - start, value);
}
throw new StringIndexOutOfBoundsException("start=" + start + " length=" + count);
@@ -1555,7 +1555,7 @@
}
// NOTE last character not copied!
// Fast range check.
- if (0 <= start && start <= end && end <= count) {
+ if (start >= 0 && start <= end && end <= count) {
return new String(offset + start, end - start, value);
}
throw startEndAndLength(start, end);
diff --git a/luni/src/main/java/java/net/Authenticator.java b/luni/src/main/java/java/net/Authenticator.java
index 903f170..3b5fd8c 100644
--- a/luni/src/main/java/java/net/Authenticator.java
+++ b/luni/src/main/java/java/net/Authenticator.java
@@ -272,10 +272,10 @@
String rPrompt, String rScheme, URL rURL,
Authenticator.RequestorType reqType) {
SecurityManager sm = System.getSecurityManager();
- if (null != sm) {
+ if (sm != null) {
sm.checkPermission(requestPasswordAuthenticationPermission);
}
- if (null == thisAuthenticator) {
+ if (thisAuthenticator == null) {
return null;
}
// sets the requester info so it knows what it is requesting
diff --git a/luni/src/main/java/java/net/CookieHandler.java b/luni/src/main/java/java/net/CookieHandler.java
index d3cbb5a..918c34a 100644
--- a/luni/src/main/java/java/net/CookieHandler.java
+++ b/luni/src/main/java/java/net/CookieHandler.java
@@ -40,7 +40,7 @@
*/
public static CookieHandler getDefault() {
SecurityManager sm = System.getSecurityManager();
- if (null != sm) {
+ if (sm != null) {
sm.checkPermission(getCookieHandlerPermission);
}
return systemWideCookieHandler;
@@ -54,7 +54,7 @@
*/
public static void setDefault(CookieHandler cHandler) {
SecurityManager sm = System.getSecurityManager();
- if (null != sm) {
+ if (sm != null) {
sm.checkPermission(setCookieHandlerPermission);
}
systemWideCookieHandler = cHandler;
diff --git a/luni/src/main/java/java/net/DatagramPacket.java b/luni/src/main/java/java/net/DatagramPacket.java
index cde5d7b..a165d94 100644
--- a/luni/src/main/java/java/net/DatagramPacket.java
+++ b/luni/src/main/java/java/net/DatagramPacket.java
@@ -188,8 +188,7 @@
* store the received data.
*/
public synchronized void setData(byte[] buf, int anOffset, int aLength) {
- if (0 > anOffset || anOffset > buf.length || 0 > aLength
- || aLength > buf.length - anOffset) {
+ if (anOffset < 0 || anOffset > buf.length || aLength < 0 || aLength > buf.length - anOffset) {
throw new IllegalArgumentException();
}
data = buf;
@@ -229,7 +228,7 @@
* the length of this datagram packet.
*/
public synchronized void setLength(int len) {
- if (0 > len || offset + len > data.length) {
+ if (len < 0 || offset + len > data.length) {
throw new IndexOutOfBoundsException();
}
length = len;
@@ -243,7 +242,7 @@
* @param len the length of this datagram packet
*/
synchronized void setLengthOnly(int len) {
- if (0 > len || offset + len > data.length) {
+ if (len < 0 || offset + len > data.length) {
throw new IndexOutOfBoundsException();
}
length = len;
diff --git a/luni/src/main/java/java/net/DatagramSocket.java b/luni/src/main/java/java/net/DatagramSocket.java
index 1bfe40e..eece7ce 100644
--- a/luni/src/main/java/java/net/DatagramSocket.java
+++ b/luni/src/main/java/java/net/DatagramSocket.java
@@ -89,7 +89,7 @@
public DatagramSocket(int aPort, InetAddress addr) throws SocketException {
super();
checkListen(aPort);
- createSocket(aPort, null == addr ? Inet4Address.ANY : addr);
+ createSocket(aPort, (addr == null) ? Inet4Address.ANY : addr);
}
/**
diff --git a/luni/src/main/java/java/net/Inet6Address.java b/luni/src/main/java/java/net/Inet6Address.java
index f8920fc..b497041 100644
--- a/luni/src/main/java/java/net/Inet6Address.java
+++ b/luni/src/main/java/java/net/Inet6Address.java
@@ -122,7 +122,7 @@
Inet6Address address = Inet6Address.getByAddress(host, addr, 0);
// if nif is null, nothing needs to be set.
- if (null == nif) {
+ if (nif == null) {
return address;
}
@@ -405,7 +405,7 @@
scope_id_set = fields.get("scope_id_set", false);
ifname = (String) fields.get("ifname", null);
scope_ifname_set = fields.get("scope_ifname_set", false);
- if (scope_ifname_set && null != ifname) {
+ if (scope_ifname_set && ifname != null) {
scopedIf = NetworkInterface.getByName(ifname);
}
}
diff --git a/luni/src/main/java/java/net/InetAddress.java b/luni/src/main/java/java/net/InetAddress.java
index f8a166a..bc414c7 100644
--- a/luni/src/main/java/java/net/InetAddress.java
+++ b/luni/src/main/java/java/net/InetAddress.java
@@ -530,7 +530,7 @@
private static native String getnameinfo(byte[] addr);
static String getHostNameInternal(String host, boolean isCheck) throws UnknownHostException {
- if (host == null || 0 == host.length()) {
+ if (host == null || host.isEmpty()) {
return Inet4Address.LOOPBACK.getHostAddress();
}
if (!isNumeric(host)) {
@@ -826,7 +826,7 @@
waitReachable.notifyAll();
} else {
addrCount--;
- if (0 == addrCount) {
+ if (addrCount == 0) {
// if count equals zero, all thread
// expired,notifies main thread
waitReachable.notifyAll();
@@ -860,7 +860,7 @@
boolean reached = false;
Platform.NETWORK.socket(fd, true);
try {
- if (null != source) {
+ if (source != null) {
Platform.NETWORK.bind(fd, source, 0);
}
Platform.NETWORK.connect(fd, destination, 7, timeout);
diff --git a/luni/src/main/java/java/net/JarURLConnection.java b/luni/src/main/java/java/net/JarURLConnection.java
index 0ea065d..4b84893 100644
--- a/luni/src/main/java/java/net/JarURLConnection.java
+++ b/luni/src/main/java/java/net/JarURLConnection.java
@@ -75,7 +75,7 @@
return;
}
entryName = file.substring(sepIdx, file.length());
- if (null != url.getRef()) {
+ if (url.getRef() != null) {
entryName += "#" + url.getRef();
}
}
diff --git a/luni/src/main/java/java/net/MulticastSocket.java b/luni/src/main/java/java/net/MulticastSocket.java
index df09de5..4f6f2f4 100644
--- a/luni/src/main/java/java/net/MulticastSocket.java
+++ b/luni/src/main/java/java/net/MulticastSocket.java
@@ -475,9 +475,6 @@
* Sets the time-to-live (TTL) for multicast packets sent on this socket.
* Valid TTL values are between 0 and 255 inclusive.
*
- * @param ttl
- * the default time-to-live field value for packets sent on this
- * socket. {@code 0 <= ttl <= 255}.
* @throws IOException
* if an error occurs while setting the TTL option value.
*/
@@ -493,9 +490,6 @@
* Sets the time-to-live (TTL) for multicast packets sent on this socket.
* Valid TTL values are between 0 and 255 inclusive.
*
- * @param ttl
- * the default time-to-live field value for packets sent on this
- * socket: {@code 0 <= ttl <= 255}.
* @throws IOException
* if an error occurs while setting the TTL option value.
* @deprecated Replaced by {@link #setTimeToLive}
diff --git a/luni/src/main/java/java/net/Proxy.java b/luni/src/main/java/java/net/Proxy.java
index b9d38ae..340ef39 100644
--- a/luni/src/main/java/java/net/Proxy.java
+++ b/luni/src/main/java/java/net/Proxy.java
@@ -147,7 +147,7 @@
public final int hashCode() {
int ret = 0;
ret += type.hashCode();
- if (null != address) {
+ if (address != null) {
ret += address.hashCode();
}
return ret;
diff --git a/luni/src/main/java/java/net/Socket.java b/luni/src/main/java/java/net/Socket.java
index c18bba8..bf79f4a 100644
--- a/luni/src/main/java/java/net/Socket.java
+++ b/luni/src/main/java/java/net/Socket.java
@@ -85,10 +85,10 @@
throw new IllegalArgumentException("Proxy is null or invalid type");
}
InetSocketAddress address = (InetSocketAddress) proxy.address();
- if (null != address) {
+ if (address != null) {
InetAddress addr = address.getAddress();
String host;
- if (null != addr) {
+ if (addr != null) {
host = addr.getHostAddress();
} else {
host = address.getHostName();
diff --git a/luni/src/main/java/java/net/SocketOptions.java b/luni/src/main/java/java/net/SocketOptions.java
index a1b95bf..52108be 100644
--- a/luni/src/main/java/java/net/SocketOptions.java
+++ b/luni/src/main/java/java/net/SocketOptions.java
@@ -33,10 +33,10 @@
* is still some buffered data to be sent while closing the socket. If the
* value of this option is set to {@code 0} the method closes the TCP socket
* forcefully and returns immediately. Is this value greater than {@code 0}
- * the method blocks this time in milliseconds. If all data could be sent
+ * the method blocks this time in seconds. If all data could be sent
* during this timeout the socket is closed normally otherwise forcefully.
- * Valid values for this option are in the range {@code 0 <= SO_LINGER <=
- * 65535}. (Larger timeouts will be treated as 65535s timeouts; roughly 18 hours.)
+ * Valid values for this option are in the range 0 to 65535 inclusive. (Larger
+ * timeouts will be treated as 65535s timeouts; roughly 18 hours.)
*/
public static final int SO_LINGER = 128;
diff --git a/luni/src/main/java/java/nio/DatagramChannelImpl.java b/luni/src/main/java/java/nio/DatagramChannelImpl.java
index 6cc1217..79c90de 100644
--- a/luni/src/main/java/java/nio/DatagramChannelImpl.java
+++ b/luni/src/main/java/java/nio/DatagramChannelImpl.java
@@ -90,7 +90,7 @@
*/
@Override
synchronized public DatagramSocket socket() {
- if (null == socket) {
+ if (socket == null) {
socket = new DatagramSocketAdapter(new PlainDatagramSocketImpl(fd, localPort), this);
}
return socket;
@@ -132,7 +132,7 @@
// security check
SecurityManager sm = System.getSecurityManager();
- if (null != sm) {
+ if (sm != null) {
if (inetSocketAddress.getAddress().isMulticastAddress()) {
sm.checkMulticast(inetSocketAddress.getAddress());
} else {
@@ -169,7 +169,7 @@
connected = false;
connectAddress = null;
Platform.NETWORK.disconnectDatagram(fd);
- if (null != socket) {
+ if (socket != null) {
socket.disconnect();
}
return this;
@@ -201,7 +201,7 @@
// this line used in Linux
return null;
} finally {
- end(null != retAddr);
+ end(retAddr != null);
}
return retAddr;
}
@@ -226,7 +226,7 @@
// security check
SecurityManager sm = System.getSecurityManager();
- if (!isConnected() && null != sm) {
+ if (!isConnected() && sm != null) {
try {
sm.checkAccept(receivePacket.getAddress().getHostAddress(),
receivePacket.getPort());
@@ -235,7 +235,7 @@
receivePacket = null;
}
}
- if (null != receivePacket && null != receivePacket.getAddress()) {
+ if (receivePacket != null && receivePacket.getAddress() != null) {
if (received > 0) {
if (target.hasArray()) {
@@ -264,7 +264,7 @@
// security check
SecurityManager sm = System.getSecurityManager();
- if (!isConnected() && null != sm) {
+ if (!isConnected() && sm != null) {
try {
sm.checkAccept(receivePacket.getAddress().getHostAddress(),
receivePacket.getPort());
@@ -273,7 +273,7 @@
receivePacket = null;
}
}
- if (null != receivePacket && null != receivePacket.getAddress()) {
+ if (receivePacket != null && receivePacket.getAddress() != null) {
// copy the data of received packet
if (received > 0) {
target.position(oldposition + received);
@@ -298,7 +298,7 @@
// transfer socketAddress
InetSocketAddress isa = (InetSocketAddress) socketAddress;
- if (null == isa.getAddress()) {
+ if (isa.getAddress() == null) {
throw new IOException();
}
@@ -581,7 +581,7 @@
* Buffer check, must not null
*/
private void checkNotNull(ByteBuffer source) {
- if (null == source) {
+ if (source == null) {
throw new NullPointerException();
}
}
@@ -641,7 +641,7 @@
*/
@Override
public InetAddress getInetAddress() {
- if (null == channelImpl.connectAddress) {
+ if (channelImpl.connectAddress == null) {
return null;
}
return channelImpl.connectAddress.getAddress();
@@ -660,7 +660,7 @@
*/
@Override
public int getPort() {
- if (null == channelImpl.connectAddress) {
+ if (channelImpl.connectAddress == null) {
return -1;
}
return channelImpl.connectAddress.getPort();
diff --git a/luni/src/main/java/java/nio/FileChannelImpl.java b/luni/src/main/java/java/nio/FileChannelImpl.java
index 5f00b4a..52c880f 100644
--- a/luni/src/main/java/java/nio/FileChannelImpl.java
+++ b/luni/src/main/java/java/nio/FileChannelImpl.java
@@ -445,7 +445,7 @@
}
public int write(ByteBuffer buffer, long position) throws IOException {
- if (null == buffer) {
+ if (buffer == null) {
throw new NullPointerException();
}
if (position < 0) {
diff --git a/luni/src/main/java/java/nio/ReadOnlyFileChannel.java b/luni/src/main/java/java/nio/ReadOnlyFileChannel.java
index 851c1d1..a5063ac 100644
--- a/luni/src/main/java/java/nio/ReadOnlyFileChannel.java
+++ b/luni/src/main/java/java/nio/ReadOnlyFileChannel.java
@@ -30,7 +30,7 @@
}
public final int write(ByteBuffer buffer, long position) throws IOException {
- if (null == buffer) {
+ if (buffer == null) {
throw new NullPointerException();
}
if (position < 0) {
diff --git a/luni/src/main/java/java/nio/SelectorImpl.java b/luni/src/main/java/java/nio/SelectorImpl.java
index bf673b8..733bb34 100644
--- a/luni/src/main/java/java/nio/SelectorImpl.java
+++ b/luni/src/main/java/java/nio/SelectorImpl.java
@@ -182,7 +182,7 @@
if (timeout < 0) {
throw new IllegalArgumentException();
}
- return selectInternal((0 == timeout) ? SELECT_BLOCK : timeout);
+ return selectInternal((timeout == 0) ? SELECT_BLOCK : timeout);
}
@Override public int selectNow() throws IOException {
diff --git a/luni/src/main/java/java/nio/ServerSocketChannelImpl.java b/luni/src/main/java/java/nio/ServerSocketChannelImpl.java
index 240a0ba..9cefe5f 100644
--- a/luni/src/main/java/java/nio/ServerSocketChannelImpl.java
+++ b/luni/src/main/java/java/nio/ServerSocketChannelImpl.java
@@ -83,7 +83,7 @@
int[] tryResult = new int[1];
boolean success = Platform.NETWORK.select(new FileDescriptor[] { fd },
SelectorImpl.EMPTY_FILE_DESCRIPTORS_ARRAY, 1, 0, 0, tryResult);
- if (!success || 0 == tryResult[0]) {
+ if (!success || tryResult[0] == 0) {
// no pending connections, returns immediately.
return null;
}
@@ -140,7 +140,7 @@
throw new IllegalBlockingModeException();
}
SocketChannel sc = channelImpl.accept();
- if (null == sc) {
+ if (sc == null) {
throw new IllegalBlockingModeException();
}
return sc.socket();
diff --git a/luni/src/main/java/java/nio/SocketChannelImpl.java b/luni/src/main/java/java/nio/SocketChannelImpl.java
index 2f52646..e75b6b7 100644
--- a/luni/src/main/java/java/nio/SocketChannelImpl.java
+++ b/luni/src/main/java/java/nio/SocketChannelImpl.java
@@ -380,7 +380,7 @@
@Override
public int write(ByteBuffer source) throws IOException {
- if (null == source) {
+ if (source == null) {
throw new NullPointerException();
}
checkOpenConnected();
@@ -490,7 +490,7 @@
* and check.
*/
static InetSocketAddress validateAddress(SocketAddress socketAddress) {
- if (null == socketAddress) {
+ if (socketAddress == null) {
throw new IllegalArgumentException();
}
if (!(socketAddress instanceof InetSocketAddress)) {
@@ -680,7 +680,7 @@
@Override
public void write(byte[] buffer, int offset, int count) throws IOException {
- if (0 > offset || 0 > count || count + offset > buffer.length) {
+ if (offset < 0 || count < 0 || count + offset > buffer.length) {
throw new IndexOutOfBoundsException();
}
ByteBuffer buf = ByteBuffer.wrap(buffer, offset, count);
@@ -735,7 +735,7 @@
@Override
public int read(byte[] buffer, int offset, int count) throws IOException {
- if (0 > offset || 0 > count || count + offset > buffer.length) {
+ if (offset < 0 || count < 0 || count + offset > buffer.length) {
throw new IndexOutOfBoundsException();
}
if (!channel.isBlocking()) {
diff --git a/luni/src/main/java/java/nio/WriteOnlyFileChannel.java b/luni/src/main/java/java/nio/WriteOnlyFileChannel.java
index 48c654c..a5584c3 100644
--- a/luni/src/main/java/java/nio/WriteOnlyFileChannel.java
+++ b/luni/src/main/java/java/nio/WriteOnlyFileChannel.java
@@ -64,7 +64,7 @@
}
public int read(ByteBuffer buffer, long position) throws IOException {
- if (null == buffer) {
+ if (buffer == null) {
throw new NullPointerException();
}
if (position < 0) {
diff --git a/luni/src/main/java/java/nio/channels/SocketChannel.java b/luni/src/main/java/java/nio/channels/SocketChannel.java
index 0951b46..9ca75ef 100644
--- a/luni/src/main/java/java/nio/channels/SocketChannel.java
+++ b/luni/src/main/java/java/nio/channels/SocketChannel.java
@@ -109,7 +109,7 @@
*/
public static SocketChannel open(SocketAddress address) throws IOException {
SocketChannel socketChannel = open();
- if (null != socketChannel) {
+ if (socketChannel != null) {
socketChannel.connect(address);
}
return socketChannel;
diff --git a/luni/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java b/luni/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java
index 674f5a4..ff44c11 100644
--- a/luni/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java
+++ b/luni/src/main/java/java/nio/channels/spi/AbstractSelectableChannel.java
@@ -91,7 +91,7 @@
synchronized public final SelectionKey keyFor(Selector selector) {
for (int i = 0; i < keyList.size(); i++) {
SelectionKey key = keyList.get(i);
- if (null != key && key.selector() == selector) {
+ if (key != null && key.selector() == selector) {
return key;
}
}
@@ -140,7 +140,7 @@
throw new IllegalBlockingModeException();
}
if (!selector.isOpen()) {
- if (0 == interestSet) {
+ if (interestSet == 0) {
// throw ISE exactly to keep consistency
throw new IllegalSelectorException();
}
@@ -148,9 +148,8 @@
throw new NullPointerException();
}
SelectionKey key = keyFor(selector);
- if (null == key) {
- key = ((AbstractSelector) selector).register(this, interestSet,
- attachment);
+ if (key == null) {
+ key = ((AbstractSelector) selector).register(this, interestSet, attachment);
keyList.add(key);
} else {
if (!key.isValid()) {
@@ -177,7 +176,7 @@
implCloseSelectableChannel();
for (int i = 0; i < keyList.size(); i++) {
SelectionKey key = keyList.get(i);
- if (null != key) {
+ if (key != null) {
key.cancel();
}
}
@@ -269,7 +268,7 @@
* package private for deregister method in AbstractSelector.
*/
synchronized void deregister(SelectionKey k) {
- if (null != keyList) {
+ if (keyList != null) {
keyList.remove(k);
}
}
diff --git a/luni/src/main/java/java/nio/channels/spi/SelectorProvider.java b/luni/src/main/java/java/nio/channels/spi/SelectorProvider.java
index 2ba5c0d..201ea9f 100644
--- a/luni/src/main/java/java/nio/channels/spi/SelectorProvider.java
+++ b/luni/src/main/java/java/nio/channels/spi/SelectorProvider.java
@@ -51,7 +51,7 @@
*/
protected SelectorProvider() {
super();
- if (null != System.getSecurityManager()) {
+ if (System.getSecurityManager() != null) {
System.getSecurityManager().checkPermission(
new RuntimePermission("selectorProvider"));
}
diff --git a/luni/src/main/java/java/nio/charset/CharsetDecoder.java b/luni/src/main/java/java/nio/charset/CharsetDecoder.java
index f4c4558..df2bb6a 100644
--- a/luni/src/main/java/java/nio/charset/CharsetDecoder.java
+++ b/luni/src/main/java/java/nio/charset/CharsetDecoder.java
@@ -620,7 +620,7 @@
* if {@code newAction} is {@code null}.
*/
public final CharsetDecoder onMalformedInput(CodingErrorAction newAction) {
- if (null == newAction) {
+ if (newAction == null) {
throw new IllegalArgumentException();
}
malformAction = newAction;
@@ -641,9 +641,8 @@
* @throws IllegalArgumentException
* if {@code newAction} is {@code null}.
*/
- public final CharsetDecoder onUnmappableCharacter(
- CodingErrorAction newAction) {
- if (null == newAction) {
+ public final CharsetDecoder onUnmappableCharacter(CodingErrorAction newAction) {
+ if (newAction == null) {
throw new IllegalArgumentException();
}
unmapAction = newAction;
diff --git a/luni/src/main/java/java/nio/charset/CoderResult.java b/luni/src/main/java/java/nio/charset/CoderResult.java
index 1d31250..b2595f0 100644
--- a/luni/src/main/java/java/nio/charset/CoderResult.java
+++ b/luni/src/main/java/java/nio/charset/CoderResult.java
@@ -115,7 +115,7 @@
Integer key = Integer.valueOf(length);
synchronized (_malformedErrors) {
CoderResult r = _malformedErrors.get(key);
- if (null == r) {
+ if (r == null) {
r = new CoderResult(TYPE_MALFORMED_INPUT, length);
_malformedErrors.put(key, r);
}
@@ -143,7 +143,7 @@
Integer key = Integer.valueOf(length);
synchronized (_unmappableErrors) {
CoderResult r = _unmappableErrors.get(key);
- if (null == r) {
+ if (r == null) {
r = new CoderResult(TYPE_UNMAPPABLE_CHAR, length);
_unmappableErrors.put(key, r);
}
diff --git a/luni/src/main/java/java/security/KeyStore.java b/luni/src/main/java/java/security/KeyStore.java
index f6add00..ab4b924 100644
--- a/luni/src/main/java/java/security/KeyStore.java
+++ b/luni/src/main/java/java/security/KeyStore.java
@@ -350,7 +350,7 @@
}
// Certificate chain is required for PrivateKey
- if (null != key && key instanceof PrivateKey && (chain == null || chain.length == 0)) {
+ if (key != null && key instanceof PrivateKey && (chain == null || chain.length == 0)) {
throw new IllegalArgumentException("Certificate chain is not defined for Private key");
}
implSpi.engineSetKeyEntry(alias, key, password, chain);
diff --git a/luni/src/main/java/java/security/Provider.java b/luni/src/main/java/java/security/Provider.java
index 669fc7b..346d199 100644
--- a/luni/src/main/java/java/security/Provider.java
+++ b/luni/src/main/java/java/security/Provider.java
@@ -866,9 +866,9 @@
*/
@SuppressWarnings("nls")
private void putProviderInfo() {
- super.put("Provider.id name", null != name ? name : "null");
+ super.put("Provider.id name", (name != null) ? name : "null");
super.put("Provider.id version", versionString);
- super.put("Provider.id info", null != info ? info : "null");
+ super.put("Provider.id info", (info != null) ? info : "null");
super.put("Provider.id className", this.getClass().getName());
}
diff --git a/luni/src/main/java/java/sql/DriverManager.java b/luni/src/main/java/java/sql/DriverManager.java
index d670562..77fe43f 100644
--- a/luni/src/main/java/java/sql/DriverManager.java
+++ b/luni/src/main/java/java/sql/DriverManager.java
@@ -202,13 +202,13 @@
* if there is an error while attempting to connect to the
* database identified by the URL.
*/
- public static Connection getConnection(String url, String user,
- String password) throws SQLException {
+ public static Connection getConnection(String url, String user, String password)
+ throws SQLException {
Properties theProperties = new Properties();
- if (null != user) {
+ if (user != null) {
theProperties.setProperty("user", user);
}
- if (null != password) {
+ if (password != null) {
theProperties.setProperty("password", password);
}
return getConnection(url, theProperties);
diff --git a/luni/src/main/java/java/text/AttributedString.java b/luni/src/main/java/java/text/AttributedString.java
index 58839dd..1495dc56 100644
--- a/luni/src/main/java/java/text/AttributedString.java
+++ b/luni/src/main/java/java/text/AttributedString.java
@@ -579,9 +579,8 @@
* @throws NullPointerException
* if {@code attribute} is {@code null}.
*/
- public void addAttribute(AttributedCharacterIterator.Attribute attribute,
- Object value) {
- if (null == attribute) {
+ public void addAttribute(AttributedCharacterIterator.Attribute attribute, Object value) {
+ if (attribute == null) {
throw new NullPointerException();
}
if (text.length() == 0) {
@@ -618,7 +617,7 @@
*/
public void addAttribute(AttributedCharacterIterator.Attribute attribute,
Object value, int start, int end) {
- if (null == attribute) {
+ if (attribute == null) {
throw new NullPointerException();
}
if (start < 0 || end > text.length() || start >= end) {
diff --git a/luni/src/main/java/java/text/DecimalFormat.java b/luni/src/main/java/java/text/DecimalFormat.java
index 393b34d..b2b5d6a 100644
--- a/luni/src/main/java/java/text/DecimalFormat.java
+++ b/luni/src/main/java/java/text/DecimalFormat.java
@@ -881,7 +881,7 @@
@Override
public Number parse(String string, ParsePosition position) {
Number number = dform.parse(string, position);
- if (null == number) {
+ if (number == null) {
return null;
}
// BEGIN android-removed
diff --git a/luni/src/main/java/java/util/AbstractList.java b/luni/src/main/java/java/util/AbstractList.java
index 8f1e79f..fe83125 100644
--- a/luni/src/main/java/java/util/AbstractList.java
+++ b/luni/src/main/java/java/util/AbstractList.java
@@ -91,7 +91,7 @@
ListIterator<E> {
FullListIterator(int start) {
super();
- if (0 <= start && start <= size()) {
+ if (start >= 0 && start <= size()) {
pos = start - 1;
} else {
throw new IndexOutOfBoundsException();
@@ -249,7 +249,7 @@
@Override
public void add(int location, E object) {
if (modCount == fullList.modCount) {
- if (0 <= location && location <= size) {
+ if (location >= 0 && location <= size) {
fullList.add(location + offset, object);
size++;
modCount = fullList.modCount;
@@ -264,7 +264,7 @@
@Override
public boolean addAll(int location, Collection<? extends E> collection) {
if (modCount == fullList.modCount) {
- if (0 <= location && location <= size) {
+ if (location >= 0 && location <= size) {
boolean result = fullList.addAll(location + offset,
collection);
if (result) {
@@ -294,7 +294,7 @@
@Override
public E get(int location) {
if (modCount == fullList.modCount) {
- if (0 <= location && location < size) {
+ if (location >= 0 && location < size) {
return fullList.get(location + offset);
}
throw new IndexOutOfBoundsException();
@@ -310,7 +310,7 @@
@Override
public ListIterator<E> listIterator(int location) {
if (modCount == fullList.modCount) {
- if (0 <= location && location <= size) {
+ if (location >= 0 && location <= size) {
return new SubAbstractListIterator<E>(fullList
.listIterator(location + offset), this, offset,
size);
@@ -323,7 +323,7 @@
@Override
public E remove(int location) {
if (modCount == fullList.modCount) {
- if (0 <= location && location < size) {
+ if (location >= 0 && location < size) {
E result = fullList.remove(location + offset);
size--;
modCount = fullList.modCount;
@@ -350,7 +350,7 @@
@Override
public E set(int location, E object) {
if (modCount == fullList.modCount) {
- if (0 <= location && location < size) {
+ if (location >= 0 && location < size) {
return fullList.set(location + offset, object);
}
throw new IndexOutOfBoundsException();
@@ -733,7 +733,7 @@
* if (start > end)
*/
public List<E> subList(int start, int end) {
- if (0 <= start && end <= size()) {
+ if (start >= 0 && end <= size()) {
if (start <= end) {
if (this instanceof RandomAccess) {
return new SubAbstractListRandomAccess<E>(this, start, end);
diff --git a/luni/src/main/java/java/util/Calendar.java b/luni/src/main/java/java/util/Calendar.java
index 01b0343..3368b2d 100644
--- a/luni/src/main/java/java/util/Calendar.java
+++ b/luni/src/main/java/java/util/Calendar.java
@@ -1397,7 +1397,7 @@
* value.
*/
public int compareTo(Calendar anotherCalendar) {
- if (null == anotherCalendar) {
+ if (anotherCalendar == null) {
throw new NullPointerException();
}
long timeInMillis = getTimeInMillis();
diff --git a/luni/src/main/java/java/util/Collections.java b/luni/src/main/java/java/util/Collections.java
index 2a20f86..38005ad 100644
--- a/luni/src/main/java/java/util/Collections.java
+++ b/luni/src/main/java/java/util/Collections.java
@@ -60,7 +60,7 @@
@Override
public E get(int location) {
- if (0 <= location && location < n) {
+ if (location >= 0 && location < n) {
return element;
}
throw new IndexOutOfBoundsException();
@@ -593,15 +593,15 @@
array = new Object[size];
list.toArray(array);
}
- if (null != object)
+ if (object != null) {
for (int i = 0; i < size; i++) {
if (object.equals(array[i])) {
return i;
}
}
- else {
+ } else {
for (int i = 0; i < size; i++) {
- if (null == array[i]) {
+ if (array[i] == null) {
return i;
}
}
@@ -617,15 +617,15 @@
array = new Object[size];
list.toArray(array);
}
- if (null != object)
+ if (object != null) {
for (int i = size - 1; i >= 0; i--) {
if (object.equals(array[i])) {
return i;
}
}
- else {
+ } else {
for (int i = size - 1; i >= 0; i--) {
- if (null == array[i]) {
+ if (array[i] == null) {
return i;
}
}
diff --git a/luni/src/main/java/java/util/EnumMap.java b/luni/src/main/java/java/util/EnumMap.java
index 36ff03a..5da3b86 100644
--- a/luni/src/main/java/java/util/EnumMap.java
+++ b/luni/src/main/java/java/util/EnumMap.java
@@ -72,8 +72,11 @@
Object enumKey = entry.getKey();
if (key.equals(enumKey)) {
Object theValue = entry.getValue();
- isEqual = enumMap.values[ordinal] == null ? null == theValue
- : enumMap.values[ordinal].equals(theValue);
+ if (enumMap.values[ordinal] == null) {
+ isEqual = (theValue == null);
+ } else {
+ isEqual = enumMap.values[ordinal].equals(theValue);
+ }
}
}
return isEqual;
@@ -262,9 +265,9 @@
@Override
public boolean remove(Object object) {
- if (null == object) {
+ if (object == null) {
for (int i = 0; i < enumMap.enumSize; i++) {
- if (enumMap.hasMapping[i] && null == enumMap.values[i]) {
+ if (enumMap.hasMapping[i] && enumMap.values[i] == null) {
enumMap.remove(enumMap.keys[i]);
return true;
}
@@ -326,8 +329,11 @@
Object enumValue = ((Map.Entry) object).getValue();
if (enumMap.containsKey(enumKey)) {
VT value = enumMap.get(enumKey);
- isEqual = (value == null ? null == enumValue : value
- .equals(enumValue));
+ if (value == null) {
+ isEqual = enumValue == null;
+ } else {
+ isEqual = value.equals(enumValue);
+ }
}
}
return isEqual;
@@ -430,7 +436,7 @@
if (map instanceof EnumMap) {
initialization((EnumMap<K, V>) map);
} else {
- if (0 == map.size()) {
+ if (map.size() == 0) {
throw new IllegalArgumentException();
}
Iterator<K> iter = map.keySet().iterator();
@@ -502,9 +508,9 @@
*/
@Override
public boolean containsValue(Object value) {
- if (null == value) {
+ if (value == null) {
for (int i = 0; i < enumSize; i++) {
- if (hasMapping[i] && null == values[i]) {
+ if (hasMapping[i] && values[i] == null) {
return true;
}
}
@@ -530,7 +536,7 @@
*/
@Override
public Set<Map.Entry<K, V>> entrySet() {
- if (null == entrySet) {
+ if (entrySet == null) {
entrySet = new EnumMapEntrySet<K, V>(this);
}
return entrySet;
@@ -594,7 +600,7 @@
*/
@Override
public Set<K> keySet() {
- if (null == keySet) {
+ if (keySet == null) {
keySet = new EnumMapKeySet<K, V>(this);
}
return keySet;
@@ -698,7 +704,7 @@
*/
@Override
public Collection<V> values() {
- if (null == valuesCollection) {
+ if (valuesCollection == null) {
valuesCollection = new EnumMapValueCollection<K, V>(this);
}
return valuesCollection;
@@ -731,7 +737,7 @@
}
private boolean isValidKeyType(Object key) {
- if (null != key && keyType.isInstance(key)) {
+ if (key != null && keyType.isInstance(key)) {
return true;
}
return false;
@@ -766,7 +772,7 @@
@SuppressWarnings("unchecked")
private V putImpl(K key, V value) {
- if (null == key) {
+ if (key == null) {
throw new NullPointerException();
}
keyType.cast(key); // Called to throw ClassCastException.
diff --git a/luni/src/main/java/java/util/FormatFlagsConversionMismatchException.java b/luni/src/main/java/java/util/FormatFlagsConversionMismatchException.java
index 73d8a64..5792877 100644
--- a/luni/src/main/java/java/util/FormatFlagsConversionMismatchException.java
+++ b/luni/src/main/java/java/util/FormatFlagsConversionMismatchException.java
@@ -43,7 +43,7 @@
* the conversion.
*/
public FormatFlagsConversionMismatchException(String f, char c) {
- if (null == f) {
+ if (f == null) {
throw new NullPointerException();
}
this.f = f;
diff --git a/luni/src/main/java/java/util/Formatter.java b/luni/src/main/java/java/util/Formatter.java
index b3d1578..6825420 100644
--- a/luni/src/main/java/java/util/Formatter.java
+++ b/luni/src/main/java/java/util/Formatter.java
@@ -2159,7 +2159,9 @@
private void transform_g(StringBuilder result) {
int precision = formatToken.getPrecision();
- precision = (0 == precision ? 1 : precision);
+ if (precision == 0) {
+ precision = 1;
+ }
formatToken.setPrecision(precision);
double d = ((Number) arg).doubleValue();
@@ -2268,7 +2270,9 @@
}
int precision = formatToken.getPrecision();
- precision = (0 == precision ? 1 : precision);
+ if (precision == 0) {
+ precision = 1;
+ }
int indexOfFirstFractionalDigit = result.indexOf(".") + 1;
int indexOfP = result.indexOf("p");
int fractionalLength = indexOfP - indexOfFirstFractionalDigit;
diff --git a/luni/src/main/java/java/util/LinkedList.java b/luni/src/main/java/java/util/LinkedList.java
index e264ed0..2d264c2 100644
--- a/luni/src/main/java/java/util/LinkedList.java
+++ b/luni/src/main/java/java/util/LinkedList.java
@@ -67,7 +67,7 @@
LinkIterator(LinkedList<ET> object, int location) {
list = object;
expectedModCount = list.modCount;
- if (0 <= location && location <= list.size) {
+ if (location >= 0 && location <= list.size) {
// pos ends up as -1 if list is empty, it ranges from -1 to
// list.size - 1
// if link == voidLink then pos must == -1
@@ -277,7 +277,7 @@
*/
@Override
public void add(int location, E object) {
- if (0 <= location && location <= size) {
+ if (location >= 0 && location <= size) {
Link<E> link = voidLink;
if (location < (size / 2)) {
for (int i = 0; i <= location; i++) {
@@ -504,7 +504,7 @@
@Override
public E get(int location) {
- if (0 <= location && location < size) {
+ if (location >= 0 && location < size) {
Link<E> link = voidLink;
if (location < (size / 2)) {
for (int i = 0; i <= location; i++) {
@@ -639,7 +639,7 @@
*/
@Override
public E remove(int location) {
- if (0 <= location && location < size) {
+ if (location >= 0 && location < size) {
Link<E> link = voidLink;
if (location < (size / 2)) {
for (int i = 0; i <= location; i++) {
@@ -860,7 +860,7 @@
*/
@Override
public E set(int location, E object) {
- if (0 <= location && location < size) {
+ if (location >= 0 && location < size) {
Link<E> link = voidLink;
if (location < (size / 2)) {
for (int i = 0; i <= location; i++) {
diff --git a/luni/src/main/java/java/util/MissingFormatArgumentException.java b/luni/src/main/java/java/util/MissingFormatArgumentException.java
index cd56f87..ce72efa 100644
--- a/luni/src/main/java/java/util/MissingFormatArgumentException.java
+++ b/luni/src/main/java/java/util/MissingFormatArgumentException.java
@@ -36,7 +36,7 @@
* the specified conversion that lacks the argument.
*/
public MissingFormatArgumentException(String s) {
- if (null == s) {
+ if (s == null) {
throw new NullPointerException();
}
this.s = s;
diff --git a/luni/src/main/java/java/util/MissingFormatWidthException.java b/luni/src/main/java/java/util/MissingFormatWidthException.java
index 842b0c4..b6d0ca6 100644
--- a/luni/src/main/java/java/util/MissingFormatWidthException.java
+++ b/luni/src/main/java/java/util/MissingFormatWidthException.java
@@ -35,7 +35,7 @@
* the specified format specifier.
*/
public MissingFormatWidthException(String s) {
- if (null == s) {
+ if (s == null) {
throw new NullPointerException();
}
this.s = s;
diff --git a/luni/src/main/java/java/util/PriorityQueue.java b/luni/src/main/java/java/util/PriorityQueue.java
index 30fce2e..10c5968 100644
--- a/luni/src/main/java/java/util/PriorityQueue.java
+++ b/luni/src/main/java/java/util/PriorityQueue.java
@@ -185,7 +185,7 @@
* if {@code o} is {@code null}.
*/
public boolean offer(E o) {
- if (null == o) {
+ if (o == null) {
throw new NullPointerException();
}
growToSize(size + 1);
@@ -347,7 +347,7 @@
}
private int compare(E o1, E o2) {
- if (null != comparator) {
+ if (comparator != null) {
return comparator.compare(o1, o2);
}
return ((Comparable<? super E>) o1).compareTo(o2);
@@ -386,7 +386,7 @@
}
private void initSize(Collection<? extends E> c) {
- if (null == c) {
+ if (c == null) {
throw new NullPointerException();
}
if (c.isEmpty()) {
diff --git a/luni/src/main/java/java/util/ResourceBundle.java b/luni/src/main/java/java/util/ResourceBundle.java
index 0f19df2..dcd5f13 100644
--- a/luni/src/main/java/java/util/ResourceBundle.java
+++ b/luni/src/main/java/java/util/ResourceBundle.java
@@ -263,7 +263,7 @@
.doPrivileged(new PrivilegedAction<ClassLoader>() {
public ClassLoader run() {
ClassLoader cl = this.getClass().getClassLoader();
- if (null == cl) {
+ if (cl == null) {
cl = ClassLoader.getSystemClassLoader();
}
return cl;
@@ -318,7 +318,7 @@
ResourceBundle ret = processGetBundle(baseName, targetLocale, loader,
control, expired, result);
- if (null != ret) {
+ if (ret != null) {
loaderCache.put(bundleName, ret);
ret.lastLoadTime = System.currentTimeMillis();
return ret;
@@ -332,9 +332,8 @@
Locale targetLocale, ClassLoader loader,
ResourceBundle.Control control, boolean expired,
ResourceBundle result) {
- List<Locale> locales = control.getCandidateLocales(baseName,
- targetLocale);
- if (null == locales) {
+ List<Locale> locales = control.getCandidateLocales(baseName, targetLocale);
+ if (locales == null) {
throw new IllegalArgumentException();
}
List<String> formats = control.getFormats(baseName);
@@ -370,29 +369,28 @@
} catch (IOException e) {
// do nothing
}
- if (null != bundle) {
- if (null != currentBundle) {
+ if (bundle != null) {
+ if (currentBundle != null) {
currentBundle.setParent(bundle);
currentBundle = bundle;
} else {
- if (null == ret) {
+ if (ret == null) {
ret = bundle;
currentBundle = ret;
}
}
}
- if (null != bundle) {
+ if (bundle != null) {
break;
}
}
}
- if ((null == ret)
+ if ((ret == null)
|| (Locale.ROOT.equals(ret.getLocale()) && (!(locales.size() == 1 && locales
.contains(Locale.ROOT))))) {
- Locale nextLocale = control.getFallbackLocale(baseName,
- targetLocale);
- if (null != nextLocale) {
+ Locale nextLocale = control.getFallbackLocale(baseName, targetLocale);
+ if (nextLocale != null) {
ret = processGetBundle(baseName, nextLocale, loader, control,
expired, result);
}
@@ -637,14 +635,14 @@
}
public static final void clearCache(ClassLoader loader) {
- if (null == loader) {
+ if (loader == null) {
throw new NullPointerException();
}
cache.remove(loader);
}
public boolean containsKey(String key) {
- if (null == key) {
+ if (key == null) {
throw new NullPointerException();
}
return keySet().contains(key);
@@ -663,7 +661,7 @@
Set<String> set = keySet();
Set<String> ret = new HashSet<String>();
for (String key : set) {
- if (null != handleGetObject(key)) {
+ if (handleGetObject(key) != null) {
ret.add(key);
}
}
@@ -695,7 +693,7 @@
@Override
public Locale getFallbackLocale(String baseName, Locale locale) {
- if (null == baseName || null == locale) {
+ if (baseName == null || locale == null) {
throw new NullPointerException();
}
return null;
@@ -837,7 +835,7 @@
* {@code locale}.
*/
public List<Locale> getCandidateLocales(String baseName, Locale locale) {
- if (null == baseName || null == locale) {
+ if (baseName == null || locale == null) {
throw new NullPointerException();
}
List<Locale> retList = new ArrayList<Locale>();
@@ -861,7 +859,7 @@
* Returns a list of strings of formats according to {@code baseName}.
*/
public List<String> getFormats(String baseName) {
- if (null == baseName) {
+ if (baseName == null) {
throw new NullPointerException();
}
return format;
@@ -871,7 +869,7 @@
* Returns the fallback locale for {@code baseName} in {@code locale}.
*/
public Locale getFallbackLocale(String baseName, Locale locale) {
- if (null == baseName || null == locale) {
+ if (baseName == null || locale == null) {
throw new NullPointerException();
}
if (Locale.getDefault() != locale) {
@@ -905,7 +903,7 @@
String format, ClassLoader loader, boolean reload)
throws IllegalAccessException, InstantiationException,
IOException {
- if (null == format || null == loader) {
+ if (format == null || loader == null) {
throw new NullPointerException();
}
InputStream streams = null;
@@ -926,7 +924,7 @@
}
}
});
- if (null == cls) {
+ if (cls == null) {
return null;
}
try {
@@ -947,7 +945,7 @@
} catch (NullPointerException e) {
// do nothing
}
- if (null != url) {
+ if (url != null) {
URLConnection con = url.openConnection();
con.setUseCaches(false);
streams = con.getInputStream();
@@ -985,7 +983,7 @@
* default is TTL_NO_EXPIRATION_CONTROL.
*/
public long getTimeToLive(String baseName, Locale locale) {
- if (null == baseName || null == locale) {
+ if (baseName == null || locale == null) {
throw new NullPointerException();
}
return TTL_NO_EXPIRATION_CONTROL;
@@ -1011,7 +1009,7 @@
public boolean needsReload(String baseName, Locale locale,
String format, ClassLoader loader, ResourceBundle bundle,
long loadTime) {
- if (null == bundle) {
+ if (bundle == null) {
// FIXME what's the use of bundle?
throw new NullPointerException();
}
@@ -1025,7 +1023,7 @@
}
String urlname = toResourceName(bundleName, suffix);
URL url = loader.getResource(urlname);
- if (null != url) {
+ if (url != null) {
String fileName = url.getFile();
long lastModified = new File(fileName).lastModified();
if (lastModified > loadTime) {
@@ -1050,7 +1048,7 @@
final String emptyString = EMPTY_STRING;
final String preString = UNDER_SCORE;
final String underline = UNDER_SCORE;
- if (null == baseName) {
+ if (baseName == null) {
throw new NullPointerException();
}
StringBuilder ret = new StringBuilder();
@@ -1090,7 +1088,7 @@
* suffix
*/
public final String toResourceName(String bundleName, String suffix) {
- if (null == suffix) {
+ if (suffix == null) {
throw new NullPointerException();
}
StringBuilder ret = new StringBuilder(bundleName.replace('.', '/'));
diff --git a/luni/src/main/java/java/util/Scanner.java b/luni/src/main/java/java/util/Scanner.java
index 3d5ac3a..85de1e7 100644
--- a/luni/src/main/java/java/util/Scanner.java
+++ b/luni/src/main/java/java/util/Scanner.java
@@ -250,7 +250,7 @@
* the {@code Readable} to be scanned.
*/
public Scanner(Readable src) {
- if (null == src) {
+ if (src == null) {
throw new NullPointerException();
}
input = src;
@@ -513,7 +513,7 @@
resetMatcher();
}
}
- if (null != result) {
+ if (result != null) {
findStartIndex = matcher.end();
matchSuccessful = true;
} else {
@@ -1420,7 +1420,7 @@
}
}
// Find text without line terminator here.
- if (null != result) {
+ if (result != null) {
Matcher terminatorMatcher = LINE_TERMINATOR.matcher(result);
if (terminatorMatcher.find()) {
result = result.substring(0, terminatorMatcher.start());
@@ -1673,7 +1673,7 @@
* @return this {@code Scanner}.
*/
public Scanner useLocale(Locale l) {
- if (null == l) {
+ if (l == null) {
throw new NullPointerException();
}
this.locale = l;
@@ -1733,7 +1733,7 @@
* will be thrown out.
*/
private void checkNull(Pattern pattern) {
- if (null == pattern) {
+ if (pattern == null) {
throw new NullPointerException();
}
}
@@ -1742,7 +1742,7 @@
* Change the matcher's string after reading input
*/
private void resetMatcher() {
- if (null == matcher) {
+ if (matcher == null) {
matcher = delimiter.matcher(buffer);
} else {
matcher.reset(buffer);
@@ -1952,7 +1952,7 @@
}
}
// Token is NaN or Infinity
- if (0 == result.length()) {
+ if (result.length() == 0) {
result = tokenBuilder;
}
if (-1 != separatorIndex) {
@@ -1975,10 +1975,10 @@
String negativePrefix = decimalFormat.getNegativePrefix();
String negativeSuffix = decimalFormat.getNegativeSuffix();
- if (0 == tokenBuilder.indexOf("+")) {
+ if (tokenBuilder.indexOf("+") == 0) {
tokenBuilder.delete(0, 1);
}
- if (!positivePrefix.isEmpty() && 0 == tokenBuilder.indexOf(positivePrefix)) {
+ if (!positivePrefix.isEmpty() && tokenBuilder.indexOf(positivePrefix) == 0) {
tokenBuilder.delete(0, positivePrefix.length());
}
if (!positiveSuffix.isEmpty()
@@ -1988,12 +1988,11 @@
tokenBuilder.length());
}
boolean negative = false;
- if (0 == tokenBuilder.indexOf("-")) {
+ if (tokenBuilder.indexOf("-") == 0) {
tokenBuilder.delete(0, 1);
negative = true;
}
- if (!negativePrefix.isEmpty()
- && 0 == tokenBuilder.indexOf(negativePrefix)) {
+ if (!negativePrefix.isEmpty() && tokenBuilder.indexOf(negativePrefix) == 0) {
tokenBuilder.delete(0, negativePrefix.length());
negative = true;
}
diff --git a/luni/src/main/java/java/util/TreeSet.java b/luni/src/main/java/java/util/TreeSet.java
index 0d330da..e4f2136 100644
--- a/luni/src/main/java/java/util/TreeSet.java
+++ b/luni/src/main/java/java/util/TreeSet.java
@@ -280,7 +280,7 @@
*/
public E pollFirst() {
Map.Entry<E, Object> entry = backingMap.pollFirstEntry();
- return (null == entry) ? null : entry.getKey();
+ return (entry == null) ? null : entry.getKey();
}
/**
@@ -291,7 +291,7 @@
*/
public E pollLast() {
Map.Entry<E, Object> entry = backingMap.pollLastEntry();
- return (null == entry) ? null : entry.getKey();
+ return (entry == null) ? null : entry.getKey();
}
/**
@@ -341,7 +341,7 @@
* @since 1.6
*/
public NavigableSet<E> descendingSet() {
- return (null != descendingSet) ? descendingSet
+ return (descendingSet != null) ? descendingSet
: (descendingSet = new TreeSet<E>(backingMap.descendingMap()));
}
diff --git a/luni/src/main/java/java/util/Vector.java b/luni/src/main/java/java/util/Vector.java
index ec03e18..dcd19f2 100644
--- a/luni/src/main/java/java/util/Vector.java
+++ b/luni/src/main/java/java/util/Vector.java
@@ -174,7 +174,7 @@
*/
@Override
public synchronized boolean addAll(int location, Collection<? extends E> collection) {
- if (0 <= location && location <= elementCount) {
+ if (location >= 0 && location <= elementCount) {
int size = collection.size();
if (size == 0) {
return false;
@@ -574,7 +574,7 @@
* @see #size
*/
public synchronized void insertElementAt(E object, int location) {
- if (0 <= location && location <= elementCount) {
+ if (location >= 0 && location <= elementCount) {
if (elementCount == elementData.length) {
growByOne();
}
@@ -792,7 +792,7 @@
* @see #size
*/
public synchronized void removeElementAt(int location) {
- if (0 <= location && location < elementCount) {
+ if (location >= 0 && location < elementCount) {
elementCount--;
int size = elementCount - location;
if (size > 0) {
diff --git a/luni/src/main/java/java/util/jar/JarEntry.java b/luni/src/main/java/java/util/jar/JarEntry.java
index f53f78f..381dd52 100644
--- a/luni/src/main/java/java/util/jar/JarEntry.java
+++ b/luni/src/main/java/java/util/jar/JarEntry.java
@@ -98,11 +98,11 @@
* @see java.security.cert.Certificate
*/
public Certificate[] getCertificates() {
- if (null == parentJar) {
+ if (parentJar == null) {
return null;
}
JarVerifier jarVerifier = parentJar.verifier;
- if (null == jarVerifier) {
+ if (jarVerifier == null) {
return null;
}
return jarVerifier.getCertificates(getName());
@@ -136,10 +136,10 @@
* @see CodeSigner
*/
public CodeSigner[] getCodeSigners() {
- if (null == signers) {
+ if (signers == null) {
signers = getCodeSigners(getCertificates());
}
- if (null == signers) {
+ if (signers == null) {
return null;
}
@@ -149,7 +149,7 @@
}
private CodeSigner[] getCodeSigners(Certificate[] certs) {
- if (null == certs) {
+ if (certs == null) {
return null;
}
@@ -163,7 +163,7 @@
continue;
}
X509Certificate x509 = (X509Certificate) element;
- if (null != prevIssuer) {
+ if (prevIssuer != null) {
X500Principal subj = x509.getSubjectX500Principal();
if (!prevIssuer.equals(subj)) {
// Ok, this ends the previous chain,
@@ -203,7 +203,7 @@
isFactoryChecked = true;
}
}
- if (null == factory) {
+ if (factory == null) {
return;
}
try {
@@ -211,7 +211,7 @@
} catch (CertificateException ex) {
// do nothing
}
- if (null != certPath) {
+ if (certPath != null) {
asigners.add(new CodeSigner(certPath, null));
}
}
diff --git a/luni/src/main/java/java/util/jar/JarVerifier.java b/luni/src/main/java/java/util/jar/JarVerifier.java
index f59ac13..cacafa0 100644
--- a/luni/src/main/java/java/util/jar/JarVerifier.java
+++ b/luni/src/main/java/java/util/jar/JarVerifier.java
@@ -300,7 +300,7 @@
* Recursive call in loading security provider related class which
* is in a signed JAR.
*/
- if (null == metaEntries) {
+ if (metaEntries == null) {
return;
}
if (signerCertChain != null) {
diff --git a/luni/src/main/java/java/util/jar/Manifest.java b/luni/src/main/java/java/util/jar/Manifest.java
index 621626179..289032f 100644
--- a/luni/src/main/java/java/util/jar/Manifest.java
+++ b/luni/src/main/java/java/util/jar/Manifest.java
@@ -214,7 +214,7 @@
// replace EOF and NUL with another new line
// which does not trigger an error
byte b = buf[buf.length - 1];
- if (0 == b || 26 == b) {
+ if (b == 0 || b == 26) {
buf[buf.length - 1] = '\n';
}
diff --git a/luni/src/main/java/java/util/logging/FileHandler.java b/luni/src/main/java/java/util/logging/FileHandler.java
index 6847d8a..0735911 100644
--- a/luni/src/main/java/java/util/logging/FileHandler.java
+++ b/luni/src/main/java/java/util/logging/FileHandler.java
@@ -182,7 +182,7 @@
* if current process has held lock for this fileName continue
* to find next file
*/
- if (null != allLocks.get(fileName)) {
+ if (allLocks.get(fileName) != null) {
continue;
}
if (files[0].exists()
@@ -221,16 +221,16 @@
super.initProperties("ALL", null, "java.util.logging.XMLFormatter",
null);
String className = this.getClass().getName();
- pattern = (null == p) ? getStringProperty(className + ".pattern",
+ pattern = (p == null) ? getStringProperty(className + ".pattern",
DEFAULT_PATTERN) : p;
if (pattern == null || pattern.isEmpty()) {
throw new NullPointerException("Pattern cannot be empty or null");
}
- append = (null == a) ? getBooleanProperty(className + ".append",
+ append = (a == null) ? getBooleanProperty(className + ".append",
DEFAULT_APPEND) : a.booleanValue();
- count = (null == c) ? getIntProperty(className + ".count",
+ count = (c == null) ? getIntProperty(className + ".count",
DEFAULT_COUNT) : c.intValue();
- limit = (null == l) ? getIntProperty(className + ".limit",
+ limit = (l == null) ? getIntProperty(className + ".limit",
DEFAULT_LIMIT) : l.intValue();
count = count < 1 ? DEFAULT_COUNT : count;
limit = limit < 0 ? DEFAULT_LIMIT : limit;
@@ -338,7 +338,7 @@
// value
private boolean getBooleanProperty(String key, boolean defaultValue) {
String property = manager.getProperty(key);
- if (null == property) {
+ if (property == null) {
return defaultValue;
}
boolean result = defaultValue;
@@ -360,7 +360,7 @@
private int getIntProperty(String key, int defaultValue) {
String property = manager.getProperty(key);
int result = defaultValue;
- if (null != property) {
+ if (property != null) {
try {
result = Integer.parseInt(property);
} catch (Exception e) {
diff --git a/luni/src/main/java/java/util/logging/Formatter.java b/luni/src/main/java/java/util/logging/Formatter.java
index 2ad4b4f..5e8d98e 100644
--- a/luni/src/main/java/java/util/logging/Formatter.java
+++ b/luni/src/main/java/java/util/logging/Formatter.java
@@ -65,21 +65,20 @@
String pattern = r.getMessage();
ResourceBundle rb = null;
// try to localize the message string first
- if (null != (rb = r.getResourceBundle())) {
+ if ((rb = r.getResourceBundle()) != null) {
try {
pattern = rb.getString(pattern);
} catch (Exception e) {
pattern = r.getMessage();
}
}
- if (null != pattern) {
+ if (pattern != null) {
Object[] params = r.getParameters();
/*
* if the message contains "{0", use java.text.MessageFormat to
* format the string
*/
- if (pattern.indexOf("{0") >= 0 && null != params
- && params.length > 0) {
+ if (pattern.indexOf("{0") >= 0 && params != null && params.length > 0) {
try {
pattern = MessageFormat.format(pattern, params);
} catch (IllegalArgumentException e) {
diff --git a/luni/src/main/java/java/util/logging/Handler.java b/luni/src/main/java/java/util/logging/Handler.java
index 5a3937d..21e77d7 100644
--- a/luni/src/main/java/java/util/logging/Handler.java
+++ b/luni/src/main/java/java/util/logging/Handler.java
@@ -66,7 +66,7 @@
// get a instance from given class name, using Class.forName()
private Object getDefaultInstance(String className) {
Object result = null;
- if (null == className) {
+ if (className == null) {
return result;
}
try {
@@ -83,9 +83,8 @@
Class<?> c = AccessController
.doPrivileged(new PrivilegedExceptionAction<Class<?>>() {
public Class<?> run() throws Exception {
- ClassLoader loader = Thread.currentThread()
- .getContextClassLoader();
- if (null == loader) {
+ ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ if (loader == null) {
loader = ClassLoader.getSystemClassLoader();
}
return loader.loadClass(className);
@@ -110,7 +109,7 @@
// set filter
final String filterName = manager.getProperty(prefix + ".filter");
- if (null != filterName) {
+ if (filterName != null) {
try {
filter = (Filter) getCustomizeInstance(filterName);
} catch (Exception e1) {
@@ -123,7 +122,7 @@
// set level
String levelName = manager.getProperty(prefix + ".level");
- if (null != levelName) {
+ if (levelName != null) {
try {
level = Level.parse(levelName);
} catch (Exception e) {
@@ -136,7 +135,7 @@
// set formatter
final String formatterName = manager.getProperty(prefix + ".formatter");
- if (null != formatterName) {
+ if (formatterName != null) {
try {
formatter = (Formatter) getCustomizeInstance(formatterName);
} catch (Exception e) {
@@ -242,13 +241,13 @@
* otherwise {@code false}.
*/
public boolean isLoggable(LogRecord record) {
- if (null == record) {
+ if (record == null) {
throw new NullPointerException();
}
if (this.level.intValue() == Level.OFF.intValue()) {
return false;
} else if (record.getLevel().intValue() >= this.level.intValue()) {
- return null == this.filter || this.filter.isLoggable(record);
+ return this.filter == null || this.filter.isLoggable(record);
}
return false;
}
@@ -324,7 +323,7 @@
*/
public void setErrorManager(ErrorManager em) {
LogManager.getLogManager().checkAccess();
- if (null == em) {
+ if (em == null) {
throw new NullPointerException();
}
this.errorMan = em;
@@ -352,7 +351,7 @@
* the formatter to set.
*/
void internalSetFormatter(Formatter newFormatter) {
- if (null == newFormatter) {
+ if (newFormatter == null) {
throw new NullPointerException();
}
this.formatter = newFormatter;
@@ -387,7 +386,7 @@
* have the required permission.
*/
public void setLevel(Level newLevel) {
- if (null == newLevel) {
+ if (newLevel == null) {
throw new NullPointerException();
}
LogManager.getLogManager().checkAccess();
diff --git a/luni/src/main/java/java/util/logging/LogManager.java b/luni/src/main/java/java/util/logging/LogManager.java
index d561f77..fac3602 100644
--- a/luni/src/main/java/java/util/logging/LogManager.java
+++ b/luni/src/main/java/java/util/logging/LogManager.java
@@ -163,10 +163,10 @@
public Object run() {
String className = System.getProperty("java.util.logging.manager");
- if (null != className) {
+ if (className != null) {
manager = (LogManager) getInstanceByClass(className);
}
- if (null == manager) {
+ if (manager == null) {
manager = new LogManager();
}
@@ -234,7 +234,7 @@
* {@code LoggingPermission("control")}
*/
public void checkAccess() {
- if (null != System.getSecurityManager()) {
+ if (System.getSecurityManager() != null) {
System.getSecurityManager().checkPermission(perm);
}
}
@@ -258,7 +258,7 @@
*/
public synchronized boolean addLogger(Logger logger) {
String name = logger.getName();
- if (null != loggers.get(name)) {
+ if (loggers.get(name) != null) {
return false;
}
addToFamilyTree(logger, name);
@@ -285,7 +285,7 @@
break;
}
}
- if (parent == null && null != (parent = loggers.get(""))) {
+ if (parent == null && (parent = loggers.get("")) != null) {
setParent(logger, parent);
}
@@ -305,7 +305,7 @@
return null;
}
});
- if (null != oldParent) {
+ if (oldParent != null) {
// -- remove from old parent as the parent has been changed
oldParent.children.remove(child);
}
@@ -439,7 +439,7 @@
// parse property "config" and apply setting
String configs = props.getProperty("config");
- if (null != configs) {
+ if (configs != null) {
StringTokenizer st = new StringTokenizer(configs, " ");
while (st.hasMoreTokens()) {
String configerName = st.nextToken();
@@ -451,7 +451,7 @@
Collection<Logger> allLoggers = loggers.values();
for (Logger logger : allLoggers) {
String property = props.getProperty(logger.getName() + ".level");
- if (null != property) {
+ if (property != null) {
logger.setLevel(Level.parse(property));
}
}
@@ -502,7 +502,7 @@
}
}
Logger root = loggers.get("");
- if (null != root) {
+ if (root != null) {
root.setLevel(Level.INFO);
}
}
diff --git a/luni/src/main/java/java/util/logging/LogRecord.java b/luni/src/main/java/java/util/logging/LogRecord.java
index 0a9e2fb..fd34eb4 100644
--- a/luni/src/main/java/java/util/logging/LogRecord.java
+++ b/luni/src/main/java/java/util/logging/LogRecord.java
@@ -162,7 +162,7 @@
synchronized (LogRecord.class) {
this.sequenceNumber = currentSequenceNumber++;
Integer id = currentThreadId.get();
- if (null == id) {
+ if (id == null) {
this.threadID = initThreadId;
currentThreadId.set(Integer.valueOf(initThreadId++));
} else {
@@ -465,12 +465,12 @@
out.defaultWriteObject();
out.writeByte(MAJOR);
out.writeByte(MINOR);
- if (null == parameters) {
+ if (parameters == null) {
out.writeInt(-1);
} else {
out.writeInt(parameters.length);
for (Object element : parameters) {
- out.writeObject(null == element ? null : element.toString());
+ out.writeObject((element == null) ? null : element.toString());
}
}
}
@@ -495,7 +495,7 @@
parameters[i] = in.readObject();
}
}
- if (null != resourceBundleName) {
+ if (resourceBundleName != null) {
try {
resourceBundle = Logger.loadResourceBundle(resourceBundleName);
} catch (MissingResourceException e) {
diff --git a/luni/src/main/java/java/util/logging/MemoryHandler.java b/luni/src/main/java/java/util/logging/MemoryHandler.java
index 08c36c9..4e7be49 100644
--- a/luni/src/main/java/java/util/logging/MemoryHandler.java
+++ b/luni/src/main/java/java/util/logging/MemoryHandler.java
@@ -109,7 +109,7 @@
}
// init size
String sizeString = manager.getProperty(className + ".size");
- if (null != sizeString) {
+ if (sizeString != null) {
try {
size = Integer.parseInt(sizeString);
if (size <= 0) {
@@ -121,7 +121,7 @@
}
// init push level
String pushName = manager.getProperty(className + ".push");
- if (null != pushName) {
+ if (pushName != null) {
try {
push = Level.parse(pushName);
} catch (Exception e) {
@@ -246,13 +246,13 @@
*/
public void push() {
for (int i = cursor; i < size; i++) {
- if (null != buffer[i]) {
+ if (buffer[i] != null) {
target.publish(buffer[i]);
}
buffer[i] = null;
}
for (int i = 0; i < cursor; i++) {
- if (null != buffer[i]) {
+ if (buffer[i] != null) {
target.publish(buffer[i]);
}
buffer[i] = null;
diff --git a/luni/src/main/java/java/util/logging/SimpleFormatter.java b/luni/src/main/java/java/util/logging/SimpleFormatter.java
index f5e7996..38672e7 100644
--- a/luni/src/main/java/java/util/logging/SimpleFormatter.java
+++ b/luni/src/main/java/java/util/logging/SimpleFormatter.java
@@ -53,7 +53,7 @@
LogManager.getSystemLineSeparator());
sb.append(r.getLevel().getName()).append(": ");
sb.append(formatMessage(r)).append(LogManager.getSystemLineSeparator());
- if (null != r.getThrown()) {
+ if (r.getThrown() != null) {
sb.append("Throwable occurred: ");
Throwable t = r.getThrown();
PrintWriter pw = null;
diff --git a/luni/src/main/java/java/util/logging/SocketHandler.java b/luni/src/main/java/java/util/logging/SocketHandler.java
index f227bc2..bcaee09 100644
--- a/luni/src/main/java/java/util/logging/SocketHandler.java
+++ b/luni/src/main/java/java/util/logging/SocketHandler.java
@@ -143,7 +143,7 @@
public void close() {
try {
super.close();
- if (null != this.socket) {
+ if (this.socket != null) {
this.socket.close();
this.socket = null;
}
diff --git a/luni/src/main/java/java/util/logging/StreamHandler.java b/luni/src/main/java/java/util/logging/StreamHandler.java
index eec3e38..42a02a3 100644
--- a/luni/src/main/java/java/util/logging/StreamHandler.java
+++ b/luni/src/main/java/java/util/logging/StreamHandler.java
@@ -119,7 +119,7 @@
// initialize the writer
private void initializeWriter() {
this.writerNotInitialized = false;
- if (null == getEncoding()) {
+ if (getEncoding() == null) {
this.writer = new OutputStreamWriter(this.os);
} else {
try {
@@ -169,7 +169,7 @@
* if {@code os} is {@code null}.
*/
protected void setOutputStream(OutputStream os) {
- if (null == os) {
+ if (os == null) {
throw new NullPointerException();
}
LogManager.getLogManager().checkAccess();
@@ -198,8 +198,8 @@
this.flush();
super.setEncoding(encoding);
// renew writer only if the writer exists
- if (null != this.writer) {
- if (null == getEncoding()) {
+ if (this.writer != null) {
+ if (getEncoding() == null) {
this.writer = new OutputStreamWriter(this.os);
} else {
try {
@@ -223,7 +223,7 @@
* whether to close the underlying output stream.
*/
void close(boolean closeStream) {
- if (null != this.os) {
+ if (this.os != null) {
if (this.writerNotInitialized) {
initializeWriter();
}
@@ -263,9 +263,9 @@
*/
@Override
public void flush() {
- if (null != this.os) {
+ if (this.os != null) {
try {
- if (null != this.writer) {
+ if (this.writer != null) {
this.writer.flush();
} else {
this.os.flush();
@@ -329,10 +329,10 @@
*/
@Override
public boolean isLoggable(LogRecord record) {
- if (null == record) {
+ if (record == null) {
return false;
}
- if (null != this.os && super.isLoggable(record)) {
+ if (this.os != null && super.isLoggable(record)) {
return true;
}
return false;
diff --git a/luni/src/main/java/java/util/logging/XMLFormatter.java b/luni/src/main/java/java/util/logging/XMLFormatter.java
index b83eeba..5e461c4 100644
--- a/luni/src/main/java/java/util/logging/XMLFormatter.java
+++ b/luni/src/main/java/java/util/logging/XMLFormatter.java
@@ -68,18 +68,18 @@
("</millis>")).append(lineSeperator);
sb.append(indent).append(("<sequence>")).append(r.getSequenceNumber())
.append(("</sequence>")).append(lineSeperator);
- if (null != r.getLoggerName()) {
+ if (r.getLoggerName() != null) {
sb.append(indent).append(("<logger>")).append(r.getLoggerName())
.append(("</logger>")).append(lineSeperator);
}
sb.append(indent).append(("<level>")).append(r.getLevel().getName())
.append(("</level>")).append(lineSeperator);
- if (null != r.getSourceClassName()) {
+ if (r.getSourceClassName() != null) {
sb.append(indent).append(("<class>"))
.append(r.getSourceClassName()).append(("</class>"))
.append(lineSeperator);
}
- if (null != r.getSourceMethodName()) {
+ if (r.getSourceMethodName() != null) {
sb.append(indent).append(("<method>")).append(
r.getSourceMethodName()).append(("</method>")).append(
lineSeperator);
@@ -105,7 +105,7 @@
// to parse pattern string
ResourceBundle rb = r.getResourceBundle();
String pattern = r.getMessage();
- if (null != rb && null != pattern) {
+ if (rb != null && pattern != null) {
String message;
try {
message = rb.getString(pattern);
@@ -126,7 +126,7 @@
r.getResourceBundleName()).append(("</catalog>"))
.append(lineSeperator);
}
- } else if (null != pattern) {
+ } else if (pattern != null) {
sb.append(indent).append(("<message>")).append(pattern).append(
("</message>")).append(lineSeperator);
} else {
@@ -175,10 +175,10 @@
@Override
public String getHead(Handler h) {
String encoding = null;
- if (null != h) {
+ if (h != null) {
encoding = h.getEncoding();
}
- if (null == encoding) {
+ if (encoding == null) {
encoding = getSystemProperty("file.encoding");
}
StringBuilder sb = new StringBuilder();
diff --git a/luni/src/main/java/java/util/prefs/AbstractPreferences.java b/luni/src/main/java/java/util/prefs/AbstractPreferences.java
index be768c5..1ae2565 100644
--- a/luni/src/main/java/java/util/prefs/AbstractPreferences.java
+++ b/luni/src/main/java/java/util/prefs/AbstractPreferences.java
@@ -144,10 +144,10 @@
* parent} is not {@code null}.
*/
protected AbstractPreferences(AbstractPreferences parent, String name) {
- if ((null == parent ^ name.length() == 0) || name.indexOf("/") >= 0) {
+ if ((parent == null ^ name.length() == 0) || name.indexOf("/") >= 0) {
throw new IllegalArgumentException();
}
- root = null == parent ? this : parent.root;
+ root = (parent == null) ? this : parent.root;
nodeChangeListeners = new LinkedList<EventListener>();
preferenceChangeListeners = new LinkedList<EventListener>();
isRemoved = false;
@@ -563,7 +563,7 @@
String[] names = path.split("/");
AbstractPreferences currentNode = this;
AbstractPreferences temp = null;
- if (null != currentNode) {
+ if (currentNode != null) {
for (int i = 0; i < names.length; i++) {
String name = names[i];
synchronized (currentNode.lock) {
@@ -573,7 +573,7 @@
}
}
currentNode = temp;
- if (null == currentNode) {
+ if (currentNode == null) {
break;
}
}
@@ -601,7 +601,7 @@
@Override
public boolean nodeExists(String name) throws BackingStoreException {
- if (null == name) {
+ if (name == null) {
throw new NullPointerException();
}
AbstractPreferences startNode = null;
@@ -625,7 +625,7 @@
}
try {
Preferences result = startNode.nodeImpl(name, false);
- return null == result ? false : true;
+ return (result != null);
} catch(IllegalArgumentException e) {
return false;
}
@@ -645,7 +645,7 @@
@Override
public void put(String key, String value) {
- if (null == key || null == value) {
+ if (key == null || value == null) {
throw new NullPointerException();
}
if (key.length() > MAX_KEY_LENGTH || value.length() > MAX_VALUE_LENGTH) {
@@ -717,7 +717,7 @@
checkState();
String[] childrenNames = childrenNamesSpi();
for (int i = 0; i < childrenNames.length; i++) {
- if (null == cachedNode.get(childrenNames[i])) {
+ if (cachedNode.get(childrenNames[i]) == null) {
AbstractPreferences child = childSpi(childrenNames[i]);
cachedNode.put(childrenNames[i], child);
}
@@ -739,7 +739,7 @@
@Override
public void addNodeChangeListener(NodeChangeListener ncl) {
- if (null == ncl) {
+ if (ncl == null) {
throw new NullPointerException();
}
checkState();
@@ -750,7 +750,7 @@
@Override
public void addPreferenceChangeListener(PreferenceChangeListener pcl) {
- if (null == pcl) {
+ if (pcl == null) {
throw new NullPointerException();
}
checkState();
diff --git a/luni/src/main/java/java/util/prefs/FilePreferencesImpl.java b/luni/src/main/java/java/util/prefs/FilePreferencesImpl.java
index 5c10dca..0fd8466 100644
--- a/luni/src/main/java/java/util/prefs/FilePreferencesImpl.java
+++ b/luni/src/main/java/java/util/prefs/FilePreferencesImpl.java
@@ -139,7 +139,7 @@
}
});
- if (null == names) {// file is not a directory, exception case
+ if (names == null) {// file is not a directory, exception case
throw new BackingStoreException("Cannot get child names for " + toString()
+ " (path is " + path + ")");
}
@@ -184,7 +184,7 @@
@Override
protected String getSpi(String key) {
try {
- if (null == prefs) {
+ if (prefs == null) {
prefs = XMLParser.loadFilePrefs(prefsFile);
}
return prefs.getProperty(key);
diff --git a/luni/src/main/java/java/util/prefs/Preferences.java b/luni/src/main/java/java/util/prefs/Preferences.java
index 707b3ba..94eb2ab 100644
--- a/luni/src/main/java/java/util/prefs/Preferences.java
+++ b/luni/src/main/java/java/util/prefs/Preferences.java
@@ -828,10 +828,9 @@
//check the RuntimePermission("preferences")
private static void checkSecurity() {
SecurityManager manager = System.getSecurityManager();
- if(null != manager){
+ if (manager != null){
manager.checkPermission(PREFS_PERM);
}
-
}
/**
@@ -862,7 +861,7 @@
//parse node's absolute path from class instance
private static String getNodeName(Class<?> c){
Package p = c.getPackage();
- if(null == p){
+ if (p == null){
return "/<unnamed>";
}
return "/"+p.getName().replace('.', '/');
diff --git a/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/ftp/FtpURLConnection.java b/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/ftp/FtpURLConnection.java
index bdd06db..2414154 100644
--- a/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/ftp/FtpURLConnection.java
+++ b/luni/src/main/java/org/apache/harmony/luni/internal/net/www/protocol/ftp/FtpURLConnection.java
@@ -168,7 +168,7 @@
// Use system-wide ProxySelect to select proxy list,
// then try to connect via elements in the proxy list.
List<Proxy> proxyList = null;
- if (null != proxy) {
+ if (proxy != null) {
proxyList = new ArrayList<Proxy>(1);
proxyList.add(proxy);
} else {
@@ -177,7 +177,7 @@
proxyList = selector.select(uri);
}
}
- if (null == proxyList) {
+ if (proxyList == null) {
currentProxy = null;
connectInternal();
} else {
@@ -194,7 +194,7 @@
failureReason = ioe.getLocalizedMessage();
// If connect failed, callback "connectFailed"
// should be invoked.
- if (null != selector && Proxy.NO_PROXY != currentProxy) {
+ if (selector != null && Proxy.NO_PROXY != currentProxy) {
selector.connectFailed(uri, currentProxy.address(), ioe);
}
}
@@ -211,7 +211,7 @@
if (port <= 0) {
port = FTP_PORT;
}
- if (null == currentProxy || Proxy.Type.HTTP == currentProxy.type()) {
+ if (currentProxy == null || Proxy.Type.HTTP == currentProxy.type()) {
controlSocket = new Socket();
} else {
controlSocket = new Socket(currentProxy);
diff --git a/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java b/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java
index 18f6d6d..4952cf6 100644
--- a/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java
+++ b/luni/src/main/java/org/apache/harmony/luni/net/PlainSocketImpl.java
@@ -285,7 +285,7 @@
// determined by ProxySelector.
InetSocketAddress addr = (InetSocketAddress) proxy.address();
proxyName = addr.getHostName();
- if (null == proxyName) {
+ if (proxyName == null) {
proxyName = addr.getAddress().getHostAddress();
}
return InetAddress.getByName(proxyName);
diff --git a/luni/src/main/java/org/apache/harmony/luni/util/TwoKeyHashMap.java b/luni/src/main/java/org/apache/harmony/luni/util/TwoKeyHashMap.java
index b7d3097..086d561 100644
--- a/luni/src/main/java/org/apache/harmony/luni/util/TwoKeyHashMap.java
+++ b/luni/src/main/java/org/apache/harmony/luni/util/TwoKeyHashMap.java
@@ -127,7 +127,7 @@
*/
public V remove(Object key1, Object key2) {
Entry<E, K, V> e = removeEntry(key1, key2);
- return null != e ? e.value : null;
+ return (e != null) ? e.value : null;
}
/**
diff --git a/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java b/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java
index 9176940..fd298b9 100644
--- a/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java
+++ b/luni/src/main/java/org/apache/harmony/xnet/provider/jsse/OpenSSLSocketImpl.java
@@ -797,7 +797,7 @@
if ((len | off) < 0 || len > b.length - off) {
throw new IndexOutOfBoundsException();
}
- if (0 == len) {
+ if (len == 0) {
return 0;
}
return NativeCrypto.SSL_read(sslNativePointer, fd, OpenSSLSocketImpl.this,