8215281: Use String.isEmpty() when applicable in java.base

Reviewed-by: dfuchs, alanb
This commit is contained in:
Claes Redestad 2018-12-13 15:31:05 +01:00
parent c998ead188
commit a3df1d618e
155 changed files with 340 additions and 382 deletions

View File

@ -996,7 +996,7 @@ class Attribute implements Comparable<Attribute> {
endp = cstr.indexOf(',', cp); endp = cstr.indexOf(',', cp);
if (endp < 0) endp = cstrlen; if (endp < 0) endp = cstrlen;
String cstr1 = cstr.substring(cp, endp); String cstr1 = cstr.substring(cp, endp);
if (cstr1.length() == 0) if (cstr1.isEmpty())
cstr1 = "empty"; // will fail parse cstr1 = "empty"; // will fail parse
int value0, value1; int value0, value1;
// Check for a case range (new in 1.6). // Check for a case range (new in 1.6).

View File

@ -279,7 +279,7 @@ class Driver {
junpack.properties().putAll(engProps); junpack.properties().putAll(engProps);
if (doRepack && newfile.equals(jarfile)) { if (doRepack && newfile.equals(jarfile)) {
String zipc = getZipComment(jarfile); String zipc = getZipComment(jarfile);
if (verbose && zipc.length() > 0) if (verbose && !zipc.isEmpty())
System.out.println(MessageFormat.format(RESOURCE.getString(DriverResource.DETECTED_ZIP_COMMENT), zipc)); System.out.println(MessageFormat.format(RESOURCE.getString(DriverResource.DETECTED_ZIP_COMMENT), zipc));
if (zipc.indexOf(Utils.PACK_ZIP_ARCHIVE_MARKER_COMMENT) >= 0) { if (zipc.indexOf(Utils.PACK_ZIP_ARCHIVE_MARKER_COMMENT) >= 0) {
System.out.println(MessageFormat.format(RESOURCE.getString(DriverResource.SKIP_FOR_REPACKED), jarfile)); System.out.println(MessageFormat.format(RESOURCE.getString(DriverResource.SKIP_FOR_REPACKED), jarfile));
@ -552,7 +552,7 @@ class Driver {
if (words.length == 0) continue loadOptmap; if (words.length == 0) continue loadOptmap;
String opt = words[0]; String opt = words[0];
words[0] = ""; // initial word is not a spec words[0] = ""; // initial word is not a spec
if (opt.length() == 0 && words.length >= 1) { if (opt.isEmpty() && words.length >= 1) {
opt = words[1]; // initial "word" is empty due to leading ' ' opt = words[1]; // initial "word" is empty due to leading ' '
words[1] = ""; words[1] = "";
} }
@ -622,7 +622,7 @@ class Driver {
switch (specop) { switch (specop) {
case '+': case '+':
// + means we want an non-empty val suffix. // + means we want an non-empty val suffix.
ok = (val.length() != 0); ok = !val.isEmpty();
specop = spec.charAt(sidx++); specop = spec.charAt(sidx++);
break; break;
case '*': case '*':
@ -641,10 +641,10 @@ class Driver {
String specarg = spec.substring(sidx); String specarg = spec.substring(sidx);
switch (specop) { switch (specop) {
case '.': // terminate the option sequence case '.': // terminate the option sequence
resultString = (specarg.length() != 0)? specarg.intern(): opt; resultString = specarg.isEmpty() ? opt : specarg.intern();
break doArgs; break doArgs;
case '?': // abort the option sequence case '?': // abort the option sequence
resultString = (specarg.length() != 0)? specarg.intern(): arg; resultString = specarg.isEmpty() ? arg : specarg.intern();
isError = true; isError = true;
break eachSpec; break eachSpec;
case '@': // change the effective opt name case '@': // change the effective opt name
@ -655,14 +655,14 @@ class Driver {
val = ""; val = "";
break; break;
case '!': // negation option case '!': // negation option
String negopt = (specarg.length() != 0)? specarg.intern(): opt; String negopt = specarg.isEmpty() ? opt : specarg.intern();
properties.remove(negopt); properties.remove(negopt);
properties.put(negopt, null); // leave placeholder properties.put(negopt, null); // leave placeholder
didAction = true; didAction = true;
break; break;
case '$': // normal "boolean" option case '$': // normal "boolean" option
String boolval; String boolval;
if (specarg.length() != 0) { if (!specarg.isEmpty()) {
// If there is a given spec token, store it. // If there is a given spec token, store it.
boolval = specarg; boolval = specarg;
} else { } else {

View File

@ -153,7 +153,7 @@ public class KeyManagerFactory {
String provider) String provider)
throws NoSuchAlgorithmException, NoSuchProviderException throws NoSuchAlgorithmException, NoSuchProviderException
{ {
if (provider == null || provider.length() == 0) if (provider == null || provider.isEmpty())
throw new IllegalArgumentException("missing provider"); throw new IllegalArgumentException("missing provider");
Object[] objs = SSLSecurity.getImpl(algorithm, "KeyManagerFactory", Object[] objs = SSLSecurity.getImpl(algorithm, "KeyManagerFactory",
provider); provider);

View File

@ -109,7 +109,7 @@ public class SSLContext {
public static SSLContext getInstance(String protocol, String provider) public static SSLContext getInstance(String protocol, String provider)
throws NoSuchAlgorithmException, NoSuchProviderException throws NoSuchAlgorithmException, NoSuchProviderException
{ {
if (provider == null || provider.length() == 0) if (provider == null || provider.isEmpty())
throw new IllegalArgumentException("missing provider"); throw new IllegalArgumentException("missing provider");
Object[] objs = SSLSecurity.getImpl(protocol, "SSLContext", Object[] objs = SSLSecurity.getImpl(protocol, "SSLContext",
provider); provider);

View File

@ -155,7 +155,7 @@ public class TrustManagerFactory {
String provider) String provider)
throws NoSuchAlgorithmException, NoSuchProviderException throws NoSuchAlgorithmException, NoSuchProviderException
{ {
if (provider == null || provider.length() == 0) if (provider == null || provider.isEmpty())
throw new IllegalArgumentException("missing provider"); throw new IllegalArgumentException("missing provider");
Object[] objs = SSLSecurity.getImpl(algorithm, "TrustManagerFactory", Object[] objs = SSLSecurity.getImpl(algorithm, "TrustManagerFactory",
provider); provider);

View File

@ -247,7 +247,7 @@ public final class Console implements Flushable
String line = null; String line = null;
synchronized (writeLock) { synchronized (writeLock) {
synchronized(readLock) { synchronized(readLock) {
if (fmt.length() != 0) if (!fmt.isEmpty())
pw.format(fmt, args); pw.format(fmt, args);
try { try {
char[] ca = readline(false); char[] ca = readline(false);
@ -319,7 +319,7 @@ public final class Console implements Flushable
} }
IOError ioe = null; IOError ioe = null;
try { try {
if (fmt.length() != 0) if (!fmt.isEmpty())
pw.format(fmt, args); pw.format(fmt, args);
passwd = readline(true); passwd = readline(true);
} catch (IOException x) { } catch (IOException x) {

View File

@ -1119,7 +1119,7 @@ public abstract class ClassLoader {
// true if the name is null or has the potential to be a valid binary name // true if the name is null or has the potential to be a valid binary name
private boolean checkName(String name) { private boolean checkName(String name) {
if ((name == null) || (name.length() == 0)) if ((name == null) || (name.isEmpty()))
return true; return true;
if ((name.indexOf('/') != -1) || (name.charAt(0) == '[')) if ((name.indexOf('/') != -1) || (name.charAt(0) == '['))
return false; return false;

View File

@ -1409,7 +1409,7 @@ public final class Integer extends Number
boolean negative = false; boolean negative = false;
Integer result; Integer result;
if (nm.length() == 0) if (nm.isEmpty())
throw new NumberFormatException("Zero length string"); throw new NumberFormatException("Zero length string");
char firstChar = nm.charAt(0); char firstChar = nm.charAt(0);
// Handle sign, if present // Handle sign, if present

View File

@ -1248,7 +1248,7 @@ public final class Long extends Number
boolean negative = false; boolean negative = false;
Long result; Long result;
if (nm.length() == 0) if (nm.isEmpty())
throw new NumberFormatException("Zero length string"); throw new NumberFormatException("Zero length string");
char firstChar = nm.charAt(0); char firstChar = nm.charAt(0);
// Handle sign, if present // Handle sign, if present

View File

@ -397,11 +397,11 @@ public class Package extends NamedPackage implements java.lang.reflect.Annotated
public String toString() { public String toString() {
String spec = versionInfo.specTitle; String spec = versionInfo.specTitle;
String ver = versionInfo.specVersion; String ver = versionInfo.specVersion;
if (spec != null && spec.length() > 0) if (spec != null && !spec.isEmpty())
spec = ", " + spec; spec = ", " + spec;
else else
spec = ""; spec = "";
if (ver != null && ver.length() > 0) if (ver != null && !ver.isEmpty())
ver = ", version " + ver; ver = ", version " + ver;
else else
ver = ""; ver = "";

View File

@ -403,7 +403,7 @@ public class Runtime {
*/ */
public Process exec(String command, String[] envp, File dir) public Process exec(String command, String[] envp, File dir)
throws IOException { throws IOException {
if (command.length() == 0) if (command.isEmpty())
throw new IllegalArgumentException("Empty command"); throw new IllegalArgumentException("Empty command");
StringTokenizer st = new StringTokenizer(command); StringTokenizer st = new StringTokenizer(command);

View File

@ -664,7 +664,7 @@ public final class String
* object. * object.
*/ */
public int length() { public int length() {
return value.length >> coder(); return isLatin1() ? value.length : value.length >> UTF16;
} }
/** /**
@ -1943,8 +1943,7 @@ public final class String
* characters followed by the string argument's characters. * characters followed by the string argument's characters.
*/ */
public String concat(String str) { public String concat(String str) {
int olen = str.length(); if (str.isEmpty()) {
if (olen == 0) {
return this; return this;
} }
if (coder() == str.coder()) { if (coder() == str.coder()) {
@ -1956,6 +1955,7 @@ public final class String
return new String(buf, coder); return new String(buf, coder);
} }
int len = length(); int len = length();
int olen = str.length();
byte[] buf = StringUTF16.newBytesFor(len + olen); byte[] buf = StringUTF16.newBytesFor(len + olen);
getBytes(buf, 0, UTF16); getBytes(buf, 0, UTF16);
str.getBytes(buf, len, UTF16); str.getBytes(buf, len, UTF16);
@ -2316,7 +2316,7 @@ public final class String
// Construct result // Construct result
int resultSize = list.size(); int resultSize = list.size();
if (limit == 0) { if (limit == 0) {
while (resultSize > 0 && list.get(resultSize - 1).length() == 0) { while (resultSize > 0 && list.get(resultSize - 1).isEmpty()) {
resultSize--; resultSize--;
} }
} }

View File

@ -73,7 +73,7 @@ class VersionProps {
"@@VENDOR_VERSION_STRING@@"; "@@VENDOR_VERSION_STRING@@";
private static final String vendor_version = private static final String vendor_version =
(VENDOR_VERSION_STRING.length() > 0 (!VENDOR_VERSION_STRING.isEmpty()
? " " + VENDOR_VERSION_STRING : ""); ? " " + VENDOR_VERSION_STRING : "");
private static final String VENDOR = private static final String VENDOR =
@ -95,7 +95,7 @@ class VersionProps {
props.put("java.version.date", java_version_date); props.put("java.version.date", java_version_date);
props.put("java.runtime.version", java_runtime_version); props.put("java.runtime.version", java_runtime_version);
props.put("java.runtime.name", java_runtime_name); props.put("java.runtime.name", java_runtime_name);
if (VENDOR_VERSION_STRING.length() > 0) if (!VENDOR_VERSION_STRING.isEmpty())
props.put("java.vendor.version", VENDOR_VERSION_STRING); props.put("java.vendor.version", VENDOR_VERSION_STRING);
props.put("java.class.version", CLASSFILE_MAJOR_MINOR); props.put("java.class.version", CLASSFILE_MAJOR_MINOR);

View File

@ -103,7 +103,7 @@ public final class ConstantBootstraps {
if (type != Class.class) { if (type != Class.class) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
if (name.length() == 0 || name.length() > 1) { if (name.length() != 1) {
throw new IllegalArgumentException(String.format("not primitive: %s", name)); throw new IllegalArgumentException(String.format("not primitive: %s", name));
} }

View File

@ -201,7 +201,7 @@ public class MethodHandles {
throw new IllegalAccessException(callerModule + " does not read " + targetModule); throw new IllegalAccessException(callerModule + " does not read " + targetModule);
if (targetModule.isNamed()) { if (targetModule.isNamed()) {
String pn = targetClass.getPackageName(); String pn = targetClass.getPackageName();
assert pn.length() > 0 : "unnamed package cannot be in named module"; assert !pn.isEmpty() : "unnamed package cannot be in named module";
if (!targetModule.isOpen(pn, callerModule)) if (!targetModule.isOpen(pn, callerModule))
throw new IllegalAccessException(targetModule + " does not open " + pn + " to " + callerModule); throw new IllegalAccessException(targetModule + " does not open " + pn + " to " + callerModule);
} }

View File

@ -62,7 +62,7 @@ final class ProxyClassesDumper {
} }
try { try {
path = path.trim(); path = path.trim();
final Path dir = Path.of(path.length() == 0 ? "." : path); final Path dir = Path.of(path.isEmpty() ? "." : path);
AccessController.doPrivileged(new PrivilegedAction<>() { AccessController.doPrivileged(new PrivilegedAction<>() {
@Override @Override
public Void run() { public Void run() {

View File

@ -149,7 +149,7 @@ public final class HttpCookie implements Cloneable {
*/ */
HttpCookie(String name, String value, String header, long creationTime) { HttpCookie(String name, String value, String header, long creationTime) {
name = name.trim(); name = name.trim();
if (name.length() == 0 || !isToken(name) || name.charAt(0) == '$') { if (name.isEmpty() || !isToken(name) || name.charAt(0) == '$') {
throw new IllegalArgumentException("Illegal cookie name"); throw new IllegalArgumentException("Illegal cookie name");
} }

View File

@ -433,7 +433,7 @@ class Inet6Address extends InetAddress {
NetworkInterface nif) NetworkInterface nif)
throws UnknownHostException throws UnknownHostException
{ {
if (host != null && host.length() > 0 && host.charAt(0) == '[') { if (host != null && !host.isEmpty() && host.charAt(0) == '[') {
if (host.charAt(host.length()-1) == ']') { if (host.charAt(host.length()-1) == ']') {
host = host.substring(1, host.length() -1); host = host.substring(1, host.length() -1);
} }
@ -466,7 +466,7 @@ class Inet6Address extends InetAddress {
int scope_id) int scope_id)
throws UnknownHostException throws UnknownHostException
{ {
if (host != null && host.length() > 0 && host.charAt(0) == '[') { if (host != null && !host.isEmpty() && host.charAt(0) == '[') {
if (host.charAt(host.length()-1) == ']') { if (host.charAt(host.length()-1) == ']') {
host = host.substring(1, host.length() -1); host = host.substring(1, host.length() -1);
} }
@ -601,7 +601,7 @@ class Inet6Address extends InetAddress {
boolean scope_ifname_set = gf.get("scope_ifname_set", false); boolean scope_ifname_set = gf.get("scope_ifname_set", false);
String ifname = (String)gf.get("ifname", null); String ifname = (String)gf.get("ifname", null);
if (ifname != null && !"".equals (ifname)) { if (ifname != null && !ifname.isEmpty()) {
try { try {
scope_ifname = NetworkInterface.getByName(ifname); scope_ifname = NetworkInterface.getByName(ifname);
if (scope_ifname == null) { if (scope_ifname == null) {

View File

@ -1187,7 +1187,7 @@ class InetAddress implements java.io.Serializable {
*/ */
public static InetAddress getByAddress(String host, byte[] addr) public static InetAddress getByAddress(String host, byte[] addr)
throws UnknownHostException { throws UnknownHostException {
if (host != null && host.length() > 0 && host.charAt(0) == '[') { if (host != null && !host.isEmpty() && host.charAt(0) == '[') {
if (host.charAt(host.length()-1) == ']') { if (host.charAt(host.length()-1) == ']') {
host = host.substring(1, host.length() -1); host = host.substring(1, host.length() -1);
} }
@ -1301,7 +1301,7 @@ class InetAddress implements java.io.Serializable {
private static InetAddress[] getAllByName(String host, InetAddress reqAddr) private static InetAddress[] getAllByName(String host, InetAddress reqAddr)
throws UnknownHostException { throws UnknownHostException {
if (host == null || host.length() == 0) { if (host == null || host.isEmpty()) {
InetAddress[] ret = new InetAddress[1]; InetAddress[] ret = new InetAddress[1];
ret[0] = impl.loopbackAddress(); ret[0] = impl.loopbackAddress();
return ret; return ret;

View File

@ -460,7 +460,7 @@ public final class SocketPermission extends Permission
} }
return; return;
} else { } else {
if (host.length() > 0) { if (!host.isEmpty()) {
// see if we are being initialized with an IP address. // see if we are being initialized with an IP address.
char ch = host.charAt(0); char ch = host.charAt(0);
if (ch == ':' || Character.digit(ch, 16) != -1) { if (ch == ':' || Character.digit(ch, 16) != -1) {
@ -705,8 +705,7 @@ public final class SocketPermission extends Permission
.orElse(b); .orElse(b);
} }
return cdomain.length() != 0 && hdomain.length() != 0 return !cdomain.isEmpty() && !hdomain.isEmpty() && cdomain.equals(hdomain);
&& cdomain.equals(hdomain);
} }
private boolean authorized(String cname, byte[] addr) { private boolean authorized(String cname, byte[] addr) {

View File

@ -1959,10 +1959,8 @@ public final class URI
throws URISyntaxException throws URISyntaxException
{ {
if (scheme != null) { if (scheme != null) {
if ((path != null) if (path != null && !path.isEmpty() && path.charAt(0) != '/')
&& ((path.length() > 0) && (path.charAt(0) != '/'))) throw new URISyntaxException(s, "Relative path in absolute URI");
throw new URISyntaxException(s,
"Relative path in absolute URI");
} }
} }
@ -2163,7 +2161,7 @@ public final class URI
ru.port = base.port; ru.port = base.port;
String cp = (child.path == null) ? "" : child.path; String cp = (child.path == null) ? "" : child.path;
if ((cp.length() > 0) && (cp.charAt(0) == '/')) { if (!cp.isEmpty() && cp.charAt(0) == '/') {
// 5.2 (5): Child path is absolute // 5.2 (5): Child path is absolute
ru.path = child.path; ru.path = child.path;
} else { } else {
@ -2187,7 +2185,7 @@ public final class URI
// o.w., return a new URI containing the normalized path. // o.w., return a new URI containing the normalized path.
// //
private static URI normalize(URI u) { private static URI normalize(URI u) {
if (u.isOpaque() || (u.path == null) || (u.path.length() == 0)) if (u.isOpaque() || u.path == null || u.path.isEmpty())
return u; return u;
String np = normalize(u.path); String np = normalize(u.path);

View File

@ -1513,7 +1513,7 @@ public final class URL implements java.io.Serializable {
String ref = (String)gf.get("ref", null); String ref = (String)gf.get("ref", null);
int hashCode = gf.get("hashCode", -1); int hashCode = gf.get("hashCode", -1);
if (authority == null if (authority == null
&& ((host != null && host.length() > 0) || port != -1)) { && ((host != null && !host.isEmpty()) || port != -1)) {
if (host == null) if (host == null)
host = ""; host = "";
authority = (port == -1) ? host : host + ":" + port; authority = (port == -1) ? host : host + ":" + port;
@ -1560,7 +1560,7 @@ public final class URL implements java.io.Serializable {
// Construct authority part // Construct authority part
if (authority == null if (authority == null
&& ((host != null && host.length() > 0) || port != -1)) { && ((host != null && !host.isEmpty()) || port != -1)) {
if (host == null) if (host == null)
host = ""; host = "";
authority = (port == -1) ? host : host + ":" + port; authority = (port == -1) ? host : host + ":" + port;
@ -1716,7 +1716,7 @@ final class UrlDeserializedState {
// pre-compute length of StringBuffer // pre-compute length of StringBuffer
int len = protocol.length() + 1; int len = protocol.length() + 1;
if (authority != null && authority.length() > 0) if (authority != null && !authority.isEmpty())
len += 2 + authority.length(); len += 2 + authority.length();
if (file != null) { if (file != null) {
len += file.length(); len += file.length();
@ -1726,7 +1726,7 @@ final class UrlDeserializedState {
StringBuilder result = new StringBuilder(len); StringBuilder result = new StringBuilder(len);
result.append(protocol); result.append(protocol);
result.append(":"); result.append(":");
if (authority != null && authority.length() > 0) { if (authority != null && !authority.isEmpty()) {
result.append("//"); result.append("//");
result.append(authority); result.append(authority);
} }

View File

@ -743,7 +743,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
locUrl = ((JarURLConnection)urlConnection).getJarFileURL(); locUrl = ((JarURLConnection)urlConnection).getJarFileURL();
} }
String host = locUrl.getHost(); String host = locUrl.getHost();
if (host != null && (host.length() > 0)) if (host != null && !host.isEmpty())
p = new SocketPermission(host, p = new SocketPermission(host,
SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION); SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION);
} }

View File

@ -133,7 +133,7 @@ public class URLDecoder {
* @since 1.4 * @since 1.4
*/ */
public static String decode(String s, String enc) throws UnsupportedEncodingException { public static String decode(String s, String enc) throws UnsupportedEncodingException {
if (enc.length() == 0) { if (enc.isEmpty()) {
throw new UnsupportedEncodingException ("URLDecoder: empty string enc parameter"); throw new UnsupportedEncodingException ("URLDecoder: empty string enc parameter");
} }

View File

@ -409,7 +409,7 @@ public final class URLPermission extends Permission {
char c = methods.charAt(i); char c = methods.charAt(i);
if (c == ',') { if (c == ',') {
String s = b.toString(); String s = b.toString();
if (s.length() > 0) if (!s.isEmpty())
l.add(s); l.add(s);
b = new StringBuilder(); b = new StringBuilder();
} else if (c == ' ' || c == '\t') { } else if (c == ' ' || c == '\t') {
@ -423,7 +423,7 @@ public final class URLPermission extends Permission {
} }
} }
String s = b.toString(); String s = b.toString();
if (s.length() > 0) if (!s.isEmpty())
l.add(s); l.add(s);
return l; return l;
} }
@ -448,7 +448,7 @@ public final class URLPermission extends Permission {
b.append(c); b.append(c);
} else if (c == ',') { } else if (c == ',') {
String s = b.toString(); String s = b.toString();
if (s.length() > 0) if (!s.isEmpty())
l.add(s); l.add(s);
b = new StringBuilder(); b = new StringBuilder();
capitalizeNext = true; capitalizeNext = true;
@ -458,7 +458,7 @@ public final class URLPermission extends Permission {
} }
} }
String s = b.toString(); String s = b.toString();
if (s.length() > 0) if (!s.isEmpty())
l.add(s); l.add(s);
return l; return l;
} }

View File

@ -235,7 +235,7 @@ public abstract class URLStreamHandler {
start = i; start = i;
// If the authority is defined then the path is defined by the // If the authority is defined then the path is defined by the
// spec only; See RFC 2396 Section 5.2.4. // spec only; See RFC 2396 Section 5.2.4.
if (authority != null && authority.length() > 0) if (authority != null && !authority.isEmpty())
path = ""; path = "";
} }
@ -247,7 +247,7 @@ public abstract class URLStreamHandler {
if (start < limit) { if (start < limit) {
if (spec.charAt(start) == '/') { if (spec.charAt(start) == '/') {
path = spec.substring(start, limit); path = spec.substring(start, limit);
} else if (path != null && path.length() > 0) { } else if (path != null && !path.isEmpty()) {
isRelPath = true; isRelPath = true;
int ind = path.lastIndexOf('/'); int ind = path.lastIndexOf('/');
String separator = ""; String separator = "";
@ -483,11 +483,11 @@ public abstract class URLStreamHandler {
String s; String s;
return u.getProtocol() return u.getProtocol()
+ ':' + ':'
+ (((s = u.getAuthority()) != null && s.length() > 0) + ((s = u.getAuthority()) != null && !s.isEmpty()
? "//" + s : "") ? "//" + s : "")
+ (((s = u.getPath()) != null) ? s : "") + ((s = u.getPath()) != null ? s : "")
+ (((s = u.getQuery()) != null) ? '?' + s : "") + ((s = u.getQuery()) != null ? '?' + s : "")
+ (((s = u.getRef()) != null) ? '#' + s : ""); + ((s = u.getRef()) != null ? '#' + s : "");
} }
/** /**
@ -544,7 +544,7 @@ public abstract class URLStreamHandler {
*/ */
String authority = null; String authority = null;
String userInfo = null; String userInfo = null;
if (host != null && host.length() != 0) { if (host != null && !host.isEmpty()) {
authority = (port == -1) ? host : host + ":" + port; authority = (port == -1) ? host : host + ":" + port;
int at = host.lastIndexOf('@'); int at = host.lastIndexOf('@');
if (at != -1) { if (at != -1) {

View File

@ -104,7 +104,7 @@ public final class LinkPermission extends BasicPermission {
public LinkPermission(String name, String actions) { public LinkPermission(String name, String actions) {
super(name); super(name);
checkName(name); checkName(name);
if (actions != null && actions.length() > 0) { if (actions != null && !actions.isEmpty()) {
throw new IllegalArgumentException("actions: " + actions); throw new IllegalArgumentException("actions: " + actions);
} }
} }

View File

@ -228,7 +228,7 @@ public class AlgorithmParameterGenerator {
throws NoSuchAlgorithmException, NoSuchProviderException throws NoSuchAlgorithmException, NoSuchProviderException
{ {
Objects.requireNonNull(algorithm, "null algorithm name"); Objects.requireNonNull(algorithm, "null algorithm name");
if (provider == null || provider.length() == 0) if (provider == null || provider.isEmpty())
throw new IllegalArgumentException("missing provider"); throw new IllegalArgumentException("missing provider");
Object[] objs = Security.getImpl(algorithm, Object[] objs = Security.getImpl(algorithm,
"AlgorithmParameterGenerator", "AlgorithmParameterGenerator",

View File

@ -209,7 +209,7 @@ public class AlgorithmParameters {
throws NoSuchAlgorithmException, NoSuchProviderException throws NoSuchAlgorithmException, NoSuchProviderException
{ {
Objects.requireNonNull(algorithm, "null algorithm name"); Objects.requireNonNull(algorithm, "null algorithm name");
if (provider == null || provider.length() == 0) if (provider == null || provider.isEmpty())
throw new IllegalArgumentException("missing provider"); throw new IllegalArgumentException("missing provider");
Object[] objs = Security.getImpl(algorithm, "AlgorithmParameters", Object[] objs = Security.getImpl(algorithm, "AlgorithmParameters",
provider); provider);

View File

@ -913,7 +913,7 @@ public class KeyStore {
throws KeyStoreException, NoSuchProviderException throws KeyStoreException, NoSuchProviderException
{ {
Objects.requireNonNull(type, "null type name"); Objects.requireNonNull(type, "null type name");
if (provider == null || provider.length() == 0) if (provider == null || provider.isEmpty())
throw new IllegalArgumentException("missing provider"); throw new IllegalArgumentException("missing provider");
try { try {
Object[] objs = Security.getImpl(type, "KeyStore", provider); Object[] objs = Security.getImpl(type, "KeyStore", provider);

View File

@ -237,7 +237,7 @@ public abstract class MessageDigest extends MessageDigestSpi {
throws NoSuchAlgorithmException, NoSuchProviderException throws NoSuchAlgorithmException, NoSuchProviderException
{ {
Objects.requireNonNull(algorithm, "null algorithm name"); Objects.requireNonNull(algorithm, "null algorithm name");
if (provider == null || provider.length() == 0) if (provider == null || provider.isEmpty())
throw new IllegalArgumentException("missing provider"); throw new IllegalArgumentException("missing provider");
Object[] objs = Security.getImpl(algorithm, "MessageDigest", provider); Object[] objs = Security.getImpl(algorithm, "MessageDigest", provider);
if (objs[0] instanceof MessageDigest) { if (objs[0] instanceof MessageDigest) {

View File

@ -222,7 +222,7 @@ public abstract class Permission implements Guard, java.io.Serializable {
*/ */
public String toString() { public String toString() {
String actions = getActions(); String actions = getActions();
if ((actions == null) || (actions.length() == 0)) { // OPTIONAL if (actions == null || actions.isEmpty()) { // OPTIONAL
return "(\"" + getClass().getName() + "\" \"" + name + "\")"; return "(\"" + getClass().getName() + "\" \"" + name + "\")";
} else { } else {
return "(\"" + getClass().getName() + "\" \"" + name + return "(\"" + getClass().getName() + "\" \"" + name +

View File

@ -456,7 +456,7 @@ public abstract class Policy {
throws NoSuchProviderException, NoSuchAlgorithmException { throws NoSuchProviderException, NoSuchAlgorithmException {
Objects.requireNonNull(type, "null type name"); Objects.requireNonNull(type, "null type name");
if (provider == null || provider.length() == 0) { if (provider == null || provider.isEmpty()) {
throw new IllegalArgumentException("missing provider"); throw new IllegalArgumentException("missing provider");
} }

View File

@ -942,7 +942,7 @@ public class SecureRandom extends java.util.Random {
} }
}); });
if ((property == null) || (property.length() == 0)) { if (property == null || property.isEmpty()) {
throw new NoSuchAlgorithmException( throw new NoSuchAlgorithmException(
"Null/empty securerandom.strongAlgorithms Security Property"); "Null/empty securerandom.strongAlgorithms Security Property");
} }

View File

@ -649,7 +649,7 @@ public final class Security {
} }
} }
if ((candidates == null) || (candidates.isEmpty())) if (candidates == null || candidates.isEmpty())
return null; return null;
Object[] candidatesArray = candidates.toArray(); Object[] candidatesArray = candidates.toArray();
@ -1005,11 +1005,11 @@ public final class Security {
String algName = null; String algName = null;
String attrName = null; String attrName = null;
if (filterValue.length() == 0) { if (filterValue.isEmpty()) {
// The filterValue is an empty string. So the filterKey // The filterValue is an empty string. So the filterKey
// should be in the format of <crypto_service>.<algorithm_or_type>. // should be in the format of <crypto_service>.<algorithm_or_type>.
algName = filterKey.substring(algIndex + 1).trim(); algName = filterKey.substring(algIndex + 1).trim();
if (algName.length() == 0) { if (algName.isEmpty()) {
// There must be a algorithm or type name. // There must be a algorithm or type name.
throw new InvalidParameterException("Invalid filter"); throw new InvalidParameterException("Invalid filter");
} }
@ -1024,7 +1024,7 @@ public final class Security {
throw new InvalidParameterException("Invalid filter"); throw new InvalidParameterException("Invalid filter");
} else { } else {
attrName = filterKey.substring(attrIndex + 1).trim(); attrName = filterKey.substring(attrIndex + 1).trim();
if (attrName.length() == 0) { if (attrName.isEmpty()) {
// There is no attribute name in the filter. // There is no attribute name in the filter.
throw new InvalidParameterException("Invalid filter"); throw new InvalidParameterException("Invalid filter");
} }
@ -1070,7 +1070,7 @@ public final class Security {
**/ **/
public static Set<String> getAlgorithms(String serviceName) { public static Set<String> getAlgorithms(String serviceName) {
if ((serviceName == null) || (serviceName.length() == 0) || if ((serviceName == null) || (serviceName.isEmpty()) ||
(serviceName.endsWith("."))) { (serviceName.endsWith("."))) {
return Collections.emptySet(); return Collections.emptySet();
} }

View File

@ -360,7 +360,7 @@ public abstract class Signature extends SignatureSpi {
Objects.requireNonNull(algorithm, "null algorithm name"); Objects.requireNonNull(algorithm, "null algorithm name");
if (algorithm.equalsIgnoreCase(RSA_SIGNATURE)) { if (algorithm.equalsIgnoreCase(RSA_SIGNATURE)) {
// exception compatibility with existing code // exception compatibility with existing code
if ((provider == null) || (provider.length() == 0)) { if (provider == null || provider.isEmpty()) {
throw new IllegalArgumentException("missing provider"); throw new IllegalArgumentException("missing provider");
} }
Provider p = Security.getProvider(provider); Provider p = Security.getProvider(provider);

View File

@ -210,7 +210,7 @@ public class TrustAnchor {
if (caName == null) if (caName == null)
throw new NullPointerException("the caName parameter must be " + throw new NullPointerException("the caName parameter must be " +
"non-null"); "non-null");
if (caName.length() == 0) if (caName.isEmpty())
throw new IllegalArgumentException("the caName " + throw new IllegalArgumentException("the caName " +
"parameter must be a non-empty String"); "parameter must be a non-empty String");
// check if caName is formatted correctly // check if caName is formatted correctly

View File

@ -85,7 +85,7 @@ public class AttributedString {
text = buffer.toString(); text = buffer.toString();
if (text.length() > 0) { if (!text.isEmpty()) {
// Determine the runs, creating a new run when the attributes // Determine the runs, creating a new run when the attributes
// differ. // differ.
int offset = 0; int offset = 0;
@ -144,7 +144,7 @@ public class AttributedString {
} }
this.text = text; this.text = text;
if (text.length() == 0) { if (text.isEmpty()) {
if (attributes.isEmpty()) if (attributes.isEmpty())
return; return;
throw new IllegalArgumentException("Can't add attribute to 0-length text"); throw new IllegalArgumentException("Can't add attribute to 0-length text");

View File

@ -125,7 +125,7 @@ public final class CollationElementIterator
CollationElementIterator(String sourceText, RuleBasedCollator owner) { CollationElementIterator(String sourceText, RuleBasedCollator owner) {
this.owner = owner; this.owner = owner;
ordering = owner.getTables(); ordering = owner.getTables();
if ( sourceText.length() != 0 ) { if (!sourceText.isEmpty()) {
NormalizerBase.Mode mode = NormalizerBase.Mode mode =
CollatorUtilities.toNormalizerMode(owner.getDecomposition()); CollatorUtilities.toNormalizerMode(owner.getDecomposition());
text = new NormalizerBase(sourceText, mode); text = new NormalizerBase(sourceText, mode);

View File

@ -799,7 +799,7 @@ public final class CompactNumberFormat extends NumberFormat {
*/ */
private void append(StringBuffer result, String string, private void append(StringBuffer result, String string,
FieldDelegate delegate, List<FieldPosition> positions) { FieldDelegate delegate, List<FieldPosition> positions) {
if (string.length() > 0) { if (!string.isEmpty()) {
int start = result.length(); int start = result.length();
result.append(string); result.append(string);
for (int counter = 0; counter < positions.size(); counter++) { for (int counter = 0; counter < positions.size(); counter++) {
@ -1213,7 +1213,7 @@ public final class CompactNumberFormat extends NumberFormat {
} }
// If no 0s are specified in a non empty pattern, it is invalid // If no 0s are specified in a non empty pattern, it is invalid
if (pattern.length() != 0 && zeros.isEmpty()) { if (!pattern.isEmpty() && zeros.isEmpty()) {
throw new IllegalArgumentException("Invalid pattern" throw new IllegalArgumentException("Invalid pattern"
+ " [" + pattern + "]: all patterns must include digit" + " [" + pattern + "]: all patterns must include digit"
+ " placement 0s"); + " placement 0s");

View File

@ -1113,11 +1113,9 @@ public class DecimalFormat extends NumberFormat {
// Records the need for adding prefix or suffix // Records the need for adding prefix or suffix
fastPathData.positiveAffixesRequired fastPathData.positiveAffixesRequired
= (positivePrefix.length() != 0) = !positivePrefix.isEmpty() || !positiveSuffix.isEmpty();
|| (positiveSuffix.length() != 0);
fastPathData.negativeAffixesRequired fastPathData.negativeAffixesRequired
= (negativePrefix.length() != 0) = !negativePrefix.isEmpty() || !negativeSuffix.isEmpty();
|| (negativeSuffix.length() != 0);
// Creates a cached char container for result, with max possible size. // Creates a cached char container for result, with max possible size.
int maxNbIntegralDigits = 10; int maxNbIntegralDigits = 10;
@ -2062,7 +2060,7 @@ public class DecimalFormat extends NumberFormat {
Format.Field signAttribute) { Format.Field signAttribute) {
int start = result.length(); int start = result.length();
if (string.length() > 0) { if (!string.isEmpty()) {
result.append(string); result.append(string);
for (int counter = 0, max = positions.length; counter < max; for (int counter = 0, max = positions.length; counter < max;
counter++) { counter++) {
@ -3042,7 +3040,7 @@ public class DecimalFormat extends NumberFormat {
} else { } else {
string = symbols.getCurrencySymbol(); string = symbols.getCurrencySymbol();
} }
if (string.length() > 0) { if (!string.isEmpty()) {
if (positions == null) { if (positions == null) {
positions = new ArrayList<>(2); positions = new ArrayList<>(2);
} }
@ -3613,7 +3611,7 @@ public class DecimalFormat extends NumberFormat {
} }
} }
if (pattern.length() == 0) { if (pattern.isEmpty()) {
posPrefixPattern = posSuffixPattern = ""; posPrefixPattern = posSuffixPattern = "";
setMinimumIntegerDigits(0); setMinimumIntegerDigits(0);
setMaximumIntegerDigits(MAXIMUM_INTEGER_DIGITS); setMaximumIntegerDigits(MAXIMUM_INTEGER_DIGITS);

View File

@ -663,7 +663,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
// Check for empty country string separately because it's a valid // Check for empty country string separately because it's a valid
// country ID for Locale (and used for the C locale), but not a valid // country ID for Locale (and used for the C locale), but not a valid
// ISO 3166 country code, and exceptions are expensive. // ISO 3166 country code, and exceptions are expensive.
if (locale.getCountry().length() > 0) { if (!locale.getCountry().isEmpty()) {
try { try {
currency = Currency.getInstance(locale); currency = Currency.getInstance(locale);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {

View File

@ -92,7 +92,7 @@ final class MergeCollation {
int i; int i;
for (i = 0; i < patterns.size(); ++i) { for (i = 0; i < patterns.size(); ++i) {
PatternEntry entry = patterns.get(i); PatternEntry entry = patterns.get(i);
if (entry.extension.length() != 0) { if (!entry.extension.isEmpty()) {
if (extList == null) if (extList == null)
extList = new ArrayList<>(); extList = new ArrayList<>();
extList.add(entry); extList.add(entry);
@ -122,7 +122,7 @@ final class MergeCollation {
private final PatternEntry findLastWithNoExtension(int i) { private final PatternEntry findLastWithNoExtension(int i) {
for (--i;i >= 0; --i) { for (--i;i >= 0; --i) {
PatternEntry entry = patterns.get(i); PatternEntry entry = patterns.get(i);
if (entry.extension.length() == 0) { if (entry.extension.isEmpty()) {
return entry; return entry;
} }
} }

View File

@ -1330,7 +1330,7 @@ public class MessageFormat extends Format {
} }
arg = null; arg = null;
} }
if (arg != null && arg.length() > 0) { if (arg != null && !arg.isEmpty()) {
result.append(arg); result.append(arg);
characterIterators.add( characterIterators.add(
createAttributedCharacterIterator( createAttributedCharacterIterator(
@ -1476,7 +1476,7 @@ public class MessageFormat extends Format {
// now get the format // now get the format
Format newFormat = null; Format newFormat = null;
if (segments[SEG_TYPE].length() != 0) { if (!segments[SEG_TYPE].isEmpty()) {
int type = findKeyword(segments[SEG_TYPE], TYPE_KEYWORDS); int type = findKeyword(segments[SEG_TYPE], TYPE_KEYWORDS);
switch (type) { switch (type) {
case TYPE_NULL: case TYPE_NULL:

View File

@ -141,7 +141,7 @@ class PatternEntry {
if (showWhiteSpace) if (showWhiteSpace)
toAddTo.append(' '); toAddTo.append(' ');
appendQuoted(chars,toAddTo); appendQuoted(chars,toAddTo);
if (showExtension && extension.length() != 0) { if (showExtension && !extension.isEmpty()) {
toAddTo.append('/'); toAddTo.append('/');
appendQuoted(extension,toAddTo); appendQuoted(extension,toAddTo);
} }

View File

@ -75,13 +75,10 @@ final class RBTableBuilder {
* @exception ParseException If the rules format is incorrect. * @exception ParseException If the rules format is incorrect.
*/ */
public void build(String pattern, int decmp) throws ParseException public void build(String pattern, int decmp) throws ParseException {
{
boolean isSource = true;
int i = 0;
String expChars; String expChars;
String groupChars; String groupChars;
if (pattern.length() == 0) if (pattern.isEmpty())
throw new ParseException("Build rules empty.", 0); throw new ParseException("Build rules empty.", 0);
// This array maps Unicode characters to their collation ordering // This array maps Unicode characters to their collation ordering
@ -119,8 +116,7 @@ final class RBTableBuilder {
int order = 0; int order = 0;
// Now walk though each entry and add it to my own tables // Now walk though each entry and add it to my own tables
for (i = 0; i < mPattern.getCount(); ++i) for (int i = 0; i < mPattern.getCount(); ++i) {
{
PatternEntry entry = mPattern.getItemAt(i); PatternEntry entry = mPattern.getItemAt(i);
if (entry != null) { if (entry != null) {
groupChars = entry.getChars(); groupChars = entry.getChars();
@ -140,7 +136,7 @@ final class RBTableBuilder {
order = increment(entry.getStrength(), order); order = increment(entry.getStrength(), order);
expChars = entry.getExtension(); expChars = entry.getExtension();
if (expChars.length() != 0) { if (!expChars.isEmpty()) {
addExpandOrder(groupChars, expChars, order); addExpandOrder(groupChars, expChars, order);
} else if (groupChars.length() > 1) { } else if (groupChars.length() > 1) {
char ch = groupChars.charAt(0); char ch = groupChars.charAt(0);

View File

@ -372,7 +372,7 @@ public abstract class ZoneId implements Serializable {
public static ZoneId ofOffset(String prefix, ZoneOffset offset) { public static ZoneId ofOffset(String prefix, ZoneOffset offset) {
Objects.requireNonNull(prefix, "prefix"); Objects.requireNonNull(prefix, "prefix");
Objects.requireNonNull(offset, "offset"); Objects.requireNonNull(offset, "offset");
if (prefix.length() == 0) { if (prefix.isEmpty()) {
return offset; return offset;
} }

View File

@ -1439,7 +1439,7 @@ public final class DateTimeFormatterBuilder {
*/ */
public DateTimeFormatterBuilder appendLiteral(String literal) { public DateTimeFormatterBuilder appendLiteral(String literal) {
Objects.requireNonNull(literal, "literal"); Objects.requireNonNull(literal, "literal");
if (literal.length() > 0) { if (!literal.isEmpty()) {
if (literal.length() == 1) { if (literal.length() == 1) {
appendInternal(new CharLiteralPrinterParser(literal.charAt(0))); appendInternal(new CharLiteralPrinterParser(literal.charAt(0)));
} else { } else {
@ -1832,7 +1832,7 @@ public final class DateTimeFormatterBuilder {
throw new IllegalArgumentException("Pattern ends with an incomplete string literal: " + pattern); throw new IllegalArgumentException("Pattern ends with an incomplete string literal: " + pattern);
} }
String str = pattern.substring(start + 1, pos); String str = pattern.substring(start + 1, pos);
if (str.length() == 0) { if (str.isEmpty()) {
appendLiteral('\''); appendLiteral('\'');
} else { } else {
appendLiteral(str.replace("''", "'")); appendLiteral(str.replace("''", "'"));
@ -4332,7 +4332,7 @@ public final class DateTimeFormatterBuilder {
this.key = k; this.key = k;
this.value = v; this.value = v;
this.child = child; this.child = child;
if (k.length() == 0){ if (k.isEmpty()) {
c0 = 0xffff; c0 = 0xffff;
} else { } else {
c0 = key.charAt(0); c0 = key.charAt(0);

View File

@ -2232,7 +2232,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
if (strings != null) { if (strings != null) {
Map<String,Integer> names = new HashMap<>(); Map<String,Integer> names = new HashMap<>();
for (int i = 0; i < strings.length; i++) { for (int i = 0; i < strings.length; i++) {
if (strings[i].length() == 0) { if (strings[i].isEmpty()) {
continue; continue;
} }
names.put(strings[i], i); names.put(strings[i], i);

View File

@ -1396,11 +1396,11 @@ public final class Locale implements Cloneable, Serializable {
*/ */
@Override @Override
public final String toString() { public final String toString() {
boolean l = (baseLocale.getLanguage().length() != 0); boolean l = !baseLocale.getLanguage().isEmpty();
boolean s = (baseLocale.getScript().length() != 0); boolean s = !baseLocale.getScript().isEmpty();
boolean r = (baseLocale.getRegion().length() != 0); boolean r = !baseLocale.getRegion().isEmpty();
boolean v = (baseLocale.getVariant().length() != 0); boolean v = !baseLocale.getVariant().isEmpty();
boolean e = (localeExtensions != null && localeExtensions.getID().length() != 0); boolean e = localeExtensions != null && !localeExtensions.getID().isEmpty();
StringBuilder result = new StringBuilder(baseLocale.getLanguage()); StringBuilder result = new StringBuilder(baseLocale.getLanguage());
if (r || (l && (v || s || e))) { if (r || (l && (v || s || e))) {
@ -1504,18 +1504,18 @@ public final class Locale implements Cloneable, Serializable {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
String subtag = tag.getLanguage(); String subtag = tag.getLanguage();
if (subtag.length() > 0) { if (!subtag.isEmpty()) {
buf.append(LanguageTag.canonicalizeLanguage(subtag)); buf.append(LanguageTag.canonicalizeLanguage(subtag));
} }
subtag = tag.getScript(); subtag = tag.getScript();
if (subtag.length() > 0) { if (!subtag.isEmpty()) {
buf.append(LanguageTag.SEP); buf.append(LanguageTag.SEP);
buf.append(LanguageTag.canonicalizeScript(subtag)); buf.append(LanguageTag.canonicalizeScript(subtag));
} }
subtag = tag.getRegion(); subtag = tag.getRegion();
if (subtag.length() > 0) { if (!subtag.isEmpty()) {
buf.append(LanguageTag.SEP); buf.append(LanguageTag.SEP);
buf.append(LanguageTag.canonicalizeRegion(subtag)); buf.append(LanguageTag.canonicalizeRegion(subtag));
} }
@ -1534,7 +1534,7 @@ public final class Locale implements Cloneable, Serializable {
} }
subtag = tag.getPrivateuse(); subtag = tag.getPrivateuse();
if (subtag.length() > 0) { if (!subtag.isEmpty()) {
if (buf.length() > 0) { if (buf.length() > 0) {
buf.append(LanguageTag.SEP); buf.append(LanguageTag.SEP);
} }
@ -1684,7 +1684,7 @@ public final class Locale implements Cloneable, Serializable {
bldr.setLanguageTag(tag); bldr.setLanguageTag(tag);
BaseLocale base = bldr.getBaseLocale(); BaseLocale base = bldr.getBaseLocale();
LocaleExtensions exts = bldr.getLocaleExtensions(); LocaleExtensions exts = bldr.getLocaleExtensions();
if (exts == null && base.getVariant().length() > 0) { if (exts == null && !base.getVariant().isEmpty()) {
exts = getCompatibilityExtensions(base.getLanguage(), base.getScript(), exts = getCompatibilityExtensions(base.getLanguage(), base.getScript(),
base.getRegion(), base.getVariant()); base.getRegion(), base.getVariant());
} }
@ -1917,7 +1917,7 @@ public final class Locale implements Cloneable, Serializable {
* @exception NullPointerException if <code>inLocale</code> is <code>null</code> * @exception NullPointerException if <code>inLocale</code> is <code>null</code>
*/ */
public String getDisplayVariant(Locale inLocale) { public String getDisplayVariant(Locale inLocale) {
if (baseLocale.getVariant().length() == 0) if (baseLocale.getVariant().isEmpty())
return ""; return "";
LocaleResources lr = LocaleProviderAdapter LocaleResources lr = LocaleProviderAdapter
@ -1998,14 +1998,14 @@ public final class Locale implements Cloneable, Serializable {
// The display name consists of a main name, followed by qualifiers. // The display name consists of a main name, followed by qualifiers.
// Typically, the format is "MainName (Qualifier, Qualifier)" but this // Typically, the format is "MainName (Qualifier, Qualifier)" but this
// depends on what pattern is stored in the display locale. // depends on what pattern is stored in the display locale.
String mainName = null; String mainName;
String[] qualifierNames = null; String[] qualifierNames;
// The main name is the language, or if there is no language, the script, // The main name is the language, or if there is no language, the script,
// then if no script, the country. If there is no language/script/country // then if no script, the country. If there is no language/script/country
// (an anomalous situation) then the display name is simply the variant's // (an anomalous situation) then the display name is simply the variant's
// display name. // display name.
if (languageName.length() == 0 && scriptName.length() == 0 && countryName.length() == 0) { if (languageName.isEmpty() && scriptName.isEmpty() && countryName.isEmpty()) {
if (variantNames.length == 0) { if (variantNames.length == 0) {
return ""; return "";
} else { } else {
@ -2013,13 +2013,13 @@ public final class Locale implements Cloneable, Serializable {
} }
} }
ArrayList<String> names = new ArrayList<>(4); ArrayList<String> names = new ArrayList<>(4);
if (languageName.length() != 0) { if (!languageName.isEmpty()) {
names.add(languageName); names.add(languageName);
} }
if (scriptName.length() != 0) { if (!scriptName.isEmpty()) {
names.add(scriptName); names.add(scriptName);
} }
if (countryName.length() != 0) { if (!countryName.isEmpty()) {
names.add(countryName); names.add(countryName);
} }
if (variantNames.length != 0) { if (variantNames.length != 0) {
@ -2309,7 +2309,7 @@ public final class Locale implements Cloneable, Serializable {
String variant = (String)fields.get("variant", ""); String variant = (String)fields.get("variant", "");
String extStr = (String)fields.get("extensions", ""); String extStr = (String)fields.get("extensions", "");
baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), script, country, variant); baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), script, country, variant);
if (extStr.length() > 0) { if (!extStr.isEmpty()) {
try { try {
InternalLocaleBuilder bldr = new InternalLocaleBuilder(); InternalLocaleBuilder bldr = new InternalLocaleBuilder();
bldr.setExtensions(extStr); bldr.setExtensions(extStr);
@ -2367,13 +2367,13 @@ public final class Locale implements Cloneable, Serializable {
LocaleExtensions extensions = null; LocaleExtensions extensions = null;
// Special cases for backward compatibility support // Special cases for backward compatibility support
if (LocaleUtils.caseIgnoreMatch(language, "ja") if (LocaleUtils.caseIgnoreMatch(language, "ja")
&& script.length() == 0 && script.isEmpty()
&& LocaleUtils.caseIgnoreMatch(country, "jp") && LocaleUtils.caseIgnoreMatch(country, "jp")
&& "JP".equals(variant)) { && "JP".equals(variant)) {
// ja_JP_JP -> u-ca-japanese (calendar = japanese) // ja_JP_JP -> u-ca-japanese (calendar = japanese)
extensions = LocaleExtensions.CALENDAR_JAPANESE; extensions = LocaleExtensions.CALENDAR_JAPANESE;
} else if (LocaleUtils.caseIgnoreMatch(language, "th") } else if (LocaleUtils.caseIgnoreMatch(language, "th")
&& script.length() == 0 && script.isEmpty()
&& LocaleUtils.caseIgnoreMatch(country, "th") && LocaleUtils.caseIgnoreMatch(country, "th")
&& "TH".equals(variant)) { && "TH".equals(variant)) {
// th_TH_TH -> u-nu-thai (numbersystem = thai) // th_TH_TH -> u-nu-thai (numbersystem = thai)
@ -2806,7 +2806,7 @@ public final class Locale implements Cloneable, Serializable {
public Locale build() { public Locale build() {
BaseLocale baseloc = localeBuilder.getBaseLocale(); BaseLocale baseloc = localeBuilder.getBaseLocale();
LocaleExtensions extensions = localeBuilder.getLocaleExtensions(); LocaleExtensions extensions = localeBuilder.getLocaleExtensions();
if (extensions == null && baseloc.getVariant().length() > 0) { if (extensions == null && !baseloc.getVariant().isEmpty()) {
extensions = getCompatibilityExtensions(baseloc.getLanguage(), baseloc.getScript(), extensions = getCompatibilityExtensions(baseloc.getLanguage(), baseloc.getScript(),
baseloc.getRegion(), baseloc.getVariant()); baseloc.getRegion(), baseloc.getVariant());
} }

View File

@ -771,8 +771,8 @@ public abstract class ResourceBundle {
@Override @Override
public String toString() { public String toString() {
String l = locale.toString(); String l = locale.toString();
if (l.length() == 0) { if (l.isEmpty()) {
if (locale.getVariant().length() != 0) { if (!locale.getVariant().isEmpty()) {
l = "__" + locale.getVariant(); l = "__" + locale.getVariant();
} else { } else {
l = "\"\""; l = "\"\"";
@ -2903,7 +2903,7 @@ public abstract class ResourceBundle {
List<Locale> bokmalList = new LinkedList<>(); List<Locale> bokmalList = new LinkedList<>();
for (Locale l : tmpList) { for (Locale l : tmpList) {
bokmalList.add(l); bokmalList.add(l);
if (l.getLanguage().length() == 0) { if (l.getLanguage().isEmpty()) {
break; break;
} }
bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(), bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
@ -2921,7 +2921,7 @@ public abstract class ResourceBundle {
} }
// Special handling for Chinese // Special handling for Chinese
else if (language.equals("zh")) { else if (language.equals("zh")) {
if (script.length() == 0 && region.length() > 0) { if (script.isEmpty() && !region.isEmpty()) {
// Supply script for users who want to use zh_Hans/zh_Hant // Supply script for users who want to use zh_Hans/zh_Hant
// as bundle names (recommended for Java7+) // as bundle names (recommended for Java7+)
switch (region) { switch (region) {
@ -2944,7 +2944,7 @@ public abstract class ResourceBundle {
private static List<Locale> getDefaultList(String language, String script, String region, String variant) { private static List<Locale> getDefaultList(String language, String script, String region, String variant) {
List<String> variants = null; List<String> variants = null;
if (variant.length() > 0) { if (!variant.isEmpty()) {
variants = new LinkedList<>(); variants = new LinkedList<>();
int idx = variant.length(); int idx = variant.length();
while (idx != -1) { while (idx != -1) {
@ -2960,14 +2960,14 @@ public abstract class ResourceBundle {
list.add(Locale.getInstance(language, script, region, v, null)); list.add(Locale.getInstance(language, script, region, v, null));
} }
} }
if (region.length() > 0) { if (!region.isEmpty()) {
list.add(Locale.getInstance(language, script, region, "", null)); list.add(Locale.getInstance(language, script, region, "", null));
} }
if (script.length() > 0) { if (!script.isEmpty()) {
list.add(Locale.getInstance(language, script, "", "", null)); list.add(Locale.getInstance(language, script, "", "", null));
// Special handling for Chinese // Special handling for Chinese
if (language.equals("zh")) { if (language.equals("zh")) {
if (region.length() == 0) { if (region.isEmpty()) {
// Supply region(country) for users who still package Chinese // Supply region(country) for users who still package Chinese
// bundles using old convension. // bundles using old convension.
switch (script) { switch (script) {
@ -2988,11 +2988,11 @@ public abstract class ResourceBundle {
list.add(Locale.getInstance(language, "", region, v, null)); list.add(Locale.getInstance(language, "", region, v, null));
} }
} }
if (region.length() > 0) { if (!region.isEmpty()) {
list.add(Locale.getInstance(language, "", region, "", null)); list.add(Locale.getInstance(language, "", region, "", null));
} }
} }
if (language.length() > 0) { if (!language.isEmpty()) {
list.add(Locale.getInstance(language, "", "", "", null)); list.add(Locale.getInstance(language, "", "", "", null));
} }
// Add root locale at the end // Add root locale at the end

View File

@ -1297,16 +1297,16 @@ public final class Scanner implements Iterator<String>, Closeable {
nanString = "\\Q" + dfs.getNaN() + "\\E"; nanString = "\\Q" + dfs.getNaN() + "\\E";
infinityString = "\\Q" + dfs.getInfinity() + "\\E"; infinityString = "\\Q" + dfs.getInfinity() + "\\E";
positivePrefix = df.getPositivePrefix(); positivePrefix = df.getPositivePrefix();
if (positivePrefix.length() > 0) if (!positivePrefix.isEmpty())
positivePrefix = "\\Q" + positivePrefix + "\\E"; positivePrefix = "\\Q" + positivePrefix + "\\E";
negativePrefix = df.getNegativePrefix(); negativePrefix = df.getNegativePrefix();
if (negativePrefix.length() > 0) if (!negativePrefix.isEmpty())
negativePrefix = "\\Q" + negativePrefix + "\\E"; negativePrefix = "\\Q" + negativePrefix + "\\E";
positiveSuffix = df.getPositiveSuffix(); positiveSuffix = df.getPositiveSuffix();
if (positiveSuffix.length() > 0) if (!positiveSuffix.isEmpty())
positiveSuffix = "\\Q" + positiveSuffix + "\\E"; positiveSuffix = "\\Q" + positiveSuffix + "\\E";
negativeSuffix = df.getNegativeSuffix(); negativeSuffix = df.getNegativeSuffix();
if (negativeSuffix.length() > 0) if (!negativeSuffix.isEmpty())
negativeSuffix = "\\Q" + negativeSuffix + "\\E"; negativeSuffix = "\\Q" + negativeSuffix + "\\E";
// Force rebuilding and recompilation of locale dependent // Force rebuilding and recompilation of locale dependent

View File

@ -1390,7 +1390,7 @@ public final class Pattern
localTCNCount = 0; localTCNCount = 0;
// if length > 0, the Pattern is lazily compiled // if length > 0, the Pattern is lazily compiled
if (pattern.length() == 0) { if (pattern.isEmpty()) {
root = new Start(lastAccept); root = new Start(lastAccept);
matchRoot = lastAccept; matchRoot = lastAccept;
compiled = true; compiled = true;
@ -1423,7 +1423,7 @@ public final class Pattern
localCount = 0; localCount = 0;
localTCNCount = 0; localTCNCount = 0;
if (pattern.length() > 0) { if (!pattern.isEmpty()) {
compile(); compile();
} else { } else {
root = new Start(lastAccept); root = new Start(lastAccept);

View File

@ -341,7 +341,7 @@ public class Cipher {
throw new NoSuchAlgorithmException("Invalid transformation " + throw new NoSuchAlgorithmException("Invalid transformation " +
"format:" + transformation); "format:" + transformation);
} }
if ((parts[0] == null) || (parts[0].length() == 0)) { if ((parts[0] == null) || (parts[0].isEmpty())) {
throw new NoSuchAlgorithmException("Invalid transformation:" + throw new NoSuchAlgorithmException("Invalid transformation:" +
"algorithm not specified-" "algorithm not specified-"
+ transformation); + transformation);
@ -445,10 +445,10 @@ public class Cipher {
String alg = parts[0]; String alg = parts[0];
String mode = parts[1]; String mode = parts[1];
String pad = parts[2]; String pad = parts[2];
if ((mode != null) && (mode.length() == 0)) { if ((mode != null) && (mode.isEmpty())) {
mode = null; mode = null;
} }
if ((pad != null) && (pad.length() == 0)) { if ((pad != null) && (pad.isEmpty())) {
pad = null; pad = null;
} }
@ -634,7 +634,7 @@ public class Cipher {
if ((transformation == null) || transformation.isEmpty()) { if ((transformation == null) || transformation.isEmpty()) {
throw new NoSuchAlgorithmException("Null or empty transformation"); throw new NoSuchAlgorithmException("Null or empty transformation");
} }
if ((provider == null) || (provider.length() == 0)) { if ((provider == null) || (provider.isEmpty())) {
throw new IllegalArgumentException("Missing provider"); throw new IllegalArgumentException("Missing provider");
} }
Provider p = Security.getProvider(provider); Provider p = Security.getProvider(provider);

View File

@ -337,7 +337,7 @@ public class SealedObject implements Serializable {
if (key == null) { if (key == null) {
throw new NullPointerException("key is null"); throw new NullPointerException("key is null");
} }
if (provider == null || provider.length() == 0) { if (provider == null || provider.isEmpty()) {
throw new IllegalArgumentException("missing provider"); throw new IllegalArgumentException("missing provider");
} }

View File

@ -133,7 +133,7 @@ public abstract class SSLSocketFactory extends SocketFactory
String s = java.security.Security.getProperty(name); String s = java.security.Security.getProperty(name);
if (s != null) { if (s != null) {
s = s.trim(); s = s.trim();
if (s.length() == 0) { if (s.isEmpty()) {
s = null; s = null;
} }
} }

View File

@ -312,7 +312,7 @@ public final class PrivateCredentialPermission extends Permission {
private void init(String name) { private void init(String name) {
if (name == null || name.trim().length() == 0) { if (name == null || name.trim().isEmpty()) {
throw new IllegalArgumentException("invalid empty name"); throw new IllegalArgumentException("invalid empty name");
} }

View File

@ -98,13 +98,13 @@ public class ChoiceCallback implements Callback, java.io.Serializable {
public ChoiceCallback(String prompt, String[] choices, public ChoiceCallback(String prompt, String[] choices,
int defaultChoice, boolean multipleSelectionsAllowed) { int defaultChoice, boolean multipleSelectionsAllowed) {
if (prompt == null || prompt.length() == 0 || if (prompt == null || prompt.isEmpty() ||
choices == null || choices.length == 0 || choices == null || choices.length == 0 ||
defaultChoice < 0 || defaultChoice >= choices.length) defaultChoice < 0 || defaultChoice >= choices.length)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
for (int i = 0; i < choices.length; i++) { for (int i = 0; i < choices.length; i++) {
if (choices[i] == null || choices[i].length() == 0) if (choices[i] == null || choices[i].isEmpty())
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }

View File

@ -248,7 +248,7 @@ public class ConfirmationCallback implements Callback, java.io.Serializable {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
for (int i = 0; i < options.length; i++) { for (int i = 0; i < options.length; i++) {
if (options[i] == null || options[i].length() == 0) if (options[i] == null || options[i].isEmpty())
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }
@ -294,7 +294,7 @@ public class ConfirmationCallback implements Callback, java.io.Serializable {
public ConfirmationCallback(String prompt, int messageType, public ConfirmationCallback(String prompt, int messageType,
int optionType, int defaultOption) { int optionType, int defaultOption) {
if (prompt == null || prompt.length() == 0 || if (prompt == null || prompt.isEmpty() ||
messageType < INFORMATION || messageType > ERROR || messageType < INFORMATION || messageType > ERROR ||
optionType < YES_NO_OPTION || optionType > OK_CANCEL_OPTION) optionType < YES_NO_OPTION || optionType > OK_CANCEL_OPTION)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
@ -357,14 +357,14 @@ public class ConfirmationCallback implements Callback, java.io.Serializable {
public ConfirmationCallback(String prompt, int messageType, public ConfirmationCallback(String prompt, int messageType,
String[] options, int defaultOption) { String[] options, int defaultOption) {
if (prompt == null || prompt.length() == 0 || if (prompt == null || prompt.isEmpty() ||
messageType < INFORMATION || messageType > ERROR || messageType < INFORMATION || messageType > ERROR ||
options == null || options.length == 0 || options == null || options.length == 0 ||
defaultOption < 0 || defaultOption >= options.length) defaultOption < 0 || defaultOption >= options.length)
throw new IllegalArgumentException(); throw new IllegalArgumentException();
for (int i = 0; i < options.length; i++) { for (int i = 0; i < options.length; i++) {
if (options[i] == null || options[i].length() == 0) if (options[i] == null || options[i].isEmpty())
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }

View File

@ -62,7 +62,7 @@ public class NameCallback implements Callback, java.io.Serializable {
* or if {@code prompt} has a length of 0. * or if {@code prompt} has a length of 0.
*/ */
public NameCallback(String prompt) { public NameCallback(String prompt) {
if (prompt == null || prompt.length() == 0) if (prompt == null || prompt.isEmpty())
throw new IllegalArgumentException(); throw new IllegalArgumentException();
this.prompt = prompt; this.prompt = prompt;
} }
@ -82,8 +82,8 @@ public class NameCallback implements Callback, java.io.Serializable {
* or if {@code defaultName} has a length of 0. * or if {@code defaultName} has a length of 0.
*/ */
public NameCallback(String prompt, String defaultName) { public NameCallback(String prompt, String defaultName) {
if (prompt == null || prompt.length() == 0 || if (prompt == null || prompt.isEmpty() ||
defaultName == null || defaultName.length() == 0) defaultName == null || defaultName.isEmpty())
throw new IllegalArgumentException(); throw new IllegalArgumentException();
this.prompt = prompt; this.prompt = prompt;

View File

@ -67,7 +67,7 @@ public class PasswordCallback implements Callback, java.io.Serializable {
* if {@code prompt} has a length of 0. * if {@code prompt} has a length of 0.
*/ */
public PasswordCallback(String prompt, boolean echoOn) { public PasswordCallback(String prompt, boolean echoOn) {
if (prompt == null || prompt.length() == 0) if (prompt == null || prompt.isEmpty())
throw new IllegalArgumentException(); throw new IllegalArgumentException();
this.prompt = prompt; this.prompt = prompt;

View File

@ -63,7 +63,7 @@ public class TextInputCallback implements Callback, java.io.Serializable {
* or if {@code prompt} has a length of 0. * or if {@code prompt} has a length of 0.
*/ */
public TextInputCallback(String prompt) { public TextInputCallback(String prompt) {
if (prompt == null || prompt.length() == 0) if (prompt == null || prompt.isEmpty())
throw new IllegalArgumentException(); throw new IllegalArgumentException();
this.prompt = prompt; this.prompt = prompt;
} }
@ -83,8 +83,8 @@ public class TextInputCallback implements Callback, java.io.Serializable {
* or if {@code defaultText} has a length of 0. * or if {@code defaultText} has a length of 0.
*/ */
public TextInputCallback(String prompt, String defaultText) { public TextInputCallback(String prompt, String defaultText) {
if (prompt == null || prompt.length() == 0 || if (prompt == null || prompt.isEmpty() ||
defaultText == null || defaultText.length() == 0) defaultText == null || defaultText.isEmpty())
throw new IllegalArgumentException(); throw new IllegalArgumentException();
this.prompt = prompt; this.prompt = prompt;

View File

@ -74,7 +74,7 @@ public class TextOutputCallback implements Callback, java.io.Serializable {
public TextOutputCallback(int messageType, String message) { public TextOutputCallback(int messageType, String message) {
if ((messageType != INFORMATION && if ((messageType != INFORMATION &&
messageType != WARNING && messageType != ERROR) || messageType != WARNING && messageType != ERROR) ||
message == null || message.length() == 0) message == null || message.isEmpty())
throw new IllegalArgumentException(); throw new IllegalArgumentException();
this.messageType = messageType; this.messageType = messageType;

View File

@ -75,7 +75,7 @@ public class AppConfigurationEntry {
LoginModuleControlFlag controlFlag, LoginModuleControlFlag controlFlag,
Map<String,?> options) Map<String,?> options)
{ {
if (loginModuleName == null || loginModuleName.length() == 0 || if (loginModuleName == null || loginModuleName.isEmpty() ||
(controlFlag != LoginModuleControlFlag.REQUIRED && (controlFlag != LoginModuleControlFlag.REQUIRED &&
controlFlag != LoginModuleControlFlag.REQUISITE && controlFlag != LoginModuleControlFlag.REQUISITE &&
controlFlag != LoginModuleControlFlag.SUFFICIENT && controlFlag != LoginModuleControlFlag.SUFFICIENT &&

View File

@ -418,7 +418,7 @@ public abstract class Configuration {
throws NoSuchProviderException, NoSuchAlgorithmException { throws NoSuchProviderException, NoSuchAlgorithmException {
Objects.requireNonNull(type, "null type name"); Objects.requireNonNull(type, "null type name");
if (provider == null || provider.length() == 0) { if (provider == null || provider.isEmpty()) {
throw new IllegalArgumentException("missing provider"); throw new IllegalArgumentException("missing provider");
} }

View File

@ -300,7 +300,7 @@ public class LoginContext {
public CallbackHandler run() throws Exception { public CallbackHandler run() throws Exception {
String defaultHandler = java.security.Security.getProperty String defaultHandler = java.security.Security.getProperty
(DEFAULT_HANDLER); (DEFAULT_HANDLER);
if (defaultHandler == null || defaultHandler.length() == 0) if (defaultHandler == null || defaultHandler.isEmpty())
return null; return null;
Class<? extends CallbackHandler> c = Class.forName( Class<? extends CallbackHandler> c = Class.forName(
defaultHandler, true, defaultHandler, true,

View File

@ -210,7 +210,7 @@ public abstract class X509Certificate extends Certificate {
* under JDK1.1. * under JDK1.1.
*/ */
String className = X509Provider; String className = X509Provider;
if (className == null || className.length() == 0) { if (className == null || className.isEmpty()) {
// shouldn't happen, but assume corrupted properties file // shouldn't happen, but assume corrupted properties file
// provide access to sun implementation // provide access to sun implementation
className = "com.sun.security.cert.internal.x509.X509V1CertImpl"; className = "com.sun.security.cert.internal.x509.X509V1CertImpl";

View File

@ -60,7 +60,7 @@ public class SignatureParser {
switch (c) { switch (c) {
case 'L': { case 'L': {
String pkg = arguments.get(arg_index); String pkg = arguments.get(arg_index);
if(pkg.length() > 0) { if(!pkg.isEmpty()) {
out.append(pkg).append("/"); out.append(pkg).append("/");
} }
arg_index+=1; arg_index+=1;

View File

@ -168,7 +168,7 @@ public class StringSharingDecompressor implements ResourceDecompressor {
int index = indices.get(argIndex); int index = indices.get(argIndex);
argIndex += 1; argIndex += 1;
String pkg = reader.getString(index); String pkg = reader.getString(index);
if (pkg.length() > 0) { if (!pkg.isEmpty()) {
pkg = pkg + "/"; pkg = pkg + "/";
byte[] encoded = getEncoded(pkg); byte[] encoded = getEncoded(pkg);
buffer = safeAdd(buffer, encoded); buffer = safeAdd(buffer, encoded);

View File

@ -123,7 +123,7 @@ class JrtFileSystem extends FileSystem {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append(first); sb.append(first);
for (String path : more) { for (String path : more) {
if (path.length() > 0) { if (!path.isEmpty()) {
if (sb.length() > 0) { if (sb.length() > 0) {
sb.append('/'); sb.append('/');
} }

View File

@ -88,7 +88,7 @@ final class JrtPath implements Path {
@Override @Override
public final JrtPath getFileName() { public final JrtPath getFileName() {
if (path.length() == 0) if (path.isEmpty())
return this; return this;
if (path.length() == 1 && path.charAt(0) == '/') if (path.length() == 1 && path.charAt(0) == '/')
return null; return null;
@ -210,7 +210,7 @@ final class JrtPath implements Path {
if (o.equals(this)) { if (o.equals(this)) {
return new JrtPath(jrtfs, "", true); return new JrtPath(jrtfs, "", true);
} }
if (path.length() == 0) { if (path.isEmpty()) {
return o; return o;
} }
if (jrtfs != o.jrtfs || isAbsolute() != o.isAbsolute()) { if (jrtfs != o.jrtfs || isAbsolute() != o.isAbsolute()) {
@ -262,16 +262,16 @@ final class JrtPath implements Path {
@Override @Override
public final boolean isAbsolute() { public final boolean isAbsolute() {
return path.length() > 0 && path.charAt(0) == '/'; return !path.isEmpty() && path.charAt(0) == '/';
} }
@Override @Override
public final JrtPath resolve(Path other) { public final JrtPath resolve(Path other) {
final JrtPath o = checkPath(other); final JrtPath o = checkPath(other);
if (this.path.length() == 0 || o.isAbsolute()) { if (this.path.isEmpty() || o.isAbsolute()) {
return o; return o;
} }
if (o.path.length() == 0) { if (o.path.isEmpty()) {
return this; return this;
} }
StringBuilder sb = new StringBuilder(path.length() + o.path.length() + 1); StringBuilder sb = new StringBuilder(path.length() + o.path.length() + 1);
@ -301,7 +301,7 @@ final class JrtPath implements Path {
} }
int off = op.length(); int off = op.length();
if (off == 0) { if (off == 0) {
return tp.length() == 0; return tp.isEmpty();
} }
// check match is on name boundary // check match is on name boundary
return tp.length() == off || tp.charAt(off) == '/' || return tp.length() == off || tp.charAt(off) == '/' ||

View File

@ -59,7 +59,7 @@ public class ClassLoaders {
// -Xbootclasspath/a or -javaagent with Boot-Class-Path attribute // -Xbootclasspath/a or -javaagent with Boot-Class-Path attribute
String append = VM.getSavedProperty("jdk.boot.class.path.append"); String append = VM.getSavedProperty("jdk.boot.class.path.append");
BOOT_LOADER = BOOT_LOADER =
new BootClassLoader((append != null && append.length() > 0) new BootClassLoader((append != null && !append.isEmpty())
? new URLClassPath(append, true) ? new URLClassPath(append, true)
: null); : null);
PLATFORM_LOADER = new PlatformClassLoader(BOOT_LOADER); PLATFORM_LOADER = new PlatformClassLoader(BOOT_LOADER);
@ -70,7 +70,7 @@ public class ClassLoaders {
// contrary, we drop this historic interpretation of the empty // contrary, we drop this historic interpretation of the empty
// string and instead treat it as unspecified. // string and instead treat it as unspecified.
String cp = System.getProperty("java.class.path"); String cp = System.getProperty("java.class.path");
if (cp == null || cp.length() == 0) { if (cp == null || cp.isEmpty()) {
String initialModuleName = System.getProperty("jdk.module.main"); String initialModuleName = System.getProperty("jdk.module.main");
cp = (initialModuleName == null) ? "" : null; cp = (initialModuleName == null) ? "" : null;
} }

View File

@ -190,7 +190,7 @@ public class URLClassPath {
String element = (next == -1) String element = (next == -1)
? cp.substring(off) ? cp.substring(off)
: cp.substring(off, next); : cp.substring(off, next);
if (element.length() > 0 || !skipEmptyElements) { if (!element.isEmpty() || !skipEmptyElements) {
URL url = toFileURL(element); URL url = toFileURL(element);
if (url != null) path.add(url); if (url != null) path.add(url);
} }

View File

@ -62,22 +62,6 @@ public final class Checks {
return name; return name;
} }
/**
* Returns {@code true} if the given name is a legal module name.
*/
public static boolean isModuleName(String name) {
int next;
int off = 0;
while ((next = name.indexOf('.', off)) != -1) {
String id = name.substring(off, next);
if (!isJavaIdentifier(id))
return false;
off = next+1;
}
String last = name.substring(off);
return isJavaIdentifier(last);
}
/** /**
* Checks a name to ensure that it's a legal package name. * Checks a name to ensure that it's a legal package name.
* *
@ -181,20 +165,20 @@ public final class Checks {
} }
/** /**
* Returns true if the given char sequence is a legal Java identifier, * Returns true if the given string is a legal Java identifier,
* otherwise false. * otherwise false.
*/ */
private static boolean isJavaIdentifier(CharSequence cs) { private static boolean isJavaIdentifier(String str) {
if (cs.length() == 0 || RESERVED.contains(cs)) if (str.isEmpty() || RESERVED.contains(str))
return false; return false;
int first = Character.codePointAt(cs, 0); int first = Character.codePointAt(str, 0);
if (!Character.isJavaIdentifierStart(first)) if (!Character.isJavaIdentifierStart(first))
return false; return false;
int i = Character.charCount(first); int i = Character.charCount(first);
while (i < cs.length()) { while (i < str.length()) {
int cp = Character.codePointAt(cs, i); int cp = Character.codePointAt(str, i);
if (!Character.isJavaIdentifierPart(cp)) if (!Character.isJavaIdentifierPart(cp))
return false; return false;
i += Character.charCount(cp); i += Character.charCount(cp);

View File

@ -604,7 +604,8 @@ public final class ModuleBootstrap {
Set<String> modules = new HashSet<>(); Set<String> modules = new HashSet<>();
while (value != null) { while (value != null) {
for (String s : value.split(",")) { for (String s : value.split(",")) {
if (s.length() > 0) modules.add(s); if (!s.isEmpty())
modules.add(s);
} }
index++; index++;
value = getAndRemoveProperty(prefix + index); value = getAndRemoveProperty(prefix + index);
@ -895,7 +896,7 @@ public final class ModuleBootstrap {
List<String> values = map.computeIfAbsent(key, k -> new ArrayList<>()); List<String> values = map.computeIfAbsent(key, k -> new ArrayList<>());
int ntargets = 0; int ntargets = 0;
for (String s : rhs.split(regex)) { for (String s : rhs.split(regex)) {
if (s.length() > 0) { if (!s.isEmpty()) {
values.add(s); values.add(s);
ntargets++; ntargets++;
} }

View File

@ -552,7 +552,7 @@ public final class ModulePatcher {
public Stream<String> list() throws IOException { public Stream<String> list() throws IOException {
return Files.walk(dir, Integer.MAX_VALUE) return Files.walk(dir, Integer.MAX_VALUE)
.map(f -> Resources.toResourceName(dir, f)) .map(f -> Resources.toResourceName(dir, f))
.filter(s -> s.length() > 0); .filter(s -> !s.isEmpty());
} }
} }

View File

@ -546,7 +546,7 @@ public class ModulePath implements ModuleFinder {
= new BufferedReader(new InputStreamReader(in, "UTF-8")); = new BufferedReader(new InputStreamReader(in, "UTF-8"));
String cn; String cn;
while ((cn = nextLine(reader)) != null) { while ((cn = nextLine(reader)) != null) {
if (cn.length() > 0) { if (!cn.isEmpty()) {
String pn = packageName(cn); String pn = packageName(cn);
if (!packages.contains(pn)) { if (!packages.contains(pn)) {
String msg = "Provider class " + cn + " not in module"; String msg = "Provider class " + cn + " not in module";
@ -599,7 +599,7 @@ public class ModulePath implements ModuleFinder {
mn = Patterns.REPEATING_DOTS.matcher(mn).replaceAll("."); mn = Patterns.REPEATING_DOTS.matcher(mn).replaceAll(".");
// drop leading dots // drop leading dots
if (mn.length() > 0 && mn.charAt(0) == '.') if (!mn.isEmpty() && mn.charAt(0) == '.')
mn = Patterns.LEADING_DOTS.matcher(mn).replaceAll(""); mn = Patterns.LEADING_DOTS.matcher(mn).replaceAll("");
// drop trailing dots // drop trailing dots

View File

@ -78,7 +78,7 @@ public final class Resources {
String s = dir.relativize(file) String s = dir.relativize(file)
.toString() .toString()
.replace(File.separatorChar, '/'); .replace(File.separatorChar, '/');
if (s.length() > 0 && Files.isDirectory(file)) if (!s.isEmpty() && Files.isDirectory(file))
s += "/"; s += "/";
return s; return s;
} }

View File

@ -83,7 +83,7 @@ public final class SystemModuleFinders {
if (value == null) { if (value == null) {
USE_FAST_PATH = true; USE_FAST_PATH = true;
} else { } else {
USE_FAST_PATH = (value.length() > 0) && !Boolean.parseBoolean(value); USE_FAST_PATH = !value.isEmpty() && !Boolean.parseBoolean(value);
} }
} }

View File

@ -147,7 +147,7 @@ public final class TypePath {
* @return the corresponding TypePath object, or {@literal null} if the path is empty. * @return the corresponding TypePath object, or {@literal null} if the path is empty.
*/ */
public static TypePath fromString(final String typePath) { public static TypePath fromString(final String typePath) {
if (typePath == null || typePath.length() == 0) { if (typePath == null || typePath.isEmpty()) {
return null; return null;
} }
int typePathLength = typePath.length(); int typePathLength = typePath.length();

View File

@ -1314,7 +1314,7 @@ public class CheckMethodAdapter extends MethodVisitor {
* @param message the message to use in case of error. * @param message the message to use in case of error.
*/ */
static void checkMethodIdentifier(final int version, final String name, final String message) { static void checkMethodIdentifier(final int version, final String name, final String message) {
if (name == null || name.length() == 0) { if (name == null || name.isEmpty()) {
throw new IllegalArgumentException(INVALID + message + MUST_NOT_BE_NULL_OR_EMPTY); throw new IllegalArgumentException(INVALID + message + MUST_NOT_BE_NULL_OR_EMPTY);
} }
if ((version & 0xFFFF) >= Opcodes.V1_5) { if ((version & 0xFFFF) >= Opcodes.V1_5) {
@ -1347,7 +1347,7 @@ public class CheckMethodAdapter extends MethodVisitor {
* @param message the message to use in case of error. * @param message the message to use in case of error.
*/ */
static void checkInternalName(final int version, final String name, final String message) { static void checkInternalName(final int version, final String name, final String message) {
if (name == null || name.length() == 0) { if (name == null || name.isEmpty()) {
throw new IllegalArgumentException(INVALID + message + MUST_NOT_BE_NULL_OR_EMPTY); throw new IllegalArgumentException(INVALID + message + MUST_NOT_BE_NULL_OR_EMPTY);
} }
if (name.charAt(0) == '[') { if (name.charAt(0) == '[') {
@ -1457,7 +1457,7 @@ public class CheckMethodAdapter extends MethodVisitor {
* @param descriptor the string to be checked. * @param descriptor the string to be checked.
*/ */
static void checkMethodDescriptor(final int version, final String descriptor) { static void checkMethodDescriptor(final int version, final String descriptor) {
if (descriptor == null || descriptor.length() == 0) { if (descriptor == null || descriptor.isEmpty()) {
throw new IllegalArgumentException("Invalid method descriptor (must not be null or empty)"); throw new IllegalArgumentException("Invalid method descriptor (must not be null or empty)");
} }
if (descriptor.charAt(0) != '(' || descriptor.length() < 3) { if (descriptor.charAt(0) != '(' || descriptor.length() < 3) {

View File

@ -365,7 +365,7 @@ public class CheckSignatureAdapter extends SignatureVisitor {
} }
private void checkClassName(final String name, final String message) { private void checkClassName(final String name, final String message) {
if (name == null || name.length() == 0) { if (name == null || name.isEmpty()) {
throw new IllegalArgumentException(INVALID + message + " (must not be null or empty)"); throw new IllegalArgumentException(INVALID + message + " (must not be null or empty)");
} }
for (int i = 0; i < name.length(); ++i) { for (int i = 0; i < name.length(); ++i) {
@ -377,7 +377,7 @@ public class CheckSignatureAdapter extends SignatureVisitor {
} }
private void checkIdentifier(final String name, final String message) { private void checkIdentifier(final String name, final String message) {
if (name == null || name.length() == 0) { if (name == null || name.isEmpty()) {
throw new IllegalArgumentException(INVALID + message + " (must not be null or empty)"); throw new IllegalArgumentException(INVALID + message + " (must not be null or empty)");
} }
for (int i = 0; i < name.length(); ++i) { for (int i = 0; i < name.length(); ++i) {

View File

@ -151,10 +151,10 @@ abstract class UnsafeFieldAccessorImpl extends FieldAccessorImpl {
if (isFinal) if (isFinal)
err += " final"; err += " final";
err += " " + field.getType().getName() + " field " + getQualifiedFieldName() + " to "; err += " " + field.getType().getName() + " field " + getQualifiedFieldName() + " to ";
if (attemptedValue.length() > 0) { if (!attemptedValue.isEmpty()) {
err += "(" + attemptedType + ")" + attemptedValue; err += "(" + attemptedType + ")" + attemptedValue;
} else { } else {
if (attemptedType.length() > 0) if (!attemptedType.isEmpty())
err += attemptedType; err += attemptedType;
else else
err += "null value"; err += "null value";

View File

@ -291,7 +291,7 @@ public class JarIndex {
while((line = br.readLine()) != null && !line.endsWith(".jar")); while((line = br.readLine()) != null && !line.endsWith(".jar"));
for(;line != null; line = br.readLine()) { for(;line != null; line = br.readLine()) {
if (line.length() == 0) if (line.isEmpty())
continue; continue;
if (line.endsWith(".jar")) { if (line.endsWith(".jar")) {

View File

@ -103,7 +103,7 @@ public class PropertiesDefaultHandler extends DefaultHandler {
writer.writeStartDocument(); writer.writeStartDocument();
writer.writeDTD(PROPS_DTD_DECL); writer.writeDTD(PROPS_DTD_DECL);
writer.writeStartElement(ELEMENT_ROOT); writer.writeStartElement(ELEMENT_ROOT);
if (comment != null && comment.length() > 0) { if (comment != null && !comment.isEmpty()) {
writer.writeStartElement(ELEMENT_COMMENT); writer.writeStartElement(ELEMENT_COMMENT);
writer.writeCharacters(comment); writer.writeCharacters(comment);
writer.writeEndElement(); writer.writeEndElement();

View File

@ -1591,7 +1591,7 @@ public abstract class Parser {
str = name(false); str = name(false);
// PI target name may not be empty string [#2.6] // PI target name may not be empty string [#2.6]
// PI target name 'XML' is reserved [#2.6] // PI target name 'XML' is reserved [#2.6]
if ((str.length() == 0) if ((str.isEmpty())
|| (mXml.name.equals(str.toLowerCase()) == true)) { || (mXml.name.equals(str.toLowerCase()) == true)) {
panic(FAULT); panic(FAULT);
} }

View File

@ -205,7 +205,7 @@ public class XMLStreamWriterImpl implements XMLStreamWriter {
* @throws XMLStreamException * @throws XMLStreamException
*/ */
public void writeStartElement(String localName) throws XMLStreamException { public void writeStartElement(String localName) throws XMLStreamException {
if (localName == null || localName.length() == 0) { if (localName == null || localName.isEmpty()) {
throw new XMLStreamException("Local Name cannot be null or empty"); throw new XMLStreamException("Local Name cannot be null or empty");
} }
@ -420,7 +420,7 @@ public class XMLStreamWriterImpl implements XMLStreamWriter {
} }
private void writeXMLContent(String content) throws XMLStreamException { private void writeXMLContent(String content) throws XMLStreamException {
if ((content != null) && (content.length() > 0)) { if (content != null && !content.isEmpty()) {
writeXMLContent(content, writeXMLContent(content,
_escapeCharacters, // boolean = escapeChars _escapeCharacters, // boolean = escapeChars
false); // false = escapeDoubleQuotes false); // false = escapeDoubleQuotes

View File

@ -451,7 +451,7 @@ public class BytecodeName {
* @return true if the name is non-empty and all of its characters are safe * @return true if the name is non-empty and all of its characters are safe
*/ */
public static boolean isSafeBytecodeName(String s) { public static boolean isSafeBytecodeName(String s) {
if (s.length() == 0) return false; if (s.isEmpty()) return false;
// check occurrences of each DANGEROUS char // check occurrences of each DANGEROUS char
for (char xc : DANGEROUS_CHARS_A) { for (char xc : DANGEROUS_CHARS_A) {
if (xc == ESCAPE_C) continue; // not really that dangerous if (xc == ESCAPE_C) continue; // not really that dangerous
@ -476,7 +476,7 @@ public class BytecodeName {
} }
private static String mangle(String s) { private static String mangle(String s) {
if (s.length() == 0) if (s.isEmpty())
return NULL_ESCAPE; return NULL_ESCAPE;
// build this lazily, when we first need an escape: // build this lazily, when we first need an escape:

View File

@ -76,7 +76,7 @@ public class TransferProtocolClient extends NetworkClient {
System.out.print(response); System.out.print(response);
} }
if (response.length() == 0) { if (response.isEmpty()) {
code = -1; code = -1;
} else { } else {
try { try {

View File

@ -433,7 +433,7 @@ public class FtpClient extends sun.net.ftp.FtpClient {
logger.finest("Server [" + serverAddr + "] --> " + response); logger.finest("Server [" + serverAddr + "] --> " + response);
} }
if (response.length() == 0) { if (response.isEmpty()) {
code = -1; code = -1;
} else { } else {
try { try {
@ -1049,7 +1049,7 @@ public class FtpClient extends sun.net.ftp.FtpClient {
if (!isConnected()) { if (!isConnected()) {
throw new sun.net.ftp.FtpProtocolException("Not connected yet", FtpReplyCode.BAD_SEQUENCE); throw new sun.net.ftp.FtpProtocolException("Not connected yet", FtpReplyCode.BAD_SEQUENCE);
} }
if (user == null || user.length() == 0) { if (user == null || user.isEmpty()) {
throw new IllegalArgumentException("User name can't be null or empty"); throw new IllegalArgumentException("User name can't be null or empty");
} }
tryLogin(user, password); tryLogin(user, password);
@ -1088,7 +1088,7 @@ public class FtpClient extends sun.net.ftp.FtpClient {
if (!isConnected()) { if (!isConnected()) {
throw new sun.net.ftp.FtpProtocolException("Not connected yet", FtpReplyCode.BAD_SEQUENCE); throw new sun.net.ftp.FtpProtocolException("Not connected yet", FtpReplyCode.BAD_SEQUENCE);
} }
if (user == null || user.length() == 0) { if (user == null || user.isEmpty()) {
throw new IllegalArgumentException("User name can't be null or empty"); throw new IllegalArgumentException("User name can't be null or empty");
} }
tryLogin(user, password); tryLogin(user, password);
@ -1152,7 +1152,7 @@ public class FtpClient extends sun.net.ftp.FtpClient {
* @exception <code>FtpProtocolException</code> * @exception <code>FtpProtocolException</code>
*/ */
public sun.net.ftp.FtpClient changeDirectory(String remoteDirectory) throws sun.net.ftp.FtpProtocolException, IOException { public sun.net.ftp.FtpClient changeDirectory(String remoteDirectory) throws sun.net.ftp.FtpProtocolException, IOException {
if (remoteDirectory == null || "".equals(remoteDirectory)) { if (remoteDirectory == null || remoteDirectory.isEmpty()) {
throw new IllegalArgumentException("directory can't be null or empty"); throw new IllegalArgumentException("directory can't be null or empty");
} }
@ -1738,7 +1738,7 @@ public class FtpClient extends sun.net.ftp.FtpClient {
* @throws IOException if an error occurs during the transmission. * @throws IOException if an error occurs during the transmission.
*/ */
public long getSize(String path) throws sun.net.ftp.FtpProtocolException, IOException { public long getSize(String path) throws sun.net.ftp.FtpProtocolException, IOException {
if (path == null || path.length() == 0) { if (path == null || path.isEmpty()) {
throw new IllegalArgumentException("path can't be null or empty"); throw new IllegalArgumentException("path can't be null or empty");
} }
issueCommandCheck("SIZE " + path); issueCommandCheck("SIZE " + path);

View File

@ -238,7 +238,7 @@ public class DefaultProxySelector extends ProxySelector {
if (phost != null && phost.length() != 0) if (phost != null && phost.length() != 0)
break; break;
} }
if (phost == null || phost.length() == 0) { if (phost == null || phost.isEmpty()) {
/** /**
* No system property defined for that * No system property defined for that
* protocol. Let's check System Proxy * protocol. Let's check System Proxy
@ -267,7 +267,7 @@ public class DefaultProxySelector extends ProxySelector {
nprop.hostsSource = null; nprop.hostsSource = null;
nprop.pattern = null; nprop.pattern = null;
} }
} else if (nphosts.length() != 0) { } else if (!nphosts.isEmpty()) {
// add the required default patterns // add the required default patterns
// but only if property no set. If it // but only if property no set. If it
// is empty, leave empty. // is empty, leave empty.

View File

@ -226,7 +226,7 @@ public class HeaderParser {
for (int i=0; k.hasNext(); i++) { for (int i=0; k.hasNext(); i++) {
String key = k.next(); String key = k.next();
String val = findValue (i); String val = findValue (i);
if (val != null && "".equals (val)) { if (val != null && val.isEmpty()) {
val = null; val = null;
} }
sb.append(" {").append(key).append(val == null ? "" : "," + val) sb.append(" {").append(key).append(val == null ? "" : "," + val)

View File

@ -201,9 +201,7 @@ public class MimeEntry implements Cloneable {
} }
private boolean isStarred(String typeName) { private boolean isStarred(String typeName) {
return (typeName != null) return typeName != null && typeName.endsWith("/*");
&& (typeName.length() > 0)
&& (typeName.endsWith("/*"));
} }
/** /**
@ -300,7 +298,7 @@ public class MimeEntry implements Cloneable {
} }
String extensions = getExtensionsAsList(); String extensions = getExtensionsAsList();
if (extensions.length() > 0) { if (!extensions.isEmpty()) {
sj.add("file_extensions=" + extensions); sj.add("file_extensions=" + extensions);
} }

View File

@ -162,7 +162,7 @@ class MimeLauncher extends Thread {
location the application. If a valid path is not found, it location the application. If a valid path is not found, it
returns false else true. */ returns false else true. */
private boolean findExecutablePath(String str) { private boolean findExecutablePath(String str) {
if (str == null || str.length() == 0) { if (str == null || str.isEmpty()) {
return false; return false;
} }

View File

@ -536,8 +536,7 @@ public final class ParseUtil {
throws URISyntaxException throws URISyntaxException
{ {
if (scheme != null) { if (scheme != null) {
if ((path != null) if (path != null && !path.isEmpty() && path.charAt(0) != '/')
&& ((path.length() > 0) && (path.charAt(0) != '/')))
throw new URISyntaxException(s, throw new URISyntaxException(s,
"Relative path in absolute URI"); "Relative path in absolute URI");
} }

View File

@ -603,7 +603,7 @@ public class HttpClient extends NetworkClient {
StringBuilder result = new StringBuilder(128); StringBuilder result = new StringBuilder(128);
result.append(url.getProtocol()); result.append(url.getProtocol());
result.append(":"); result.append(":");
if (url.getAuthority() != null && url.getAuthority().length() > 0) { if (url.getAuthority() != null && !url.getAuthority().isEmpty()) {
result.append("//"); result.append("//");
result.append(url.getAuthority()); result.append(url.getAuthority());
} }
@ -619,7 +619,7 @@ public class HttpClient extends NetworkClient {
} else { } else {
fileName = url.getFile(); fileName = url.getFile();
if ((fileName == null) || (fileName.length() == 0)) { if ((fileName == null) || (fileName.isEmpty())) {
fileName = "/"; fileName = "/";
} else if (fileName.charAt(0) == '?') { } else if (fileName.charAt(0) == '?') {
/* HTTP/1.1 spec says in 5.1.2. about Request-URI: /* HTTP/1.1 spec says in 5.1.2. about Request-URI:

View File

@ -341,7 +341,7 @@ public class FtpURLConnection extends URLConnection {
path.charAt(0) == '/') { path.charAt(0) == '/') {
path = path.substring(1); path = path.substring(1);
} }
if (path == null || path.length() == 0) { if (path == null || path.isEmpty()) {
path = "./"; path = "./";
} }
if (!path.endsWith("/")) { if (!path.endsWith("/")) {
@ -555,7 +555,7 @@ public class FtpURLConnection extends URLConnection {
} }
decodePath(url.getPath()); decodePath(url.getPath());
if (filename == null || filename.length() == 0) { if (filename == null || filename.isEmpty()) {
throw new IOException("illegal filename for a PUT"); throw new IOException("illegal filename for a PUT");
} }
try { try {

View File

@ -248,7 +248,7 @@ public abstract class AuthenticationInfo extends AuthCacheValue implements Clone
this.realm = realm; this.realm = realm;
String urlPath = url.getPath(); String urlPath = url.getPath();
if (urlPath.length() == 0) if (urlPath.isEmpty())
this.path = urlPath; this.path = urlPath;
else { else {
this.path = reducePath (urlPath); this.path = reducePath (urlPath);

View File

@ -279,7 +279,7 @@ class DigestAuthentication extends AuthenticationInfo {
if (s == null || !s.equals("true")) if (s == null || !s.equals("true"))
return false; return false;
String newNonce = p.findValue ("nonce"); String newNonce = p.findValue ("nonce");
if (newNonce == null || "".equals(newNonce)) { if (newNonce == null || newNonce.isEmpty()) {
return false; return false;
} }
params.setNonce (newNonce); params.setNonce (newNonce);
@ -323,7 +323,7 @@ class DigestAuthentication extends AuthenticationInfo {
+ authMethod.substring(1).toLowerCase(); + authMethod.substring(1).toLowerCase();
} }
String algorithm = p.findValue("algorithm"); String algorithm = p.findValue("algorithm");
if (algorithm == null || "".equals(algorithm)) { if (algorithm == null || algorithm.isEmpty()) {
algorithm = "MD5"; // The default, accoriding to rfc2069 algorithm = "MD5"; // The default, accoriding to rfc2069
} }
params.setAlgorithm (algorithm); params.setAlgorithm (algorithm);
@ -451,7 +451,7 @@ class DigestAuthentication extends AuthenticationInfo {
} }
/* Check if there is a nextnonce field */ /* Check if there is a nextnonce field */
String nextnonce = p.findValue ("nextnonce"); String nextnonce = p.findValue ("nextnonce");
if (nextnonce != null && ! "".equals(nextnonce)) { if (nextnonce != null && !nextnonce.isEmpty()) {
params.setNonce (nextnonce); params.setNonce (nextnonce);
} }

View File

@ -3026,7 +3026,7 @@ public class HttpURLConnection extends java.net.HttpURLConnection {
// Filtering only if there is a cookie handler. [Assumption: the // Filtering only if there is a cookie handler. [Assumption: the
// cookie handler will store/retrieve the HttpOnly cookies] // cookie handler will store/retrieve the HttpOnly cookies]
if (cookieHandler == null || value.length() == 0) if (cookieHandler == null || value.isEmpty())
return value; return value;
JavaNetHttpCookieAccess access = JavaNetHttpCookieAccess access =

Some files were not shown because too many files have changed in this diff Show More