mirror of
https://github.com/openjdk/jdk.git
synced 2025-09-20 11:04:34 +02:00
Merge
This commit is contained in:
commit
f6fcaf0f7d
1139 changed files with 23321 additions and 126709 deletions
|
@ -124,10 +124,10 @@ final class GHASH {
|
|||
|
||||
}
|
||||
|
||||
/* subkeyH and state are stored in long[] for GHASH intrinsic use */
|
||||
/* subkeyHtbl and state are stored in long[] for GHASH intrinsic use */
|
||||
|
||||
// hash subkey H; should not change after the object has been constructed
|
||||
private final long[] subkeyH;
|
||||
// hashtable subkeyHtbl; holds 2*9 powers of subkeyH computed using carry-less multiplication
|
||||
private long[] subkeyHtbl;
|
||||
|
||||
// buffer for storing hash
|
||||
private final long[] state;
|
||||
|
@ -149,9 +149,9 @@ final class GHASH {
|
|||
throw new ProviderException("Internal error");
|
||||
}
|
||||
state = new long[2];
|
||||
this.subkeyH = new long[2];
|
||||
this.subkeyH[0] = getLong(subkeyH, 0);
|
||||
this.subkeyH[1] = getLong(subkeyH, 8);
|
||||
subkeyHtbl = new long[2*9];
|
||||
subkeyHtbl[0] = getLong(subkeyH, 0);
|
||||
subkeyHtbl[1] = getLong(subkeyH, 8);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -194,8 +194,8 @@ final class GHASH {
|
|||
if (inLen == 0) {
|
||||
return;
|
||||
}
|
||||
ghashRangeCheck(in, inOfs, inLen, state, subkeyH);
|
||||
processBlocks(in, inOfs, inLen/AES_BLOCK_SIZE, state, subkeyH);
|
||||
ghashRangeCheck(in, inOfs, inLen, state, subkeyHtbl);
|
||||
processBlocks(in, inOfs, inLen/AES_BLOCK_SIZE, state, subkeyHtbl);
|
||||
}
|
||||
|
||||
private static void ghashRangeCheck(byte[] in, int inOfs, int inLen, long[] st, long[] subH) {
|
||||
|
@ -219,8 +219,8 @@ final class GHASH {
|
|||
throw new RuntimeException("internal state has invalid length: " +
|
||||
st.length);
|
||||
}
|
||||
if (subH.length != 2) {
|
||||
throw new RuntimeException("internal subkeyH has invalid length: " +
|
||||
if (subH.length != 18) {
|
||||
throw new RuntimeException("internal subkeyHtbl has invalid length: " +
|
||||
subH.length);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -26,9 +26,7 @@
|
|||
package com.sun.crypto.provider;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import javax.crypto.MacSpi;
|
||||
import javax.crypto.SecretKey;
|
||||
import javax.crypto.spec.SecretKeySpec;
|
||||
import javax.crypto.spec.PBEParameterSpec;
|
||||
|
@ -36,18 +34,65 @@ import java.security.*;
|
|||
import java.security.spec.*;
|
||||
|
||||
/**
|
||||
* This is an implementation of the HMAC-PBESHA1 algorithm as defined
|
||||
* in PKCS#12 v1.0 standard.
|
||||
* This is an implementation of the HMAC algorithms as defined
|
||||
* in PKCS#12 v1.1 standard (see RFC 7292 Appendix B.4).
|
||||
*
|
||||
* @author Valerie Peng
|
||||
*/
|
||||
public final class HmacPKCS12PBESHA1 extends HmacCore {
|
||||
abstract class HmacPKCS12PBECore extends HmacCore {
|
||||
|
||||
public static final class HmacPKCS12PBE_SHA1 extends HmacPKCS12PBECore {
|
||||
public HmacPKCS12PBE_SHA1() throws NoSuchAlgorithmException {
|
||||
super("SHA1", 64);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class HmacPKCS12PBE_SHA224 extends HmacPKCS12PBECore {
|
||||
public HmacPKCS12PBE_SHA224() throws NoSuchAlgorithmException {
|
||||
super("SHA-224", 64);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class HmacPKCS12PBE_SHA256 extends HmacPKCS12PBECore {
|
||||
public HmacPKCS12PBE_SHA256() throws NoSuchAlgorithmException {
|
||||
super("SHA-256", 64);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class HmacPKCS12PBE_SHA384 extends HmacPKCS12PBECore {
|
||||
public HmacPKCS12PBE_SHA384() throws NoSuchAlgorithmException {
|
||||
super("SHA-384", 128);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class HmacPKCS12PBE_SHA512 extends HmacPKCS12PBECore {
|
||||
public HmacPKCS12PBE_SHA512() throws NoSuchAlgorithmException {
|
||||
super("SHA-512", 128);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class HmacPKCS12PBE_SHA512_224 extends HmacPKCS12PBECore {
|
||||
public HmacPKCS12PBE_SHA512_224() throws NoSuchAlgorithmException {
|
||||
super("SHA-512/224", 128);
|
||||
}
|
||||
}
|
||||
|
||||
public static final class HmacPKCS12PBE_SHA512_256 extends HmacPKCS12PBECore {
|
||||
public HmacPKCS12PBE_SHA512_256() throws NoSuchAlgorithmException {
|
||||
super("SHA-512/256", 128);
|
||||
}
|
||||
}
|
||||
|
||||
private final String algorithm;
|
||||
private final int bl;
|
||||
|
||||
/**
|
||||
* Standard constructor, creates a new HmacSHA1 instance.
|
||||
*/
|
||||
public HmacPKCS12PBESHA1() throws NoSuchAlgorithmException {
|
||||
super("SHA1", 64);
|
||||
public HmacPKCS12PBECore(String algorithm, int bl) throws NoSuchAlgorithmException {
|
||||
super(algorithm, bl);
|
||||
this.algorithm = algorithm;
|
||||
this.bl = bl;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -132,7 +177,8 @@ public final class HmacPKCS12PBESHA1 extends HmacCore {
|
|||
("IterationCount must be a positive number");
|
||||
}
|
||||
derivedKey = PKCS12PBECipherCore.derive(passwdChars, salt,
|
||||
iCount, engineGetMacLength(), PKCS12PBECipherCore.MAC_KEY);
|
||||
iCount, engineGetMacLength(), PKCS12PBECipherCore.MAC_KEY,
|
||||
algorithm, bl);
|
||||
} finally {
|
||||
Arrays.fill(passwdChars, '\0');
|
||||
}
|
|
@ -314,41 +314,48 @@ abstract class PBES2Parameters extends AlgorithmParametersSpi {
|
|||
+ "not an ASN.1 OCTET STRING tag");
|
||||
}
|
||||
iCount = pBKDF2_params.data.getInteger();
|
||||
|
||||
DerValue prf = null;
|
||||
// keyLength INTEGER (1..MAX) OPTIONAL,
|
||||
if (pBKDF2_params.data.available() > 0) {
|
||||
DerValue keyLength = pBKDF2_params.data.getDerValue();
|
||||
if (keyLength.tag == DerValue.tag_Integer) {
|
||||
keysize = keyLength.getInteger() * 8; // keysize (in bits)
|
||||
} else {
|
||||
// Should be the prf
|
||||
prf = keyLength;
|
||||
}
|
||||
}
|
||||
// prf AlgorithmIdentifier {{PBKDF2-PRFs}} DEFAULT algid-hmacWithSHA1
|
||||
String kdfAlgo = "HmacSHA1";
|
||||
if (pBKDF2_params.data.available() > 0) {
|
||||
if (pBKDF2_params.tag == DerValue.tag_Sequence) {
|
||||
DerValue prf = pBKDF2_params.data.getDerValue();
|
||||
kdfAlgo_OID = prf.data.getOID();
|
||||
if (hmacWithSHA1_OID.equals(kdfAlgo_OID)) {
|
||||
kdfAlgo = "HmacSHA1";
|
||||
} else if (hmacWithSHA224_OID.equals(kdfAlgo_OID)) {
|
||||
kdfAlgo = "HmacSHA224";
|
||||
} else if (hmacWithSHA256_OID.equals(kdfAlgo_OID)) {
|
||||
kdfAlgo = "HmacSHA256";
|
||||
} else if (hmacWithSHA384_OID.equals(kdfAlgo_OID)) {
|
||||
kdfAlgo = "HmacSHA384";
|
||||
} else if (hmacWithSHA512_OID.equals(kdfAlgo_OID)) {
|
||||
kdfAlgo = "HmacSHA512";
|
||||
} else {
|
||||
if (prf == null) {
|
||||
if (pBKDF2_params.data.available() > 0) {
|
||||
prf = pBKDF2_params.data.getDerValue();
|
||||
}
|
||||
}
|
||||
if (prf != null) {
|
||||
kdfAlgo_OID = prf.data.getOID();
|
||||
if (hmacWithSHA1_OID.equals(kdfAlgo_OID)) {
|
||||
kdfAlgo = "HmacSHA1";
|
||||
} else if (hmacWithSHA224_OID.equals(kdfAlgo_OID)) {
|
||||
kdfAlgo = "HmacSHA224";
|
||||
} else if (hmacWithSHA256_OID.equals(kdfAlgo_OID)) {
|
||||
kdfAlgo = "HmacSHA256";
|
||||
} else if (hmacWithSHA384_OID.equals(kdfAlgo_OID)) {
|
||||
kdfAlgo = "HmacSHA384";
|
||||
} else if (hmacWithSHA512_OID.equals(kdfAlgo_OID)) {
|
||||
kdfAlgo = "HmacSHA512";
|
||||
} else {
|
||||
throw new IOException("PBE parameter parsing error: "
|
||||
+ "expecting the object identifier for a HmacSHA key "
|
||||
+ "derivation function");
|
||||
}
|
||||
if (prf.data.available() != 0) {
|
||||
// parameter is 'NULL' for all HmacSHA KDFs
|
||||
DerValue parameter = prf.data.getDerValue();
|
||||
if (parameter.tag != DerValue.tag_Null) {
|
||||
throw new IOException("PBE parameter parsing error: "
|
||||
+ "expecting the object identifier for a HmacSHA key "
|
||||
+ "derivation function");
|
||||
}
|
||||
if (prf.data.available() != 0) {
|
||||
// parameter is 'NULL' for all HmacSHA KDFs
|
||||
DerValue parameter = prf.data.getDerValue();
|
||||
if (parameter.tag != DerValue.tag_Null) {
|
||||
throw new IOException("PBE parameter parsing error: "
|
||||
+ "not an ASN.1 NULL tag");
|
||||
}
|
||||
+ "not an ASN.1 NULL tag");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -996,7 +996,7 @@ class Attribute implements Comparable<Attribute> {
|
|||
endp = cstr.indexOf(',', cp);
|
||||
if (endp < 0) endp = cstrlen;
|
||||
String cstr1 = cstr.substring(cp, endp);
|
||||
if (cstr1.length() == 0)
|
||||
if (cstr1.isEmpty())
|
||||
cstr1 = "empty"; // will fail parse
|
||||
int value0, value1;
|
||||
// Check for a case range (new in 1.6).
|
||||
|
|
|
@ -50,6 +50,7 @@ class Constants {
|
|||
1.10 to 1.10.X 54,0
|
||||
1.11 to 1.11.X 55,0
|
||||
1.12 to 1.12.X 56,0
|
||||
1.13 to 1.13.X 57,0
|
||||
*/
|
||||
|
||||
public static final Package.Version JAVA_MIN_CLASS_VERSION =
|
||||
|
@ -79,6 +80,9 @@ class Constants {
|
|||
public static final Package.Version JAVA12_MAX_CLASS_VERSION =
|
||||
Package.Version.of(56, 00);
|
||||
|
||||
public static final Package.Version JAVA13_MAX_CLASS_VERSION =
|
||||
Package.Version.of(57, 00);
|
||||
|
||||
public static final int JAVA_PACKAGE_MAGIC = 0xCAFED00D;
|
||||
|
||||
public static final Package.Version JAVA5_PACKAGE_VERSION =
|
||||
|
@ -95,7 +99,7 @@ class Constants {
|
|||
|
||||
// upper limit, should point to the latest class version
|
||||
public static final Package.Version JAVA_MAX_CLASS_VERSION =
|
||||
JAVA12_MAX_CLASS_VERSION;
|
||||
JAVA13_MAX_CLASS_VERSION;
|
||||
|
||||
// upper limit should point to the latest package version, for version info!.
|
||||
public static final Package.Version MAX_PACKAGE_VERSION =
|
||||
|
|
|
@ -279,7 +279,7 @@ class Driver {
|
|||
junpack.properties().putAll(engProps);
|
||||
if (doRepack && newfile.equals(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));
|
||||
if (zipc.indexOf(Utils.PACK_ZIP_ARCHIVE_MARKER_COMMENT) >= 0) {
|
||||
System.out.println(MessageFormat.format(RESOURCE.getString(DriverResource.SKIP_FOR_REPACKED), jarfile));
|
||||
|
@ -552,7 +552,7 @@ class Driver {
|
|||
if (words.length == 0) continue loadOptmap;
|
||||
String opt = words[0];
|
||||
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 ' '
|
||||
words[1] = "";
|
||||
}
|
||||
|
@ -622,7 +622,7 @@ class Driver {
|
|||
switch (specop) {
|
||||
case '+':
|
||||
// + means we want an non-empty val suffix.
|
||||
ok = (val.length() != 0);
|
||||
ok = !val.isEmpty();
|
||||
specop = spec.charAt(sidx++);
|
||||
break;
|
||||
case '*':
|
||||
|
@ -641,10 +641,10 @@ class Driver {
|
|||
String specarg = spec.substring(sidx);
|
||||
switch (specop) {
|
||||
case '.': // terminate the option sequence
|
||||
resultString = (specarg.length() != 0)? specarg.intern(): opt;
|
||||
resultString = specarg.isEmpty() ? opt : specarg.intern();
|
||||
break doArgs;
|
||||
case '?': // abort the option sequence
|
||||
resultString = (specarg.length() != 0)? specarg.intern(): arg;
|
||||
resultString = specarg.isEmpty() ? arg : specarg.intern();
|
||||
isError = true;
|
||||
break eachSpec;
|
||||
case '@': // change the effective opt name
|
||||
|
@ -655,14 +655,14 @@ class Driver {
|
|||
val = "";
|
||||
break;
|
||||
case '!': // negation option
|
||||
String negopt = (specarg.length() != 0)? specarg.intern(): opt;
|
||||
String negopt = specarg.isEmpty() ? opt : specarg.intern();
|
||||
properties.remove(negopt);
|
||||
properties.put(negopt, null); // leave placeholder
|
||||
didAction = true;
|
||||
break;
|
||||
case '$': // normal "boolean" option
|
||||
String boolval;
|
||||
if (specarg.length() != 0) {
|
||||
if (!specarg.isEmpty()) {
|
||||
// If there is a given spec token, store it.
|
||||
boolval = specarg;
|
||||
} else {
|
||||
|
|
|
@ -153,7 +153,7 @@ public class KeyManagerFactory {
|
|||
String provider)
|
||||
throws NoSuchAlgorithmException, NoSuchProviderException
|
||||
{
|
||||
if (provider == null || provider.length() == 0)
|
||||
if (provider == null || provider.isEmpty())
|
||||
throw new IllegalArgumentException("missing provider");
|
||||
Object[] objs = SSLSecurity.getImpl(algorithm, "KeyManagerFactory",
|
||||
provider);
|
||||
|
|
|
@ -109,7 +109,7 @@ public class SSLContext {
|
|||
public static SSLContext getInstance(String protocol, String provider)
|
||||
throws NoSuchAlgorithmException, NoSuchProviderException
|
||||
{
|
||||
if (provider == null || provider.length() == 0)
|
||||
if (provider == null || provider.isEmpty())
|
||||
throw new IllegalArgumentException("missing provider");
|
||||
Object[] objs = SSLSecurity.getImpl(protocol, "SSLContext",
|
||||
provider);
|
||||
|
|
|
@ -155,7 +155,7 @@ public class TrustManagerFactory {
|
|||
String provider)
|
||||
throws NoSuchAlgorithmException, NoSuchProviderException
|
||||
{
|
||||
if (provider == null || provider.length() == 0)
|
||||
if (provider == null || provider.isEmpty())
|
||||
throw new IllegalArgumentException("missing provider");
|
||||
Object[] objs = SSLSecurity.getImpl(algorithm, "TrustManagerFactory",
|
||||
provider);
|
||||
|
|
|
@ -247,7 +247,7 @@ public final class Console implements Flushable
|
|||
String line = null;
|
||||
synchronized (writeLock) {
|
||||
synchronized(readLock) {
|
||||
if (fmt.length() != 0)
|
||||
if (!fmt.isEmpty())
|
||||
pw.format(fmt, args);
|
||||
try {
|
||||
char[] ca = readline(false);
|
||||
|
@ -319,7 +319,7 @@ public final class Console implements Flushable
|
|||
}
|
||||
IOError ioe = null;
|
||||
try {
|
||||
if (fmt.length() != 0)
|
||||
if (!fmt.isEmpty())
|
||||
pw.format(fmt, args);
|
||||
passwd = readline(true);
|
||||
} catch (IOException x) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1996, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1996, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -2275,7 +2275,7 @@ public class ObjectStreamClass implements Serializable {
|
|||
*/
|
||||
private static class FieldReflectorKey extends WeakReference<Class<?>> {
|
||||
|
||||
private final String sigs;
|
||||
private final String[] sigs;
|
||||
private final int hash;
|
||||
private final boolean nullClass;
|
||||
|
||||
|
@ -2284,13 +2284,13 @@ public class ObjectStreamClass implements Serializable {
|
|||
{
|
||||
super(cl, queue);
|
||||
nullClass = (cl == null);
|
||||
StringBuilder sbuf = new StringBuilder();
|
||||
for (int i = 0; i < fields.length; i++) {
|
||||
sigs = new String[2 * fields.length];
|
||||
for (int i = 0, j = 0; i < fields.length; i++) {
|
||||
ObjectStreamField f = fields[i];
|
||||
sbuf.append(f.getName()).append(f.getSignature());
|
||||
sigs[j++] = f.getName();
|
||||
sigs[j++] = f.getSignature();
|
||||
}
|
||||
sigs = sbuf.toString();
|
||||
hash = System.identityHashCode(cl) + sigs.hashCode();
|
||||
hash = System.identityHashCode(cl) + Arrays.hashCode(sigs);
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
|
@ -2308,7 +2308,7 @@ public class ObjectStreamClass implements Serializable {
|
|||
return (nullClass ? other.nullClass
|
||||
: ((referent = get()) != null) &&
|
||||
(referent == other.get())) &&
|
||||
sigs.equals(other.sigs);
|
||||
Arrays.equals(sigs, other.sigs);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -575,7 +575,7 @@ public class PrintStream extends FilterOutputStream
|
|||
* stream occur as promptly as with the original PrintStream.
|
||||
*/
|
||||
|
||||
private void write(char buf[]) {
|
||||
private void write(char[] buf) {
|
||||
try {
|
||||
synchronized (this) {
|
||||
ensureOpen();
|
||||
|
@ -584,10 +584,34 @@ public class PrintStream extends FilterOutputStream
|
|||
charOut.flushBuffer();
|
||||
if (autoFlush) {
|
||||
for (int i = 0; i < buf.length; i++)
|
||||
if (buf[i] == '\n')
|
||||
if (buf[i] == '\n') {
|
||||
out.flush();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (InterruptedIOException x) {
|
||||
Thread.currentThread().interrupt();
|
||||
} catch (IOException x) {
|
||||
trouble = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Used to optimize away back-to-back flushing and synchronization when
|
||||
// using println, but since subclasses could exist which depend on
|
||||
// observing a call to print followed by newLine() we only use this if
|
||||
// getClass() == PrintStream.class to avoid compatibility issues.
|
||||
private void writeln(char[] buf) {
|
||||
try {
|
||||
synchronized (this) {
|
||||
ensureOpen();
|
||||
textOut.write(buf);
|
||||
textOut.newLine();
|
||||
textOut.flushBuffer();
|
||||
charOut.flushBuffer();
|
||||
if (autoFlush)
|
||||
out.flush();
|
||||
}
|
||||
}
|
||||
catch (InterruptedIOException x) {
|
||||
Thread.currentThread().interrupt();
|
||||
|
@ -616,6 +640,30 @@ public class PrintStream extends FilterOutputStream
|
|||
}
|
||||
}
|
||||
|
||||
// Used to optimize away back-to-back flushing and synchronization when
|
||||
// using println, but since subclasses could exist which depend on
|
||||
// observing a call to print followed by newLine we only use this if
|
||||
// getClass() == PrintStream.class to avoid compatibility issues.
|
||||
private void writeln(String s) {
|
||||
try {
|
||||
synchronized (this) {
|
||||
ensureOpen();
|
||||
textOut.write(s);
|
||||
textOut.newLine();
|
||||
textOut.flushBuffer();
|
||||
charOut.flushBuffer();
|
||||
if (autoFlush)
|
||||
out.flush();
|
||||
}
|
||||
}
|
||||
catch (InterruptedIOException x) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
catch (IOException x) {
|
||||
trouble = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void newLine() {
|
||||
try {
|
||||
synchronized (this) {
|
||||
|
@ -780,9 +828,13 @@ public class PrintStream extends FilterOutputStream
|
|||
* @param x The {@code boolean} to be printed
|
||||
*/
|
||||
public void println(boolean x) {
|
||||
synchronized (this) {
|
||||
print(x);
|
||||
newLine();
|
||||
if (getClass() == PrintStream.class) {
|
||||
writeln(String.valueOf(x));
|
||||
} else {
|
||||
synchronized (this) {
|
||||
print(x);
|
||||
newLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -794,9 +846,13 @@ public class PrintStream extends FilterOutputStream
|
|||
* @param x The {@code char} to be printed.
|
||||
*/
|
||||
public void println(char x) {
|
||||
synchronized (this) {
|
||||
print(x);
|
||||
newLine();
|
||||
if (getClass() == PrintStream.class) {
|
||||
writeln(String.valueOf(x));
|
||||
} else {
|
||||
synchronized (this) {
|
||||
print(x);
|
||||
newLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -808,9 +864,13 @@ public class PrintStream extends FilterOutputStream
|
|||
* @param x The {@code int} to be printed.
|
||||
*/
|
||||
public void println(int x) {
|
||||
synchronized (this) {
|
||||
print(x);
|
||||
newLine();
|
||||
if (getClass() == PrintStream.class) {
|
||||
writeln(String.valueOf(x));
|
||||
} else {
|
||||
synchronized (this) {
|
||||
print(x);
|
||||
newLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -822,9 +882,13 @@ public class PrintStream extends FilterOutputStream
|
|||
* @param x a The {@code long} to be printed.
|
||||
*/
|
||||
public void println(long x) {
|
||||
synchronized (this) {
|
||||
print(x);
|
||||
newLine();
|
||||
if (getClass() == PrintStream.class) {
|
||||
writeln(String.valueOf(x));
|
||||
} else {
|
||||
synchronized (this) {
|
||||
print(x);
|
||||
newLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -836,9 +900,13 @@ public class PrintStream extends FilterOutputStream
|
|||
* @param x The {@code float} to be printed.
|
||||
*/
|
||||
public void println(float x) {
|
||||
synchronized (this) {
|
||||
print(x);
|
||||
newLine();
|
||||
if (getClass() == PrintStream.class) {
|
||||
writeln(String.valueOf(x));
|
||||
} else {
|
||||
synchronized (this) {
|
||||
print(x);
|
||||
newLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -850,9 +918,13 @@ public class PrintStream extends FilterOutputStream
|
|||
* @param x The {@code double} to be printed.
|
||||
*/
|
||||
public void println(double x) {
|
||||
synchronized (this) {
|
||||
print(x);
|
||||
newLine();
|
||||
if (getClass() == PrintStream.class) {
|
||||
writeln(String.valueOf(x));
|
||||
} else {
|
||||
synchronized (this) {
|
||||
print(x);
|
||||
newLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -863,10 +935,14 @@ public class PrintStream extends FilterOutputStream
|
|||
*
|
||||
* @param x an array of chars to print.
|
||||
*/
|
||||
public void println(char x[]) {
|
||||
synchronized (this) {
|
||||
print(x);
|
||||
newLine();
|
||||
public void println(char[] x) {
|
||||
if (getClass() == PrintStream.class) {
|
||||
writeln(x);
|
||||
} else {
|
||||
synchronized (this) {
|
||||
print(x);
|
||||
newLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -878,9 +954,13 @@ public class PrintStream extends FilterOutputStream
|
|||
* @param x The {@code String} to be printed.
|
||||
*/
|
||||
public void println(String x) {
|
||||
synchronized (this) {
|
||||
print(x);
|
||||
newLine();
|
||||
if (getClass() == PrintStream.class) {
|
||||
writeln(String.valueOf(x));
|
||||
} else {
|
||||
synchronized (this) {
|
||||
print(x);
|
||||
newLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -895,9 +975,15 @@ public class PrintStream extends FilterOutputStream
|
|||
*/
|
||||
public void println(Object x) {
|
||||
String s = String.valueOf(x);
|
||||
synchronized (this) {
|
||||
print(s);
|
||||
newLine();
|
||||
if (getClass() == PrintStream.class) {
|
||||
// need to apply String.valueOf again since first invocation
|
||||
// might return null
|
||||
writeln(String.valueOf(s));
|
||||
} else {
|
||||
synchronized (this) {
|
||||
print(s);
|
||||
newLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -9085,7 +9085,7 @@ class Character implements java.io.Serializable, Comparable<Character> {
|
|||
* @since 1.5
|
||||
*/
|
||||
public static boolean isLowerCase(int codePoint) {
|
||||
return getType(codePoint) == Character.LOWERCASE_LETTER ||
|
||||
return CharacterData.of(codePoint).isLowerCase(codePoint) ||
|
||||
CharacterData.of(codePoint).isOtherLowercase(codePoint);
|
||||
}
|
||||
|
||||
|
@ -9151,7 +9151,7 @@ class Character implements java.io.Serializable, Comparable<Character> {
|
|||
* @since 1.5
|
||||
*/
|
||||
public static boolean isUpperCase(int codePoint) {
|
||||
return getType(codePoint) == Character.UPPERCASE_LETTER ||
|
||||
return CharacterData.of(codePoint).isUpperCase(codePoint) ||
|
||||
CharacterData.of(codePoint).isOtherUppercase(codePoint);
|
||||
}
|
||||
|
||||
|
@ -9302,7 +9302,7 @@ class Character implements java.io.Serializable, Comparable<Character> {
|
|||
* @since 1.5
|
||||
*/
|
||||
public static boolean isDigit(int codePoint) {
|
||||
return getType(codePoint) == Character.DECIMAL_DIGIT_NUMBER;
|
||||
return CharacterData.of(codePoint).isDigit(codePoint);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2006, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -28,6 +28,9 @@ package java.lang;
|
|||
abstract class CharacterData {
|
||||
abstract int getProperties(int ch);
|
||||
abstract int getType(int ch);
|
||||
abstract boolean isDigit(int ch);
|
||||
abstract boolean isLowerCase(int ch);
|
||||
abstract boolean isUpperCase(int ch);
|
||||
abstract boolean isWhitespace(int ch);
|
||||
abstract boolean isMirrored(int ch);
|
||||
abstract boolean isJavaIdentifierStart(int ch);
|
||||
|
|
|
@ -1119,7 +1119,7 @@ public abstract class ClassLoader {
|
|||
|
||||
// true if the name is null or has the potential to be a valid binary name
|
||||
private boolean checkName(String name) {
|
||||
if ((name == null) || (name.length() == 0))
|
||||
if ((name == null) || (name.isEmpty()))
|
||||
return true;
|
||||
if ((name.indexOf('/') != -1) || (name.charAt(0) == '['))
|
||||
return false;
|
||||
|
@ -1864,12 +1864,12 @@ public abstract class ClassLoader {
|
|||
* <p> The default system class loader is an implementation-dependent
|
||||
* instance of this class.
|
||||
*
|
||||
* <p> If the system property "{@code java.system.class.loader}" is defined
|
||||
* when this method is first invoked then the value of that property is
|
||||
* taken to be the name of a class that will be returned as the system
|
||||
* class loader. The class is loaded using the default system class loader
|
||||
* and must define a public constructor that takes a single parameter of
|
||||
* type {@code ClassLoader} which is used as the delegation parent. An
|
||||
* <p> If the system property "{@systemProperty java.system.class.loader}"
|
||||
* is defined when this method is first invoked then the value of that
|
||||
* property is taken to be the name of a class that will be returned as the
|
||||
* system class loader. The class is loaded using the default system class
|
||||
* loader and must define a public constructor that takes a single parameter
|
||||
* of type {@code ClassLoader} which is used as the delegation parent. An
|
||||
* instance is then created using this constructor with the default system
|
||||
* class loader as the parameter. The resulting class loader is defined
|
||||
* to be the system class loader. During construction, the class loader
|
||||
|
|
|
@ -1077,8 +1077,8 @@ public final class Double extends Number
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a nominal descriptor for this instance, which is the instance
|
||||
* itself.
|
||||
* Returns an {@link Optional} containing the nominal descriptor for this
|
||||
* instance, which is the instance itself.
|
||||
*
|
||||
* @return an {@link Optional} describing the {@linkplain Double} instance
|
||||
* @since 12
|
||||
|
|
|
@ -989,8 +989,8 @@ public final class Float extends Number
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a nominal descriptor for this instance, which is the instance
|
||||
* itself.
|
||||
* Returns an {@link Optional} containing the nominal descriptor for this
|
||||
* instance, which is the instance itself.
|
||||
*
|
||||
* @return an {@link Optional} describing the {@linkplain Float} instance
|
||||
* @since 12
|
||||
|
|
|
@ -1409,7 +1409,7 @@ public final class Integer extends Number
|
|||
boolean negative = false;
|
||||
Integer result;
|
||||
|
||||
if (nm.length() == 0)
|
||||
if (nm.isEmpty())
|
||||
throw new NumberFormatException("Zero length string");
|
||||
char firstChar = nm.charAt(0);
|
||||
// Handle sign, if present
|
||||
|
@ -1838,8 +1838,8 @@ public final class Integer extends Number
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a nominal descriptor for this instance, which is the instance
|
||||
* itself.
|
||||
* Returns an {@link Optional} containing the nominal descriptor for this
|
||||
* instance, which is the instance itself.
|
||||
*
|
||||
* @return an {@link Optional} describing the {@linkplain Integer} instance
|
||||
* @since 12
|
||||
|
|
|
@ -1248,7 +1248,7 @@ public final class Long extends Number
|
|||
boolean negative = false;
|
||||
Long result;
|
||||
|
||||
if (nm.length() == 0)
|
||||
if (nm.isEmpty())
|
||||
throw new NumberFormatException("Zero length string");
|
||||
char firstChar = nm.charAt(0);
|
||||
// Handle sign, if present
|
||||
|
@ -1967,8 +1967,8 @@ public final class Long extends Number
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a nominal descriptor for this instance, which is the instance
|
||||
* itself.
|
||||
* Returns an {@link Optional} containing the nominal descriptor for this
|
||||
* instance, which is the instance itself.
|
||||
*
|
||||
* @return an {@link Optional} describing the {@linkplain Long} instance
|
||||
* @since 12
|
||||
|
|
|
@ -1460,6 +1460,7 @@ public final class Math {
|
|||
* @param b another argument.
|
||||
* @return the larger of {@code a} and {@code b}.
|
||||
*/
|
||||
@HotSpotIntrinsicCandidate
|
||||
public static float max(float a, float b) {
|
||||
if (a != a)
|
||||
return a; // a is NaN
|
||||
|
@ -1486,6 +1487,7 @@ public final class Math {
|
|||
* @param b another argument.
|
||||
* @return the larger of {@code a} and {@code b}.
|
||||
*/
|
||||
@HotSpotIntrinsicCandidate
|
||||
public static double max(double a, double b) {
|
||||
if (a != a)
|
||||
return a; // a is NaN
|
||||
|
@ -1541,6 +1543,7 @@ public final class Math {
|
|||
* @param b another argument.
|
||||
* @return the smaller of {@code a} and {@code b}.
|
||||
*/
|
||||
@HotSpotIntrinsicCandidate
|
||||
public static float min(float a, float b) {
|
||||
if (a != a)
|
||||
return a; // a is NaN
|
||||
|
@ -1567,6 +1570,7 @@ public final class Math {
|
|||
* @param b another argument.
|
||||
* @return the smaller of {@code a} and {@code b}.
|
||||
*/
|
||||
@HotSpotIntrinsicCandidate
|
||||
public static double min(double a, double b) {
|
||||
if (a != a)
|
||||
return a; // a is NaN
|
||||
|
|
|
@ -397,11 +397,11 @@ public class Package extends NamedPackage implements java.lang.reflect.Annotated
|
|||
public String toString() {
|
||||
String spec = versionInfo.specTitle;
|
||||
String ver = versionInfo.specVersion;
|
||||
if (spec != null && spec.length() > 0)
|
||||
if (spec != null && !spec.isEmpty())
|
||||
spec = ", " + spec;
|
||||
else
|
||||
spec = "";
|
||||
if (ver != null && ver.length() > 0)
|
||||
if (ver != null && !ver.isEmpty())
|
||||
ver = ", version " + ver;
|
||||
else
|
||||
ver = "";
|
||||
|
|
|
@ -403,7 +403,7 @@ public class Runtime {
|
|||
*/
|
||||
public Process exec(String command, String[] envp, File dir)
|
||||
throws IOException {
|
||||
if (command.length() == 0)
|
||||
if (command.isEmpty())
|
||||
throw new IllegalArgumentException("Empty command");
|
||||
|
||||
StringTokenizer st = new StringTokenizer(command);
|
||||
|
|
|
@ -1154,6 +1154,7 @@ public final class StrictMath {
|
|||
* @param b another argument.
|
||||
* @return the larger of {@code a} and {@code b}.
|
||||
*/
|
||||
@HotSpotIntrinsicCandidate
|
||||
public static float max(float a, float b) {
|
||||
return Math.max(a, b);
|
||||
}
|
||||
|
@ -1172,6 +1173,7 @@ public final class StrictMath {
|
|||
* @param b another argument.
|
||||
* @return the larger of {@code a} and {@code b}.
|
||||
*/
|
||||
@HotSpotIntrinsicCandidate
|
||||
public static double max(double a, double b) {
|
||||
return Math.max(a, b);
|
||||
}
|
||||
|
@ -1219,6 +1221,7 @@ public final class StrictMath {
|
|||
* @param b another argument.
|
||||
* @return the smaller of {@code a} and {@code b.}
|
||||
*/
|
||||
@HotSpotIntrinsicCandidate
|
||||
public static float min(float a, float b) {
|
||||
return Math.min(a, b);
|
||||
}
|
||||
|
@ -1237,6 +1240,7 @@ public final class StrictMath {
|
|||
* @param b another argument.
|
||||
* @return the smaller of {@code a} and {@code b}.
|
||||
*/
|
||||
@HotSpotIntrinsicCandidate
|
||||
public static double min(double a, double b) {
|
||||
return Math.min(a, b);
|
||||
}
|
||||
|
|
|
@ -1943,8 +1943,7 @@ public final class String
|
|||
* characters followed by the string argument's characters.
|
||||
*/
|
||||
public String concat(String str) {
|
||||
int olen = str.length();
|
||||
if (olen == 0) {
|
||||
if (str.isEmpty()) {
|
||||
return this;
|
||||
}
|
||||
if (coder() == str.coder()) {
|
||||
|
@ -1956,6 +1955,7 @@ public final class String
|
|||
return new String(buf, coder);
|
||||
}
|
||||
int len = length();
|
||||
int olen = str.length();
|
||||
byte[] buf = StringUTF16.newBytesFor(len + olen);
|
||||
getBytes(buf, 0, UTF16);
|
||||
str.getBytes(buf, len, UTF16);
|
||||
|
@ -2316,7 +2316,7 @@ public final class String
|
|||
// Construct result
|
||||
int resultSize = list.size();
|
||||
if (limit == 0) {
|
||||
while (resultSize > 0 && list.get(resultSize - 1).length() == 0) {
|
||||
while (resultSize > 0 && list.get(resultSize - 1).isEmpty()) {
|
||||
resultSize--;
|
||||
}
|
||||
}
|
||||
|
@ -3545,8 +3545,8 @@ public final class String
|
|||
}
|
||||
|
||||
/**
|
||||
* Returns a nominal descriptor for this instance, which is the instance
|
||||
* itself.
|
||||
* Returns an {@link Optional} containing the nominal descriptor for this
|
||||
* instance, which is the instance itself.
|
||||
*
|
||||
* @return an {@link Optional} describing the {@linkplain String} instance
|
||||
* @since 12
|
||||
|
|
|
@ -801,8 +801,9 @@ public final class System {
|
|||
}
|
||||
|
||||
if (props == null) {
|
||||
props = SystemProps.initProperties();
|
||||
VersionProps.init(props);
|
||||
Map<String, String> tempProps = SystemProps.initProperties();
|
||||
VersionProps.init(tempProps);
|
||||
props = createProperties(tempProps);
|
||||
}
|
||||
System.props = props;
|
||||
}
|
||||
|
@ -1959,18 +1960,42 @@ public final class System {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the Properties object from a map - masking out system properties
|
||||
* that are not intended for public access.
|
||||
*/
|
||||
private static Properties createProperties(Map<String, String> initialProps) {
|
||||
Properties properties = new Properties(initialProps.size());
|
||||
for (var entry : initialProps.entrySet()) {
|
||||
String prop = entry.getKey();
|
||||
switch (prop) {
|
||||
// Do not add private system properties to the Properties
|
||||
case "sun.nio.MaxDirectMemorySize":
|
||||
case "sun.nio.PageAlignDirectMemory":
|
||||
// used by java.lang.Integer.IntegerCache
|
||||
case "java.lang.Integer.IntegerCache.high":
|
||||
// used by sun.launcher.LauncherHelper
|
||||
case "sun.java.launcher.diag":
|
||||
// used by jdk.internal.loader.ClassLoaders
|
||||
case "jdk.boot.class.path.append":
|
||||
break;
|
||||
default:
|
||||
properties.put(prop, entry.getValue());
|
||||
}
|
||||
}
|
||||
return properties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize the system class. Called after thread initialization.
|
||||
*/
|
||||
private static void initPhase1() {
|
||||
|
||||
// VM might invoke JNU_NewStringPlatform() to set those encoding
|
||||
// sensitive properties (user.home, user.name, boot.class.path, etc.)
|
||||
// during "props" initialization.
|
||||
// The charset is initialized in System.c and does not depend on the Properties.
|
||||
props = SystemProps.initProperties();
|
||||
VersionProps.init(props);
|
||||
StaticProperty.javaHome(); // Load StaticProperty to cache the property values
|
||||
Map<String, String> tempProps = SystemProps.initProperties();
|
||||
VersionProps.init(tempProps);
|
||||
|
||||
// There are certain system configurations that may be controlled by
|
||||
// VM options such as the maximum amount of direct memory and
|
||||
|
@ -1978,15 +2003,14 @@ public final class System {
|
|||
// of autoboxing. Typically, the library will obtain these values
|
||||
// from the properties set by the VM. If the properties are for
|
||||
// internal implementation use only, these properties should be
|
||||
// removed from the system properties.
|
||||
//
|
||||
// See java.lang.Integer.IntegerCache and the
|
||||
// VM.saveAndRemoveProperties method for example.
|
||||
// masked from the system properties.
|
||||
//
|
||||
// Save a private copy of the system properties object that
|
||||
// can only be accessed by the internal implementation. Remove
|
||||
// certain system properties that are not intended for public access.
|
||||
VM.saveAndRemoveProperties(props);
|
||||
// can only be accessed by the internal implementation.
|
||||
VM.saveProperties(tempProps);
|
||||
props = createProperties(tempProps);
|
||||
|
||||
StaticProperty.javaHome(); // Load StaticProperty to cache the property values
|
||||
|
||||
lineSeparator = props.getProperty("line.separator");
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ package java.lang;
|
|||
import java.io.PrintStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
|
||||
class VersionProps {
|
||||
|
||||
|
@ -73,7 +73,7 @@ class VersionProps {
|
|||
"@@VENDOR_VERSION_STRING@@";
|
||||
|
||||
private static final String vendor_version =
|
||||
(VENDOR_VERSION_STRING.length() > 0
|
||||
(!VENDOR_VERSION_STRING.isEmpty()
|
||||
? " " + VENDOR_VERSION_STRING : "");
|
||||
|
||||
private static final String VENDOR =
|
||||
|
@ -88,25 +88,25 @@ class VersionProps {
|
|||
/**
|
||||
* Initialize system properties using build provided values.
|
||||
*
|
||||
* @param props Properties instance in which to insert the properties
|
||||
* @param props Map instance in which to insert the properties
|
||||
*/
|
||||
public static void init(Properties props) {
|
||||
props.setProperty("java.version", java_version);
|
||||
props.setProperty("java.version.date", java_version_date);
|
||||
props.setProperty("java.runtime.version", java_runtime_version);
|
||||
props.setProperty("java.runtime.name", java_runtime_name);
|
||||
if (VENDOR_VERSION_STRING.length() > 0)
|
||||
props.setProperty("java.vendor.version", VENDOR_VERSION_STRING);
|
||||
public static void init(Map<String, String> props) {
|
||||
props.put("java.version", java_version);
|
||||
props.put("java.version.date", java_version_date);
|
||||
props.put("java.runtime.version", java_runtime_version);
|
||||
props.put("java.runtime.name", java_runtime_name);
|
||||
if (!VENDOR_VERSION_STRING.isEmpty())
|
||||
props.put("java.vendor.version", VENDOR_VERSION_STRING);
|
||||
|
||||
props.setProperty("java.class.version", CLASSFILE_MAJOR_MINOR);
|
||||
props.put("java.class.version", CLASSFILE_MAJOR_MINOR);
|
||||
|
||||
props.setProperty("java.specification.version", VERSION_SPECIFICATION);
|
||||
props.setProperty("java.specification.name", "Java Platform API Specification");
|
||||
props.setProperty("java.specification.vendor", "Oracle Corporation");
|
||||
props.put("java.specification.version", VERSION_SPECIFICATION);
|
||||
props.put("java.specification.name", "Java Platform API Specification");
|
||||
props.put("java.specification.vendor", "Oracle Corporation");
|
||||
|
||||
props.setProperty("java.vendor", VENDOR);
|
||||
props.setProperty("java.vendor.url", VENDOR_URL);
|
||||
props.setProperty("java.vendor.url.bug", VENDOR_URL_BUG);
|
||||
props.put("java.vendor", VENDOR);
|
||||
props.put("java.vendor.url", VENDOR_URL);
|
||||
props.put("java.vendor.url.bug", VENDOR_URL_BUG);
|
||||
}
|
||||
|
||||
private static int parseVersionNumber(String version, int prevIndex, int index) {
|
||||
|
|
|
@ -112,13 +112,13 @@ public interface ClassDesc
|
|||
*
|
||||
* A field type descriptor string for a non-array type is either
|
||||
* a one-letter code corresponding to a primitive type
|
||||
* ({@code J,I,C,S,B,D,F,Z,V}), or the letter {@code L}, followed
|
||||
* by the fully qualified binary name of a class, followed by {@code ;}.
|
||||
* A field type descriptor for an array type is the character {@code [}
|
||||
* ({@code "J", "I", "C", "S", "B", "D", "F", "Z", "V"}), or the letter {@code "L"}, followed
|
||||
* by the fully qualified binary name of a class, followed by {@code ";"}.
|
||||
* A field type descriptor for an array type is the character {@code "["}
|
||||
* followed by the field descriptor for the component type. Examples of
|
||||
* valid type descriptor strings include {@code Ljava/lang/String;}, {@code I},
|
||||
* {@code [I}, {@code V}, {@code [Ljava/lang/String;}, etc.
|
||||
* for more detail.
|
||||
* valid type descriptor strings include {@code "Ljava/lang/String;"}, {@code "I"},
|
||||
* {@code "[I"}, {@code "V"}, {@code "[Ljava/lang/String;"}, etc.
|
||||
* See JVMS 4.3.2 ("Field Descriptors") for more detail.
|
||||
*
|
||||
* @param descriptor a field descriptor string
|
||||
* @return a {@linkplain ClassDesc} describing the desired class
|
||||
|
@ -126,9 +126,15 @@ public interface ClassDesc
|
|||
* @throws IllegalArgumentException if the name string is not in the
|
||||
* correct format
|
||||
* @jvms 4.3.2 Field Descriptors
|
||||
* @jvms 4.4.1 The CONSTANT_Class_info Structure
|
||||
*/
|
||||
static ClassDesc ofDescriptor(String descriptor) {
|
||||
requireNonNull(descriptor);
|
||||
int depth = ConstantUtils.arrayDepth(descriptor);
|
||||
if (depth > ConstantUtils.MAX_ARRAY_TYPE_DESC_DIMENSIONS) {
|
||||
throw new IllegalArgumentException(String.format("Cannot create an array type descriptor with more than %d dimensions",
|
||||
ConstantUtils.MAX_ARRAY_TYPE_DESC_DIMENSIONS));
|
||||
}
|
||||
return (descriptor.length() == 1)
|
||||
? new PrimitiveClassDescImpl(descriptor)
|
||||
: new ReferenceClassDescImpl(descriptor);
|
||||
|
@ -139,8 +145,15 @@ public interface ClassDesc
|
|||
* is described by this {@linkplain ClassDesc}.
|
||||
*
|
||||
* @return a {@linkplain ClassDesc} describing the array type
|
||||
* @throws IllegalStateException if the resulting {@linkplain ClassDesc} would have an array rank of greater than 255
|
||||
* @jvms 4.4.1 The CONSTANT_Class_info Structure
|
||||
*/
|
||||
default ClassDesc arrayType() {
|
||||
int depth = ConstantUtils.arrayDepth(descriptorString());
|
||||
if (depth >= ConstantUtils.MAX_ARRAY_TYPE_DESC_DIMENSIONS) {
|
||||
throw new IllegalStateException(String.format("Cannot create an array type descriptor with more than %d dimensions",
|
||||
ConstantUtils.MAX_ARRAY_TYPE_DESC_DIMENSIONS));
|
||||
}
|
||||
return arrayType(1);
|
||||
}
|
||||
|
||||
|
@ -150,11 +163,14 @@ public interface ClassDesc
|
|||
*
|
||||
* @param rank the rank of the array
|
||||
* @return a {@linkplain ClassDesc} describing the array type
|
||||
* @throws IllegalArgumentException if the rank is zero or negative
|
||||
* @throws IllegalArgumentException if the rank is less than zero or if the rank of the resulting array type is
|
||||
* greater than 255
|
||||
* @jvms 4.4.1 The CONSTANT_Class_info Structure
|
||||
*/
|
||||
default ClassDesc arrayType(int rank) {
|
||||
if (rank <= 0)
|
||||
throw new IllegalArgumentException("rank: " + rank);
|
||||
int currentDepth = ConstantUtils.arrayDepth(descriptorString());
|
||||
if (rank <= 0 || currentDepth + rank > ConstantUtils.MAX_ARRAY_TYPE_DESC_DIMENSIONS)
|
||||
throw new IllegalArgumentException("rank: " + currentDepth + rank);
|
||||
return ClassDesc.ofDescriptor("[".repeat(rank) + descriptorString());
|
||||
}
|
||||
|
||||
|
@ -162,6 +178,12 @@ public interface ClassDesc
|
|||
* Returns a {@linkplain ClassDesc} for a nested class of the class or
|
||||
* interface type described by this {@linkplain ClassDesc}.
|
||||
*
|
||||
* @apiNote
|
||||
*
|
||||
* Example: If descriptor {@code d} describes the class {@code java.util.Map}, a
|
||||
* descriptor for the class {@code java.util.Map.Entry} could be obtained
|
||||
* by {@code d.nested("Entry")}.
|
||||
*
|
||||
* @param nestedName the unqualified name of the nested class
|
||||
* @return a {@linkplain ClassDesc} describing the nested class
|
||||
* @throws NullPointerException if any argument is {@code null}
|
||||
|
|
|
@ -65,8 +65,9 @@ import java.util.Optional;
|
|||
*/
|
||||
public interface Constable {
|
||||
/**
|
||||
* Returns a nominal descriptor for this instance, if one can be
|
||||
* constructed, or an empty {@link Optional} if one cannot be constructed.
|
||||
* Returns an {@link Optional} containing the nominal descriptor for this
|
||||
* instance, if one can be constructed, or an empty {@link Optional}
|
||||
* if one cannot be constructed.
|
||||
*
|
||||
* @return An {@link Optional} containing the resulting nominal descriptor,
|
||||
* or an empty {@link Optional} if one cannot be constructed.
|
||||
|
|
|
@ -37,6 +37,7 @@ class ConstantUtils {
|
|||
/** an empty constant descriptor */
|
||||
public static final ConstantDesc[] EMPTY_CONSTANTDESC = new ConstantDesc[0];
|
||||
static final Constable[] EMPTY_CONSTABLE = new Constable[0];
|
||||
static final int MAX_ARRAY_TYPE_DESC_DIMENSIONS = 255;
|
||||
|
||||
private static final Set<String> pointyNames = Set.of("<init>", "<clinit>");
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
* storing the value in a constant pool entry, or reconstituting the value given
|
||||
* a class loading context. Every {@link java.lang.constant.ConstantDesc}
|
||||
* knows how to <em>resolve</em> itself -- compute the value that it describes --
|
||||
* via {@link java.lang.constant.ConstantDesc#resolveConstantDesc(java.lang.invoke.MethodHandles.Lookup)}.
|
||||
* via {@link java.lang.constant.ConstantDesc#resolveConstantDesc(java.lang.invoke.MethodHandles.Lookup) ConstantDesc.resolveConstantDesc}.
|
||||
* This allows an API which accepts {@link java.lang.constant.ConstantDesc}
|
||||
* objects to evaluate them reflectively, provided that the classes and methods
|
||||
* referenced in their nominal description are present and accessible.
|
||||
|
@ -68,7 +68,7 @@
|
|||
* When a bytecode-reading API encounters a constant pool entry, it can
|
||||
* convert it to the appropriate type of nominal descriptor. For dynamic
|
||||
* constants, bytecode-reading APIs may wish to use the factory
|
||||
* {@link java.lang.constant.DynamicConstantDesc#ofCanonical(DirectMethodHandleDesc, java.lang.String, ClassDesc, ConstantDesc[])},
|
||||
* {@link java.lang.constant.DynamicConstantDesc#ofCanonical(DirectMethodHandleDesc, java.lang.String, ClassDesc, ConstantDesc[]) DynamicConstantDesc.ofCanonical},
|
||||
* which will inspect the bootstrap and, for well-known bootstraps, return
|
||||
* a more specific subtype of {@link java.lang.constant.DynamicConstantDesc}, such as
|
||||
* {@link java.lang.Enum.EnumDesc}.
|
||||
|
|
|
@ -103,7 +103,7 @@ public final class ConstantBootstraps {
|
|||
if (type != Class.class) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
if (name.length() == 0 || name.length() > 1) {
|
||||
if (name.length() != 1) {
|
||||
throw new IllegalArgumentException(String.format("not primitive: %s", name));
|
||||
}
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ public class MethodHandles {
|
|||
throw new IllegalAccessException(callerModule + " does not read " + targetModule);
|
||||
if (targetModule.isNamed()) {
|
||||
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))
|
||||
throw new IllegalAccessException(targetModule + " does not open " + pn + " to " + callerModule);
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ final class ProxyClassesDumper {
|
|||
}
|
||||
try {
|
||||
path = path.trim();
|
||||
final Path dir = Path.of(path.length() == 0 ? "." : path);
|
||||
final Path dir = Path.of(path.isEmpty() ? "." : path);
|
||||
AccessController.doPrivileged(new PrivilegedAction<>() {
|
||||
@Override
|
||||
public Void run() {
|
||||
|
|
|
@ -61,7 +61,8 @@ public interface TypeDescriptor {
|
|||
boolean isArray();
|
||||
|
||||
/**
|
||||
* Does this field descriptor describe a primitive type?
|
||||
* Does this field descriptor describe a primitive type (including void.)
|
||||
*
|
||||
* @return whether this field descriptor describes a primitive type
|
||||
*/
|
||||
boolean isPrimitive();
|
||||
|
|
|
@ -1864,6 +1864,16 @@ public abstract class VarHandle implements Constable {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare this {@linkplain VarHandle} with another object for equality.
|
||||
* Two {@linkplain VarHandle}s are considered equal if they both describe the
|
||||
* same instance field, both describe the same static field, both describe
|
||||
* array elements for arrays with the same component type, or both describe
|
||||
* the same component of an off-heap structure.
|
||||
*
|
||||
* @param o the other object
|
||||
* @return Whether this {@linkplain VarHandle} is equal to the other object
|
||||
*/
|
||||
@Override
|
||||
public final boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
@ -1883,6 +1893,12 @@ public abstract class VarHandle implements Constable {
|
|||
|
||||
abstract int internalHashCode();
|
||||
|
||||
/**
|
||||
* Returns a compact textual description of this {@linkplain VarHandle},
|
||||
* including the type of variable described, and a description of its coordinates.
|
||||
*
|
||||
* @return A compact textual description of this {@linkplain VarHandle}
|
||||
*/
|
||||
@Override
|
||||
public final String toString() {
|
||||
return String.format("VarHandle[varType=%s, coord=%s]",
|
||||
|
@ -2272,6 +2288,14 @@ public abstract class VarHandle implements Constable {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a compact textual description of this constant description.
|
||||
* For a field {@linkplain VarHandle}, includes the owner, name, and type
|
||||
* of the field, and whether it is static; for an array {@linkplain VarHandle},
|
||||
* the name of the component type.
|
||||
*
|
||||
* @return A compact textual description of this descriptor
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
switch (kind) {
|
||||
|
|
|
@ -2871,6 +2871,8 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
|||
* @throws ArithmeticException if scale overflows.
|
||||
*/
|
||||
public BigDecimal movePointLeft(int n) {
|
||||
if (n == 0) return this;
|
||||
|
||||
// Cannot use movePointRight(-n) in case of n==Integer.MIN_VALUE
|
||||
int newScale = checkScale((long)scale + n);
|
||||
BigDecimal num = new BigDecimal(intVal, intCompact, newScale, 0);
|
||||
|
@ -2893,6 +2895,8 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
|||
* @throws ArithmeticException if scale overflows.
|
||||
*/
|
||||
public BigDecimal movePointRight(int n) {
|
||||
if (n == 0) return this;
|
||||
|
||||
// Cannot use movePointLeft(-n) in case of n==Integer.MIN_VALUE
|
||||
int newScale = checkScale((long)scale - n);
|
||||
BigDecimal num = new BigDecimal(intVal, intCompact, newScale, 0);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -102,7 +102,7 @@ class DatagramPacket {
|
|||
|
||||
/**
|
||||
* Constructs a datagram packet for sending packets of length
|
||||
* {@code length} with offset {@code ioffset}to the
|
||||
* {@code length} with offset {@code offset} to the
|
||||
* specified port number on the specified host. The
|
||||
* {@code length} argument must be less than or equal to
|
||||
* {@code buf.length}.
|
||||
|
@ -125,7 +125,7 @@ class DatagramPacket {
|
|||
|
||||
/**
|
||||
* Constructs a datagram packet for sending packets of length
|
||||
* {@code length} with offset {@code ioffset}to the
|
||||
* {@code length} with offset {@code offset} to the
|
||||
* specified port number on the specified host. The
|
||||
* {@code length} argument must be less than or equal to
|
||||
* {@code buf.length}.
|
||||
|
|
|
@ -149,7 +149,7 @@ public final class HttpCookie implements Cloneable {
|
|||
*/
|
||||
HttpCookie(String name, String value, String header, long creationTime) {
|
||||
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");
|
||||
}
|
||||
|
||||
|
|
|
@ -433,7 +433,7 @@ class Inet6Address extends InetAddress {
|
|||
NetworkInterface nif)
|
||||
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) == ']') {
|
||||
host = host.substring(1, host.length() -1);
|
||||
}
|
||||
|
@ -466,7 +466,7 @@ class Inet6Address extends InetAddress {
|
|||
int scope_id)
|
||||
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) == ']') {
|
||||
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);
|
||||
String ifname = (String)gf.get("ifname", null);
|
||||
|
||||
if (ifname != null && !"".equals (ifname)) {
|
||||
if (ifname != null && !ifname.isEmpty()) {
|
||||
try {
|
||||
scope_ifname = NetworkInterface.getByName(ifname);
|
||||
if (scope_ifname == null) {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -531,7 +531,7 @@ class InetAddress implements java.io.Serializable {
|
|||
* @param timeout the time, in milliseconds, before the call aborts
|
||||
* @throws IllegalArgumentException if either {@code timeout}
|
||||
* or {@code ttl} are negative.
|
||||
* @return a {@code boolean}indicating if the address is reachable.
|
||||
* @return a {@code boolean} indicating if the address is reachable.
|
||||
* @throws IOException if a network error occurs
|
||||
* @since 1.5
|
||||
*/
|
||||
|
@ -1187,7 +1187,7 @@ class InetAddress implements java.io.Serializable {
|
|||
*/
|
||||
public static InetAddress getByAddress(String host, byte[] addr)
|
||||
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) == ']') {
|
||||
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)
|
||||
throws UnknownHostException {
|
||||
|
||||
if (host == null || host.length() == 0) {
|
||||
if (host == null || host.isEmpty()) {
|
||||
InetAddress[] ret = new InetAddress[1];
|
||||
ret[0] = impl.loopbackAddress();
|
||||
return ret;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1995, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -1102,7 +1102,7 @@ class Socket implements java.io.Closeable {
|
|||
* Tests if {@link SocketOptions#SO_OOBINLINE SO_OOBINLINE} is enabled.
|
||||
*
|
||||
* @return a {@code boolean} indicating whether or not
|
||||
* {@link SocketOptions#SO_OOBINLINE SO_OOBINLINE}is enabled.
|
||||
* {@link SocketOptions#SO_OOBINLINE SO_OOBINLINE} is enabled.
|
||||
*
|
||||
* @exception SocketException if there is an error
|
||||
* in the underlying protocol, such as a TCP error.
|
||||
|
|
|
@ -460,7 +460,7 @@ public final class SocketPermission extends Permission
|
|||
}
|
||||
return;
|
||||
} else {
|
||||
if (host.length() > 0) {
|
||||
if (!host.isEmpty()) {
|
||||
// see if we are being initialized with an IP address.
|
||||
char ch = host.charAt(0);
|
||||
if (ch == ':' || Character.digit(ch, 16) != -1) {
|
||||
|
@ -705,8 +705,7 @@ public final class SocketPermission extends Permission
|
|||
.orElse(b);
|
||||
}
|
||||
|
||||
return cdomain.length() != 0 && hdomain.length() != 0
|
||||
&& cdomain.equals(hdomain);
|
||||
return !cdomain.isEmpty() && !hdomain.isEmpty() && cdomain.equals(hdomain);
|
||||
}
|
||||
|
||||
private boolean authorized(String cname, byte[] addr) {
|
||||
|
|
|
@ -1959,10 +1959,8 @@ public final class URI
|
|||
throws URISyntaxException
|
||||
{
|
||||
if (scheme != null) {
|
||||
if ((path != null)
|
||||
&& ((path.length() > 0) && (path.charAt(0) != '/')))
|
||||
throw new URISyntaxException(s,
|
||||
"Relative path in absolute URI");
|
||||
if (path != null && !path.isEmpty() && path.charAt(0) != '/')
|
||||
throw new URISyntaxException(s, "Relative path in absolute URI");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2163,7 +2161,7 @@ public final class URI
|
|||
ru.port = base.port;
|
||||
|
||||
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
|
||||
ru.path = child.path;
|
||||
} else {
|
||||
|
@ -2187,7 +2185,7 @@ public final class URI
|
|||
// o.w., return a new URI containing the normalized path.
|
||||
//
|
||||
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;
|
||||
|
||||
String np = normalize(u.path);
|
||||
|
|
|
@ -304,7 +304,7 @@ public final class URL implements java.io.Serializable {
|
|||
* or all providers have been exhausted.
|
||||
* <li>If the previous step fails to find a protocol handler, the
|
||||
* constructor reads the value of the system property:
|
||||
* <blockquote>{@code
|
||||
* <blockquote>{@systemProperty
|
||||
* java.protocol.handler.pkgs
|
||||
* }</blockquote>
|
||||
* If the value of that system property is not {@code null},
|
||||
|
@ -1220,16 +1220,22 @@ public final class URL implements java.io.Serializable {
|
|||
private static final URLStreamHandlerFactory defaultFactory = new DefaultFactory();
|
||||
|
||||
private static class DefaultFactory implements URLStreamHandlerFactory {
|
||||
private static String PREFIX = "sun.net.www.protocol";
|
||||
private static String PREFIX = "sun.net.www.protocol.";
|
||||
|
||||
public URLStreamHandler createURLStreamHandler(String protocol) {
|
||||
String name = PREFIX + "." + protocol + ".Handler";
|
||||
// Avoid using reflection during bootstrap
|
||||
switch (protocol) {
|
||||
case "file":
|
||||
return new sun.net.www.protocol.file.Handler();
|
||||
case "jar":
|
||||
return new sun.net.www.protocol.jar.Handler();
|
||||
case "jrt":
|
||||
return new sun.net.www.protocol.jrt.Handler();
|
||||
}
|
||||
String name = PREFIX + protocol + ".Handler";
|
||||
try {
|
||||
@SuppressWarnings("deprecation")
|
||||
Object o = Class.forName(name).newInstance();
|
||||
Object o = Class.forName(name).getDeclaredConstructor().newInstance();
|
||||
return (URLStreamHandler)o;
|
||||
} catch (ClassNotFoundException x) {
|
||||
// ignore
|
||||
} catch (Exception e) {
|
||||
// For compatibility, all Exceptions are ignored.
|
||||
// any number of exceptions can get thrown here
|
||||
|
@ -1513,7 +1519,7 @@ public final class URL implements java.io.Serializable {
|
|||
String ref = (String)gf.get("ref", null);
|
||||
int hashCode = gf.get("hashCode", -1);
|
||||
if (authority == null
|
||||
&& ((host != null && host.length() > 0) || port != -1)) {
|
||||
&& ((host != null && !host.isEmpty()) || port != -1)) {
|
||||
if (host == null)
|
||||
host = "";
|
||||
authority = (port == -1) ? host : host + ":" + port;
|
||||
|
@ -1560,7 +1566,7 @@ public final class URL implements java.io.Serializable {
|
|||
|
||||
// Construct authority part
|
||||
if (authority == null
|
||||
&& ((host != null && host.length() > 0) || port != -1)) {
|
||||
&& ((host != null && !host.isEmpty()) || port != -1)) {
|
||||
if (host == null)
|
||||
host = "";
|
||||
authority = (port == -1) ? host : host + ":" + port;
|
||||
|
@ -1716,7 +1722,7 @@ final class UrlDeserializedState {
|
|||
|
||||
// pre-compute length of StringBuffer
|
||||
int len = protocol.length() + 1;
|
||||
if (authority != null && authority.length() > 0)
|
||||
if (authority != null && !authority.isEmpty())
|
||||
len += 2 + authority.length();
|
||||
if (file != null) {
|
||||
len += file.length();
|
||||
|
@ -1726,7 +1732,7 @@ final class UrlDeserializedState {
|
|||
StringBuilder result = new StringBuilder(len);
|
||||
result.append(protocol);
|
||||
result.append(":");
|
||||
if (authority != null && authority.length() > 0) {
|
||||
if (authority != null && !authority.isEmpty()) {
|
||||
result.append("//");
|
||||
result.append(authority);
|
||||
}
|
||||
|
|
|
@ -743,7 +743,7 @@ public class URLClassLoader extends SecureClassLoader implements Closeable {
|
|||
locUrl = ((JarURLConnection)urlConnection).getJarFileURL();
|
||||
}
|
||||
String host = locUrl.getHost();
|
||||
if (host != null && (host.length() > 0))
|
||||
if (host != null && !host.isEmpty())
|
||||
p = new SocketPermission(host,
|
||||
SecurityConstants.SOCKET_CONNECT_ACCEPT_ACTION);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1995, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -681,7 +681,7 @@ public abstract class URLConnection {
|
|||
/**
|
||||
* Returns the value for the {@code n}<sup>th</sup> header field.
|
||||
* It returns {@code null} if there are fewer than
|
||||
* {@code n+1}fields.
|
||||
* {@code n+1} fields.
|
||||
* <p>
|
||||
* This method can be used in conjunction with the
|
||||
* {@link #getHeaderFieldKey(int) getHeaderFieldKey} method to iterate through all
|
||||
|
|
|
@ -133,7 +133,7 @@ public class URLDecoder {
|
|||
* @since 1.4
|
||||
*/
|
||||
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");
|
||||
}
|
||||
|
||||
|
|
|
@ -409,7 +409,7 @@ public final class URLPermission extends Permission {
|
|||
char c = methods.charAt(i);
|
||||
if (c == ',') {
|
||||
String s = b.toString();
|
||||
if (s.length() > 0)
|
||||
if (!s.isEmpty())
|
||||
l.add(s);
|
||||
b = new StringBuilder();
|
||||
} else if (c == ' ' || c == '\t') {
|
||||
|
@ -423,7 +423,7 @@ public final class URLPermission extends Permission {
|
|||
}
|
||||
}
|
||||
String s = b.toString();
|
||||
if (s.length() > 0)
|
||||
if (!s.isEmpty())
|
||||
l.add(s);
|
||||
return l;
|
||||
}
|
||||
|
@ -448,7 +448,7 @@ public final class URLPermission extends Permission {
|
|||
b.append(c);
|
||||
} else if (c == ',') {
|
||||
String s = b.toString();
|
||||
if (s.length() > 0)
|
||||
if (!s.isEmpty())
|
||||
l.add(s);
|
||||
b = new StringBuilder();
|
||||
capitalizeNext = true;
|
||||
|
@ -458,7 +458,7 @@ public final class URLPermission extends Permission {
|
|||
}
|
||||
}
|
||||
String s = b.toString();
|
||||
if (s.length() > 0)
|
||||
if (!s.isEmpty())
|
||||
l.add(s);
|
||||
return l;
|
||||
}
|
||||
|
|
|
@ -235,7 +235,7 @@ public abstract class URLStreamHandler {
|
|||
start = i;
|
||||
// If the authority is defined then the path is defined by the
|
||||
// spec only; See RFC 2396 Section 5.2.4.
|
||||
if (authority != null && authority.length() > 0)
|
||||
if (authority != null && !authority.isEmpty())
|
||||
path = "";
|
||||
}
|
||||
|
||||
|
@ -247,7 +247,7 @@ public abstract class URLStreamHandler {
|
|||
if (start < limit) {
|
||||
if (spec.charAt(start) == '/') {
|
||||
path = spec.substring(start, limit);
|
||||
} else if (path != null && path.length() > 0) {
|
||||
} else if (path != null && !path.isEmpty()) {
|
||||
isRelPath = true;
|
||||
int ind = path.lastIndexOf('/');
|
||||
String separator = "";
|
||||
|
@ -483,11 +483,11 @@ public abstract class URLStreamHandler {
|
|||
String s;
|
||||
return u.getProtocol()
|
||||
+ ':'
|
||||
+ (((s = u.getAuthority()) != null && s.length() > 0)
|
||||
+ ((s = u.getAuthority()) != null && !s.isEmpty()
|
||||
? "//" + s : "")
|
||||
+ (((s = u.getPath()) != null) ? s : "")
|
||||
+ (((s = u.getQuery()) != null) ? '?' + s : "")
|
||||
+ (((s = u.getRef()) != null) ? '#' + s : "");
|
||||
+ ((s = u.getPath()) != null ? s : "")
|
||||
+ ((s = u.getQuery()) != null ? '?' + s : "")
|
||||
+ ((s = u.getRef()) != null ? '#' + s : "");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -544,7 +544,7 @@ public abstract class URLStreamHandler {
|
|||
*/
|
||||
String authority = null;
|
||||
String userInfo = null;
|
||||
if (host != null && host.length() != 0) {
|
||||
if (host != null && !host.isEmpty()) {
|
||||
authority = (port == -1) ? host : host + ":" + port;
|
||||
int at = host.lastIndexOf('@');
|
||||
if (at != -1) {
|
||||
|
|
|
@ -104,7 +104,7 @@ public final class LinkPermission extends BasicPermission {
|
|||
public LinkPermission(String name, String actions) {
|
||||
super(name);
|
||||
checkName(name);
|
||||
if (actions != null && actions.length() > 0) {
|
||||
if (actions != null && !actions.isEmpty()) {
|
||||
throw new IllegalArgumentException("actions: " + actions);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -709,6 +709,13 @@ public final class AccessController {
|
|||
return context;
|
||||
}
|
||||
|
||||
/**
|
||||
* The value needs to be physically located in the frame, so that it
|
||||
* can be found by a stack walk.
|
||||
*/
|
||||
@Hidden
|
||||
private static native void ensureMaterializedForStackWalk(Object o);
|
||||
|
||||
/**
|
||||
* Sanity check that the caller context is indeed privileged.
|
||||
*
|
||||
|
@ -734,6 +741,11 @@ public final class AccessController {
|
|||
AccessControlContext context,
|
||||
Class<?> caller)
|
||||
{
|
||||
// Ensure context has a physical value in the frame
|
||||
if (context != null) {
|
||||
ensureMaterializedForStackWalk(context);
|
||||
}
|
||||
|
||||
assert isPrivileged(); // sanity check invariant
|
||||
T result = action.run();
|
||||
assert isPrivileged(); // sanity check invariant
|
||||
|
@ -742,7 +754,6 @@ public final class AccessController {
|
|||
// retrieved by getStackAccessControlContext().
|
||||
Reference.reachabilityFence(context);
|
||||
Reference.reachabilityFence(caller);
|
||||
Reference.reachabilityFence(action);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -761,6 +772,11 @@ public final class AccessController {
|
|||
Class<?> caller)
|
||||
throws Exception
|
||||
{
|
||||
// Ensure context has a physical value in the frame
|
||||
if (context != null) {
|
||||
ensureMaterializedForStackWalk(context);
|
||||
}
|
||||
|
||||
assert isPrivileged(); // sanity check invariant
|
||||
T result = action.run();
|
||||
assert isPrivileged(); // sanity check invariant
|
||||
|
@ -769,7 +785,6 @@ public final class AccessController {
|
|||
// retrieved by getStackAccessControlContext().
|
||||
Reference.reachabilityFence(context);
|
||||
Reference.reachabilityFence(caller);
|
||||
Reference.reachabilityFence(action);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
|
@ -228,7 +228,7 @@ public class AlgorithmParameterGenerator {
|
|||
throws NoSuchAlgorithmException, NoSuchProviderException
|
||||
{
|
||||
Objects.requireNonNull(algorithm, "null algorithm name");
|
||||
if (provider == null || provider.length() == 0)
|
||||
if (provider == null || provider.isEmpty())
|
||||
throw new IllegalArgumentException("missing provider");
|
||||
Object[] objs = Security.getImpl(algorithm,
|
||||
"AlgorithmParameterGenerator",
|
||||
|
|
|
@ -209,7 +209,7 @@ public class AlgorithmParameters {
|
|||
throws NoSuchAlgorithmException, NoSuchProviderException
|
||||
{
|
||||
Objects.requireNonNull(algorithm, "null algorithm name");
|
||||
if (provider == null || provider.length() == 0)
|
||||
if (provider == null || provider.isEmpty())
|
||||
throw new IllegalArgumentException("missing provider");
|
||||
Object[] objs = Security.getImpl(algorithm, "AlgorithmParameters",
|
||||
provider);
|
||||
|
|
|
@ -314,14 +314,7 @@ public class KeyStore {
|
|||
/**
|
||||
* Gets the name of the protection algorithm.
|
||||
* If none was set then the keystore provider will use its default
|
||||
* protection algorithm. The name of the default protection algorithm
|
||||
* for a given keystore type is set using the
|
||||
* {@code 'keystore.<type>.keyProtectionAlgorithm'} security property.
|
||||
* For example, the
|
||||
* {@code keystore.PKCS12.keyProtectionAlgorithm} property stores the
|
||||
* name of the default key protection algorithm used for PKCS12
|
||||
* keystores. If the security property is not set, an
|
||||
* implementation-specific algorithm will be used.
|
||||
* protection algorithm.
|
||||
*
|
||||
* @return the algorithm name, or {@code null} if none was set
|
||||
*
|
||||
|
@ -920,7 +913,7 @@ public class KeyStore {
|
|||
throws KeyStoreException, NoSuchProviderException
|
||||
{
|
||||
Objects.requireNonNull(type, "null type name");
|
||||
if (provider == null || provider.length() == 0)
|
||||
if (provider == null || provider.isEmpty())
|
||||
throw new IllegalArgumentException("missing provider");
|
||||
try {
|
||||
Object[] objs = Security.getImpl(type, "KeyStore", provider);
|
||||
|
@ -1813,8 +1806,8 @@ public class KeyStore {
|
|||
}
|
||||
}
|
||||
|
||||
throw new KeyStoreException("This keystore does not support probing "
|
||||
+ "and must be loaded with a specified type");
|
||||
throw new KeyStoreException("Unrecognized keystore format. "
|
||||
+ "Please load it with a specified type");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -237,7 +237,7 @@ public abstract class MessageDigest extends MessageDigestSpi {
|
|||
throws NoSuchAlgorithmException, NoSuchProviderException
|
||||
{
|
||||
Objects.requireNonNull(algorithm, "null algorithm name");
|
||||
if (provider == null || provider.length() == 0)
|
||||
if (provider == null || provider.isEmpty())
|
||||
throw new IllegalArgumentException("missing provider");
|
||||
Object[] objs = Security.getImpl(algorithm, "MessageDigest", provider);
|
||||
if (objs[0] instanceof MessageDigest) {
|
||||
|
|
|
@ -222,7 +222,7 @@ public abstract class Permission implements Guard, java.io.Serializable {
|
|||
*/
|
||||
public String toString() {
|
||||
String actions = getActions();
|
||||
if ((actions == null) || (actions.length() == 0)) { // OPTIONAL
|
||||
if (actions == null || actions.isEmpty()) { // OPTIONAL
|
||||
return "(\"" + getClass().getName() + "\" \"" + name + "\")";
|
||||
} else {
|
||||
return "(\"" + getClass().getName() + "\" \"" + name +
|
||||
|
|
|
@ -456,7 +456,7 @@ public abstract class Policy {
|
|||
throws NoSuchProviderException, NoSuchAlgorithmException {
|
||||
|
||||
Objects.requireNonNull(type, "null type name");
|
||||
if (provider == null || provider.length() == 0) {
|
||||
if (provider == null || provider.isEmpty()) {
|
||||
throw new IllegalArgumentException("missing provider");
|
||||
}
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@ import java.lang.reflect.*;
|
|||
import java.util.function.BiConsumer;
|
||||
import java.util.function.BiFunction;
|
||||
import java.util.function.Function;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* This class represents a "provider" for the
|
||||
|
@ -225,6 +226,7 @@ public abstract class Provider extends Properties {
|
|||
this.version = version;
|
||||
this.versionStr = Double.toString(version);
|
||||
this.info = info;
|
||||
this.serviceMap = new ConcurrentHashMap<>();
|
||||
putId();
|
||||
initialized = true;
|
||||
}
|
||||
|
@ -262,6 +264,7 @@ public abstract class Provider extends Properties {
|
|||
this.versionStr = versionStr;
|
||||
this.version = parseVersionStr(versionStr);
|
||||
this.info = info;
|
||||
this.serviceMap = new ConcurrentHashMap<>();
|
||||
putId();
|
||||
initialized = true;
|
||||
}
|
||||
|
@ -852,10 +855,7 @@ public abstract class Provider extends Properties {
|
|||
// legacy properties changed since last call to any services method?
|
||||
private transient boolean legacyChanged;
|
||||
// serviceMap changed since last call to getServices()
|
||||
private transient boolean servicesChanged;
|
||||
|
||||
// Map<String,String>
|
||||
private transient Map<String,String> legacyStrings;
|
||||
private volatile transient boolean servicesChanged;
|
||||
|
||||
// Map<ServiceKey,Service>
|
||||
// used for services added via putService(), initialized on demand
|
||||
|
@ -905,22 +905,18 @@ public abstract class Provider extends Properties {
|
|||
// otherwise, set version based on versionStr
|
||||
this.version = parseVersionStr(this.versionStr);
|
||||
}
|
||||
this.serviceMap = new ConcurrentHashMap<>();
|
||||
implClear();
|
||||
initialized = true;
|
||||
putAll(copy);
|
||||
}
|
||||
|
||||
private boolean checkLegacy(Object key) {
|
||||
private static boolean isProviderInfo(Object key) {
|
||||
String keyString = (String)key;
|
||||
if (keyString.startsWith("Provider.")) {
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
legacyChanged = true;
|
||||
if (legacyStrings == null) {
|
||||
legacyStrings = new LinkedHashMap<>();
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -936,20 +932,20 @@ public abstract class Provider extends Properties {
|
|||
|
||||
private Object implRemove(Object key) {
|
||||
if (key instanceof String) {
|
||||
if (!checkLegacy(key)) {
|
||||
if (isProviderInfo(key)) {
|
||||
return null;
|
||||
}
|
||||
legacyStrings.remove((String)key);
|
||||
legacyChanged = true;
|
||||
}
|
||||
return super.remove(key);
|
||||
}
|
||||
|
||||
private boolean implRemove(Object key, Object value) {
|
||||
if (key instanceof String && value instanceof String) {
|
||||
if (!checkLegacy(key)) {
|
||||
if (isProviderInfo(key)) {
|
||||
return false;
|
||||
}
|
||||
legacyStrings.remove((String)key, value);
|
||||
legacyChanged = true;
|
||||
}
|
||||
return super.remove(key, value);
|
||||
}
|
||||
|
@ -957,21 +953,20 @@ public abstract class Provider extends Properties {
|
|||
private boolean implReplace(Object key, Object oldValue, Object newValue) {
|
||||
if ((key instanceof String) && (oldValue instanceof String) &&
|
||||
(newValue instanceof String)) {
|
||||
if (!checkLegacy(key)) {
|
||||
if (isProviderInfo(key)) {
|
||||
return false;
|
||||
}
|
||||
legacyStrings.replace((String)key, (String)oldValue,
|
||||
(String)newValue);
|
||||
legacyChanged = true;
|
||||
}
|
||||
return super.replace(key, oldValue, newValue);
|
||||
}
|
||||
|
||||
private Object implReplace(Object key, Object value) {
|
||||
if ((key instanceof String) && (value instanceof String)) {
|
||||
if (!checkLegacy(key)) {
|
||||
if (isProviderInfo(key)) {
|
||||
return null;
|
||||
}
|
||||
legacyStrings.replace((String)key, (String)value);
|
||||
legacyChanged = true;
|
||||
}
|
||||
return super.replace(key, value);
|
||||
}
|
||||
|
@ -980,12 +975,6 @@ public abstract class Provider extends Properties {
|
|||
private void implReplaceAll(BiFunction<? super Object, ? super Object,
|
||||
? extends Object> function) {
|
||||
legacyChanged = true;
|
||||
if (legacyStrings == null) {
|
||||
legacyStrings = new LinkedHashMap<>();
|
||||
} else {
|
||||
legacyStrings.replaceAll((BiFunction<? super String, ? super String,
|
||||
? extends String>) function);
|
||||
}
|
||||
super.replaceAll(function);
|
||||
}
|
||||
|
||||
|
@ -993,11 +982,10 @@ public abstract class Provider extends Properties {
|
|||
private Object implMerge(Object key, Object value, BiFunction<? super Object,
|
||||
? super Object, ? extends Object> remappingFunction) {
|
||||
if ((key instanceof String) && (value instanceof String)) {
|
||||
if (!checkLegacy(key)) {
|
||||
if (isProviderInfo(key)) {
|
||||
return null;
|
||||
}
|
||||
legacyStrings.merge((String)key, (String)value,
|
||||
(BiFunction<? super String, ? super String, ? extends String>) remappingFunction);
|
||||
legacyChanged = true;
|
||||
}
|
||||
return super.merge(key, value, remappingFunction);
|
||||
}
|
||||
|
@ -1006,11 +994,10 @@ public abstract class Provider extends Properties {
|
|||
private Object implCompute(Object key, BiFunction<? super Object,
|
||||
? super Object, ? extends Object> remappingFunction) {
|
||||
if (key instanceof String) {
|
||||
if (!checkLegacy(key)) {
|
||||
if (isProviderInfo(key)) {
|
||||
return null;
|
||||
}
|
||||
legacyStrings.compute((String) key,
|
||||
(BiFunction<? super String,? super String, ? extends String>) remappingFunction);
|
||||
legacyChanged = true;
|
||||
}
|
||||
return super.compute(key, remappingFunction);
|
||||
}
|
||||
|
@ -1019,11 +1006,10 @@ public abstract class Provider extends Properties {
|
|||
private Object implComputeIfAbsent(Object key, Function<? super Object,
|
||||
? extends Object> mappingFunction) {
|
||||
if (key instanceof String) {
|
||||
if (!checkLegacy(key)) {
|
||||
if (isProviderInfo(key)) {
|
||||
return null;
|
||||
}
|
||||
legacyStrings.computeIfAbsent((String) key,
|
||||
(Function<? super String, ? extends String>) mappingFunction);
|
||||
legacyChanged = true;
|
||||
}
|
||||
return super.computeIfAbsent(key, mappingFunction);
|
||||
}
|
||||
|
@ -1032,45 +1018,39 @@ public abstract class Provider extends Properties {
|
|||
private Object implComputeIfPresent(Object key, BiFunction<? super Object,
|
||||
? super Object, ? extends Object> remappingFunction) {
|
||||
if (key instanceof String) {
|
||||
if (!checkLegacy(key)) {
|
||||
if (isProviderInfo(key)) {
|
||||
return null;
|
||||
}
|
||||
legacyStrings.computeIfPresent((String) key,
|
||||
(BiFunction<? super String, ? super String, ? extends String>) remappingFunction);
|
||||
legacyChanged = true;
|
||||
}
|
||||
return super.computeIfPresent(key, remappingFunction);
|
||||
}
|
||||
|
||||
private Object implPut(Object key, Object value) {
|
||||
if ((key instanceof String) && (value instanceof String)) {
|
||||
if (!checkLegacy(key)) {
|
||||
if (isProviderInfo(key)) {
|
||||
return null;
|
||||
}
|
||||
legacyStrings.put((String)key, (String)value);
|
||||
legacyChanged = true;
|
||||
}
|
||||
return super.put(key, value);
|
||||
}
|
||||
|
||||
private Object implPutIfAbsent(Object key, Object value) {
|
||||
if ((key instanceof String) && (value instanceof String)) {
|
||||
if (!checkLegacy(key)) {
|
||||
if (isProviderInfo(key)) {
|
||||
return null;
|
||||
}
|
||||
legacyStrings.putIfAbsent((String)key, (String)value);
|
||||
legacyChanged = true;
|
||||
}
|
||||
return super.putIfAbsent(key, value);
|
||||
}
|
||||
|
||||
private void implClear() {
|
||||
if (legacyStrings != null) {
|
||||
legacyStrings.clear();
|
||||
}
|
||||
if (legacyMap != null) {
|
||||
legacyMap.clear();
|
||||
}
|
||||
if (serviceMap != null) {
|
||||
serviceMap.clear();
|
||||
}
|
||||
serviceMap.clear();
|
||||
legacyChanged = false;
|
||||
servicesChanged = false;
|
||||
serviceSet = null;
|
||||
|
@ -1090,13 +1070,13 @@ public abstract class Provider extends Properties {
|
|||
this.algorithm = intern ? algorithm.intern() : algorithm;
|
||||
}
|
||||
public int hashCode() {
|
||||
return type.hashCode() + algorithm.hashCode();
|
||||
return Objects.hash(type, algorithm);
|
||||
}
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof ServiceKey == false) {
|
||||
if (!(obj instanceof ServiceKey)) {
|
||||
return false;
|
||||
}
|
||||
ServiceKey other = (ServiceKey)obj;
|
||||
|
@ -1113,16 +1093,16 @@ public abstract class Provider extends Properties {
|
|||
* service objects.
|
||||
*/
|
||||
private void ensureLegacyParsed() {
|
||||
if ((legacyChanged == false) || (legacyStrings == null)) {
|
||||
if (legacyChanged == false) {
|
||||
return;
|
||||
}
|
||||
serviceSet = null;
|
||||
if (legacyMap == null) {
|
||||
legacyMap = new LinkedHashMap<>();
|
||||
legacyMap = new ConcurrentHashMap<>();
|
||||
} else {
|
||||
legacyMap.clear();
|
||||
}
|
||||
for (Map.Entry<String,String> entry : legacyStrings.entrySet()) {
|
||||
for (Map.Entry<?,?> entry : super.entrySet()) {
|
||||
parseLegacyPut(entry.getKey(), entry.getValue());
|
||||
}
|
||||
removeInvalidServices(legacyMap);
|
||||
|
@ -1161,7 +1141,15 @@ public abstract class Provider extends Properties {
|
|||
private static final String ALIAS_PREFIX_LOWER = "alg.alias.";
|
||||
private static final int ALIAS_LENGTH = ALIAS_PREFIX.length();
|
||||
|
||||
private void parseLegacyPut(String name, String value) {
|
||||
private void parseLegacyPut(Object k, Object v) {
|
||||
if (!(k instanceof String) || !(v instanceof String)) {
|
||||
return;
|
||||
}
|
||||
String name = (String) k;
|
||||
String value = (String) v;
|
||||
if (isProviderInfo(name)) {
|
||||
return;
|
||||
}
|
||||
if (name.toLowerCase(ENGLISH).startsWith(ALIAS_PREFIX_LOWER)) {
|
||||
// e.g. put("Alg.Alias.MessageDigest.SHA", "SHA-1");
|
||||
// aliasKey ~ MessageDigest.SHA
|
||||
|
@ -1248,22 +1236,28 @@ public abstract class Provider extends Properties {
|
|||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public synchronized Service getService(String type, String algorithm) {
|
||||
public Service getService(String type, String algorithm) {
|
||||
checkInitialized();
|
||||
// avoid allocating a new key object if possible
|
||||
|
||||
// avoid allocating a new ServiceKey object if possible
|
||||
ServiceKey key = previousKey;
|
||||
if (key.matches(type, algorithm) == false) {
|
||||
key = new ServiceKey(type, algorithm, false);
|
||||
previousKey = key;
|
||||
}
|
||||
if (serviceMap != null) {
|
||||
Service service = serviceMap.get(key);
|
||||
if (service != null) {
|
||||
return service;
|
||||
if (!serviceMap.isEmpty()) {
|
||||
Service s = serviceMap.get(key);
|
||||
if (s != null) {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
ensureLegacyParsed();
|
||||
return (legacyMap != null) ? legacyMap.get(key) : null;
|
||||
synchronized (this) {
|
||||
ensureLegacyParsed();
|
||||
}
|
||||
if (legacyMap != null && !legacyMap.isEmpty()) {
|
||||
return legacyMap.get(key);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// ServiceKey from previous getService() call
|
||||
|
@ -1292,10 +1286,10 @@ public abstract class Provider extends Properties {
|
|||
if (serviceSet == null) {
|
||||
ensureLegacyParsed();
|
||||
Set<Service> set = new LinkedHashSet<>();
|
||||
if (serviceMap != null) {
|
||||
if (!serviceMap.isEmpty()) {
|
||||
set.addAll(serviceMap.values());
|
||||
}
|
||||
if (legacyMap != null) {
|
||||
if (legacyMap != null && !legacyMap.isEmpty()) {
|
||||
set.addAll(legacyMap.values());
|
||||
}
|
||||
serviceSet = Collections.unmodifiableSet(set);
|
||||
|
@ -1333,7 +1327,7 @@ public abstract class Provider extends Properties {
|
|||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
protected synchronized void putService(Service s) {
|
||||
protected void putService(Service s) {
|
||||
check("putProviderProperty." + name);
|
||||
if (debug != null) {
|
||||
debug.println(name + ".putService(): " + s);
|
||||
|
@ -1345,20 +1339,18 @@ public abstract class Provider extends Properties {
|
|||
throw new IllegalArgumentException
|
||||
("service.getProvider() must match this Provider object");
|
||||
}
|
||||
if (serviceMap == null) {
|
||||
serviceMap = new LinkedHashMap<>();
|
||||
}
|
||||
servicesChanged = true;
|
||||
String type = s.getType();
|
||||
String algorithm = s.getAlgorithm();
|
||||
ServiceKey key = new ServiceKey(type, algorithm, true);
|
||||
// remove existing service
|
||||
implRemoveService(serviceMap.get(key));
|
||||
serviceMap.put(key, s);
|
||||
for (String alias : s.getAliases()) {
|
||||
serviceMap.put(new ServiceKey(type, alias, true), s);
|
||||
}
|
||||
putPropertyStrings(s);
|
||||
servicesChanged = true;
|
||||
synchronized (this) {
|
||||
putPropertyStrings(s);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1425,7 +1417,7 @@ public abstract class Provider extends Properties {
|
|||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
protected synchronized void removeService(Service s) {
|
||||
protected void removeService(Service s) {
|
||||
check("removeProviderProperty." + name);
|
||||
if (debug != null) {
|
||||
debug.println(name + ".removeService(): " + s);
|
||||
|
@ -1437,7 +1429,7 @@ public abstract class Provider extends Properties {
|
|||
}
|
||||
|
||||
private void implRemoveService(Service s) {
|
||||
if ((s == null) || (serviceMap == null)) {
|
||||
if ((s == null) || serviceMap.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
String type = s.getType();
|
||||
|
@ -1452,7 +1444,9 @@ public abstract class Provider extends Properties {
|
|||
for (String alias : s.getAliases()) {
|
||||
serviceMap.remove(new ServiceKey(type, alias, false));
|
||||
}
|
||||
removePropertyStrings(s);
|
||||
synchronized (this) {
|
||||
removePropertyStrings(s);
|
||||
}
|
||||
}
|
||||
|
||||
// Wrapped String that behaves in a case insensitive way for equals/hashCode
|
||||
|
|
|
@ -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(
|
||||
"Null/empty securerandom.strongAlgorithms Security Property");
|
||||
}
|
||||
|
|
|
@ -649,7 +649,7 @@ public final class Security {
|
|||
}
|
||||
}
|
||||
|
||||
if ((candidates == null) || (candidates.isEmpty()))
|
||||
if (candidates == null || candidates.isEmpty())
|
||||
return null;
|
||||
|
||||
Object[] candidatesArray = candidates.toArray();
|
||||
|
@ -1005,11 +1005,11 @@ public final class Security {
|
|||
String algName = null;
|
||||
String attrName = null;
|
||||
|
||||
if (filterValue.length() == 0) {
|
||||
if (filterValue.isEmpty()) {
|
||||
// The filterValue is an empty string. So the filterKey
|
||||
// should be in the format of <crypto_service>.<algorithm_or_type>.
|
||||
algName = filterKey.substring(algIndex + 1).trim();
|
||||
if (algName.length() == 0) {
|
||||
if (algName.isEmpty()) {
|
||||
// There must be a algorithm or type name.
|
||||
throw new InvalidParameterException("Invalid filter");
|
||||
}
|
||||
|
@ -1024,7 +1024,7 @@ public final class Security {
|
|||
throw new InvalidParameterException("Invalid filter");
|
||||
} else {
|
||||
attrName = filterKey.substring(attrIndex + 1).trim();
|
||||
if (attrName.length() == 0) {
|
||||
if (attrName.isEmpty()) {
|
||||
// There is no attribute name in the filter.
|
||||
throw new InvalidParameterException("Invalid filter");
|
||||
}
|
||||
|
@ -1070,7 +1070,7 @@ public final class Security {
|
|||
**/
|
||||
public static Set<String> getAlgorithms(String serviceName) {
|
||||
|
||||
if ((serviceName == null) || (serviceName.length() == 0) ||
|
||||
if ((serviceName == null) || (serviceName.isEmpty()) ||
|
||||
(serviceName.endsWith("."))) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
|
|
|
@ -360,7 +360,7 @@ public abstract class Signature extends SignatureSpi {
|
|||
Objects.requireNonNull(algorithm, "null algorithm name");
|
||||
if (algorithm.equalsIgnoreCase(RSA_SIGNATURE)) {
|
||||
// exception compatibility with existing code
|
||||
if ((provider == null) || (provider.length() == 0)) {
|
||||
if (provider == null || provider.isEmpty()) {
|
||||
throw new IllegalArgumentException("missing provider");
|
||||
}
|
||||
Provider p = Security.getProvider(provider);
|
||||
|
|
|
@ -210,7 +210,7 @@ public class TrustAnchor {
|
|||
if (caName == null)
|
||||
throw new NullPointerException("the caName parameter must be " +
|
||||
"non-null");
|
||||
if (caName.length() == 0)
|
||||
if (caName.isEmpty())
|
||||
throw new IllegalArgumentException("the caName " +
|
||||
"parameter must be a non-empty String");
|
||||
// check if caName is formatted correctly
|
||||
|
|
|
@ -85,7 +85,7 @@ public class AttributedString {
|
|||
|
||||
text = buffer.toString();
|
||||
|
||||
if (text.length() > 0) {
|
||||
if (!text.isEmpty()) {
|
||||
// Determine the runs, creating a new run when the attributes
|
||||
// differ.
|
||||
int offset = 0;
|
||||
|
@ -144,7 +144,7 @@ public class AttributedString {
|
|||
}
|
||||
this.text = text;
|
||||
|
||||
if (text.length() == 0) {
|
||||
if (text.isEmpty()) {
|
||||
if (attributes.isEmpty())
|
||||
return;
|
||||
throw new IllegalArgumentException("Can't add attribute to 0-length text");
|
||||
|
|
|
@ -125,7 +125,7 @@ public final class CollationElementIterator
|
|||
CollationElementIterator(String sourceText, RuleBasedCollator owner) {
|
||||
this.owner = owner;
|
||||
ordering = owner.getTables();
|
||||
if ( sourceText.length() != 0 ) {
|
||||
if (!sourceText.isEmpty()) {
|
||||
NormalizerBase.Mode mode =
|
||||
CollatorUtilities.toNormalizerMode(owner.getDecomposition());
|
||||
text = new NormalizerBase(sourceText, mode);
|
||||
|
|
|
@ -799,7 +799,7 @@ public final class CompactNumberFormat extends NumberFormat {
|
|||
*/
|
||||
private void append(StringBuffer result, String string,
|
||||
FieldDelegate delegate, List<FieldPosition> positions) {
|
||||
if (string.length() > 0) {
|
||||
if (!string.isEmpty()) {
|
||||
int start = result.length();
|
||||
result.append(string);
|
||||
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 (pattern.length() != 0 && zeros.isEmpty()) {
|
||||
if (!pattern.isEmpty() && zeros.isEmpty()) {
|
||||
throw new IllegalArgumentException("Invalid pattern"
|
||||
+ " [" + pattern + "]: all patterns must include digit"
|
||||
+ " placement 0s");
|
||||
|
|
|
@ -1113,11 +1113,9 @@ public class DecimalFormat extends NumberFormat {
|
|||
|
||||
// Records the need for adding prefix or suffix
|
||||
fastPathData.positiveAffixesRequired
|
||||
= (positivePrefix.length() != 0)
|
||||
|| (positiveSuffix.length() != 0);
|
||||
= !positivePrefix.isEmpty() || !positiveSuffix.isEmpty();
|
||||
fastPathData.negativeAffixesRequired
|
||||
= (negativePrefix.length() != 0)
|
||||
|| (negativeSuffix.length() != 0);
|
||||
= !negativePrefix.isEmpty() || !negativeSuffix.isEmpty();
|
||||
|
||||
// Creates a cached char container for result, with max possible size.
|
||||
int maxNbIntegralDigits = 10;
|
||||
|
@ -2062,7 +2060,7 @@ public class DecimalFormat extends NumberFormat {
|
|||
Format.Field signAttribute) {
|
||||
int start = result.length();
|
||||
|
||||
if (string.length() > 0) {
|
||||
if (!string.isEmpty()) {
|
||||
result.append(string);
|
||||
for (int counter = 0, max = positions.length; counter < max;
|
||||
counter++) {
|
||||
|
@ -3042,7 +3040,7 @@ public class DecimalFormat extends NumberFormat {
|
|||
} else {
|
||||
string = symbols.getCurrencySymbol();
|
||||
}
|
||||
if (string.length() > 0) {
|
||||
if (!string.isEmpty()) {
|
||||
if (positions == null) {
|
||||
positions = new ArrayList<>(2);
|
||||
}
|
||||
|
@ -3613,7 +3611,7 @@ public class DecimalFormat extends NumberFormat {
|
|||
}
|
||||
}
|
||||
|
||||
if (pattern.length() == 0) {
|
||||
if (pattern.isEmpty()) {
|
||||
posPrefixPattern = posSuffixPattern = "";
|
||||
setMinimumIntegerDigits(0);
|
||||
setMaximumIntegerDigits(MAXIMUM_INTEGER_DIGITS);
|
||||
|
|
|
@ -663,7 +663,7 @@ public class DecimalFormatSymbols implements Cloneable, Serializable {
|
|||
// 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
|
||||
// ISO 3166 country code, and exceptions are expensive.
|
||||
if (locale.getCountry().length() > 0) {
|
||||
if (!locale.getCountry().isEmpty()) {
|
||||
try {
|
||||
currency = Currency.getInstance(locale);
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
|
|
@ -92,7 +92,7 @@ final class MergeCollation {
|
|||
int i;
|
||||
for (i = 0; i < patterns.size(); ++i) {
|
||||
PatternEntry entry = patterns.get(i);
|
||||
if (entry.extension.length() != 0) {
|
||||
if (!entry.extension.isEmpty()) {
|
||||
if (extList == null)
|
||||
extList = new ArrayList<>();
|
||||
extList.add(entry);
|
||||
|
@ -122,7 +122,7 @@ final class MergeCollation {
|
|||
private final PatternEntry findLastWithNoExtension(int i) {
|
||||
for (--i;i >= 0; --i) {
|
||||
PatternEntry entry = patterns.get(i);
|
||||
if (entry.extension.length() == 0) {
|
||||
if (entry.extension.isEmpty()) {
|
||||
return entry;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1330,7 +1330,7 @@ public class MessageFormat extends Format {
|
|||
}
|
||||
arg = null;
|
||||
}
|
||||
if (arg != null && arg.length() > 0) {
|
||||
if (arg != null && !arg.isEmpty()) {
|
||||
result.append(arg);
|
||||
characterIterators.add(
|
||||
createAttributedCharacterIterator(
|
||||
|
@ -1476,7 +1476,7 @@ public class MessageFormat extends Format {
|
|||
|
||||
// now get the format
|
||||
Format newFormat = null;
|
||||
if (segments[SEG_TYPE].length() != 0) {
|
||||
if (!segments[SEG_TYPE].isEmpty()) {
|
||||
int type = findKeyword(segments[SEG_TYPE], TYPE_KEYWORDS);
|
||||
switch (type) {
|
||||
case TYPE_NULL:
|
||||
|
|
|
@ -141,7 +141,7 @@ class PatternEntry {
|
|||
if (showWhiteSpace)
|
||||
toAddTo.append(' ');
|
||||
appendQuoted(chars,toAddTo);
|
||||
if (showExtension && extension.length() != 0) {
|
||||
if (showExtension && !extension.isEmpty()) {
|
||||
toAddTo.append('/');
|
||||
appendQuoted(extension,toAddTo);
|
||||
}
|
||||
|
|
|
@ -75,13 +75,10 @@ final class RBTableBuilder {
|
|||
* @exception ParseException If the rules format is incorrect.
|
||||
*/
|
||||
|
||||
public void build(String pattern, int decmp) throws ParseException
|
||||
{
|
||||
boolean isSource = true;
|
||||
int i = 0;
|
||||
public void build(String pattern, int decmp) throws ParseException {
|
||||
String expChars;
|
||||
String groupChars;
|
||||
if (pattern.length() == 0)
|
||||
if (pattern.isEmpty())
|
||||
throw new ParseException("Build rules empty.", 0);
|
||||
|
||||
// This array maps Unicode characters to their collation ordering
|
||||
|
@ -119,8 +116,7 @@ final class RBTableBuilder {
|
|||
int order = 0;
|
||||
|
||||
// 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);
|
||||
if (entry != null) {
|
||||
groupChars = entry.getChars();
|
||||
|
@ -140,7 +136,7 @@ final class RBTableBuilder {
|
|||
order = increment(entry.getStrength(), order);
|
||||
expChars = entry.getExtension();
|
||||
|
||||
if (expChars.length() != 0) {
|
||||
if (!expChars.isEmpty()) {
|
||||
addExpandOrder(groupChars, expChars, order);
|
||||
} else if (groupChars.length() > 1) {
|
||||
char ch = groupChars.charAt(0);
|
||||
|
|
|
@ -372,7 +372,7 @@ public abstract class ZoneId implements Serializable {
|
|||
public static ZoneId ofOffset(String prefix, ZoneOffset offset) {
|
||||
Objects.requireNonNull(prefix, "prefix");
|
||||
Objects.requireNonNull(offset, "offset");
|
||||
if (prefix.length() == 0) {
|
||||
if (prefix.isEmpty()) {
|
||||
return offset;
|
||||
}
|
||||
|
||||
|
|
|
@ -1439,7 +1439,7 @@ public final class DateTimeFormatterBuilder {
|
|||
*/
|
||||
public DateTimeFormatterBuilder appendLiteral(String literal) {
|
||||
Objects.requireNonNull(literal, "literal");
|
||||
if (literal.length() > 0) {
|
||||
if (!literal.isEmpty()) {
|
||||
if (literal.length() == 1) {
|
||||
appendInternal(new CharLiteralPrinterParser(literal.charAt(0)));
|
||||
} else {
|
||||
|
@ -1832,7 +1832,7 @@ public final class DateTimeFormatterBuilder {
|
|||
throw new IllegalArgumentException("Pattern ends with an incomplete string literal: " + pattern);
|
||||
}
|
||||
String str = pattern.substring(start + 1, pos);
|
||||
if (str.length() == 0) {
|
||||
if (str.isEmpty()) {
|
||||
appendLiteral('\'');
|
||||
} else {
|
||||
appendLiteral(str.replace("''", "'"));
|
||||
|
@ -4332,7 +4332,7 @@ public final class DateTimeFormatterBuilder {
|
|||
this.key = k;
|
||||
this.value = v;
|
||||
this.child = child;
|
||||
if (k.length() == 0){
|
||||
if (k.isEmpty()) {
|
||||
c0 = 0xffff;
|
||||
} else {
|
||||
c0 = key.charAt(0);
|
||||
|
|
|
@ -99,7 +99,7 @@ import java.util.Collections;
|
|||
* <p>
|
||||
* The Java virtual machine has a default provider that provides zone rules
|
||||
* for the time-zones defined by IANA Time Zone Database (TZDB). If the system
|
||||
* property {@code java.time.zone.DefaultZoneRulesProvider} is defined then
|
||||
* property {@systemProperty java.time.zone.DefaultZoneRulesProvider} is defined then
|
||||
* it is taken to be the fully-qualified name of a concrete ZoneRulesProvider
|
||||
* class to be loaded as the default provider, using the system class loader.
|
||||
* If this system property is not defined, a system-default provider will be
|
||||
|
|
|
@ -2232,7 +2232,7 @@ public abstract class Calendar implements Serializable, Cloneable, Comparable<Ca
|
|||
if (strings != null) {
|
||||
Map<String,Integer> names = new HashMap<>();
|
||||
for (int i = 0; i < strings.length; i++) {
|
||||
if (strings[i].length() == 0) {
|
||||
if (strings[i].isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
names.put(strings[i], i);
|
||||
|
|
|
@ -459,7 +459,7 @@ public class Collections {
|
|||
for (int i=size; i>1; i--)
|
||||
swap(list, i-1, rnd.nextInt(i));
|
||||
} else {
|
||||
Object arr[] = list.toArray();
|
||||
Object[] arr = list.toArray();
|
||||
|
||||
// Shuffle array
|
||||
for (int i=size; i>1; i--)
|
||||
|
@ -5101,6 +5101,53 @@ public class Collections {
|
|||
return new CopiesList<>(toIndex - fromIndex, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
if (n == 0) return 1;
|
||||
// hashCode of n repeating elements is 31^n + elementHash * Sum(31^k, k = 0..n-1)
|
||||
// this implementation completes in O(log(n)) steps taking advantage of
|
||||
// 31^(2*n) = (31^n)^2 and Sum(31^k, k = 0..(2*n-1)) = Sum(31^k, k = 0..n-1) * (31^n + 1)
|
||||
int pow = 31;
|
||||
int sum = 1;
|
||||
for (int i = Integer.numberOfLeadingZeros(n) + 1; i < Integer.SIZE; i++) {
|
||||
sum *= pow + 1;
|
||||
pow *= pow;
|
||||
if ((n << i) < 0) {
|
||||
pow *= 31;
|
||||
sum = sum * 31 + 1;
|
||||
}
|
||||
}
|
||||
return pow + sum * (element == null ? 0 : element.hashCode());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this)
|
||||
return true;
|
||||
if (o instanceof CopiesList) {
|
||||
CopiesList<?> other = (CopiesList<?>) o;
|
||||
return n == other.n && (n == 0 || eq(element, other.element));
|
||||
}
|
||||
if (!(o instanceof List))
|
||||
return false;
|
||||
|
||||
int remaining = n;
|
||||
E e = element;
|
||||
Iterator<?> itr = ((List<?>) o).iterator();
|
||||
if (e == null) {
|
||||
while (itr.hasNext() && remaining-- > 0) {
|
||||
if (itr.next() != null)
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
while (itr.hasNext() && remaining-- > 0) {
|
||||
if (!e.equals(itr.next()))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return remaining == 0 && !itr.hasNext();
|
||||
}
|
||||
|
||||
// Override default methods in Collection
|
||||
@Override
|
||||
public Stream<E> stream() {
|
||||
|
|
|
@ -60,7 +60,7 @@ import sun.util.logging.PlatformLogger;
|
|||
* the <code>getInstance</code> methods.
|
||||
* <p>
|
||||
* Users can supersede the Java runtime currency data by means of the system
|
||||
* property {@code java.util.currency.data}. If this system property is
|
||||
* property {@systemProperty java.util.currency.data}. If this system property is
|
||||
* defined then its value is the location of a properties file, the contents of
|
||||
* which are key/value pairs of the ISO 3166 country codes and the ISO 4217
|
||||
* currency data respectively. The value part consists of three ISO 4217 values
|
||||
|
|
|
@ -1396,11 +1396,11 @@ public final class Locale implements Cloneable, Serializable {
|
|||
*/
|
||||
@Override
|
||||
public final String toString() {
|
||||
boolean l = (baseLocale.getLanguage().length() != 0);
|
||||
boolean s = (baseLocale.getScript().length() != 0);
|
||||
boolean r = (baseLocale.getRegion().length() != 0);
|
||||
boolean v = (baseLocale.getVariant().length() != 0);
|
||||
boolean e = (localeExtensions != null && localeExtensions.getID().length() != 0);
|
||||
boolean l = !baseLocale.getLanguage().isEmpty();
|
||||
boolean s = !baseLocale.getScript().isEmpty();
|
||||
boolean r = !baseLocale.getRegion().isEmpty();
|
||||
boolean v = !baseLocale.getVariant().isEmpty();
|
||||
boolean e = localeExtensions != null && !localeExtensions.getID().isEmpty();
|
||||
|
||||
StringBuilder result = new StringBuilder(baseLocale.getLanguage());
|
||||
if (r || (l && (v || s || e))) {
|
||||
|
@ -1504,18 +1504,18 @@ public final class Locale implements Cloneable, Serializable {
|
|||
StringBuilder buf = new StringBuilder();
|
||||
|
||||
String subtag = tag.getLanguage();
|
||||
if (subtag.length() > 0) {
|
||||
if (!subtag.isEmpty()) {
|
||||
buf.append(LanguageTag.canonicalizeLanguage(subtag));
|
||||
}
|
||||
|
||||
subtag = tag.getScript();
|
||||
if (subtag.length() > 0) {
|
||||
if (!subtag.isEmpty()) {
|
||||
buf.append(LanguageTag.SEP);
|
||||
buf.append(LanguageTag.canonicalizeScript(subtag));
|
||||
}
|
||||
|
||||
subtag = tag.getRegion();
|
||||
if (subtag.length() > 0) {
|
||||
if (!subtag.isEmpty()) {
|
||||
buf.append(LanguageTag.SEP);
|
||||
buf.append(LanguageTag.canonicalizeRegion(subtag));
|
||||
}
|
||||
|
@ -1534,7 +1534,7 @@ public final class Locale implements Cloneable, Serializable {
|
|||
}
|
||||
|
||||
subtag = tag.getPrivateuse();
|
||||
if (subtag.length() > 0) {
|
||||
if (!subtag.isEmpty()) {
|
||||
if (buf.length() > 0) {
|
||||
buf.append(LanguageTag.SEP);
|
||||
}
|
||||
|
@ -1684,7 +1684,7 @@ public final class Locale implements Cloneable, Serializable {
|
|||
bldr.setLanguageTag(tag);
|
||||
BaseLocale base = bldr.getBaseLocale();
|
||||
LocaleExtensions exts = bldr.getLocaleExtensions();
|
||||
if (exts == null && base.getVariant().length() > 0) {
|
||||
if (exts == null && !base.getVariant().isEmpty()) {
|
||||
exts = getCompatibilityExtensions(base.getLanguage(), base.getScript(),
|
||||
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>
|
||||
*/
|
||||
public String getDisplayVariant(Locale inLocale) {
|
||||
if (baseLocale.getVariant().length() == 0)
|
||||
if (baseLocale.getVariant().isEmpty())
|
||||
return "";
|
||||
|
||||
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.
|
||||
// Typically, the format is "MainName (Qualifier, Qualifier)" but this
|
||||
// depends on what pattern is stored in the display locale.
|
||||
String mainName = null;
|
||||
String[] qualifierNames = null;
|
||||
String mainName;
|
||||
String[] qualifierNames;
|
||||
|
||||
// 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
|
||||
// (an anomalous situation) then the display name is simply the variant's
|
||||
// display name.
|
||||
if (languageName.length() == 0 && scriptName.length() == 0 && countryName.length() == 0) {
|
||||
if (languageName.isEmpty() && scriptName.isEmpty() && countryName.isEmpty()) {
|
||||
if (variantNames.length == 0) {
|
||||
return "";
|
||||
} else {
|
||||
|
@ -2013,13 +2013,13 @@ public final class Locale implements Cloneable, Serializable {
|
|||
}
|
||||
}
|
||||
ArrayList<String> names = new ArrayList<>(4);
|
||||
if (languageName.length() != 0) {
|
||||
if (!languageName.isEmpty()) {
|
||||
names.add(languageName);
|
||||
}
|
||||
if (scriptName.length() != 0) {
|
||||
if (!scriptName.isEmpty()) {
|
||||
names.add(scriptName);
|
||||
}
|
||||
if (countryName.length() != 0) {
|
||||
if (!countryName.isEmpty()) {
|
||||
names.add(countryName);
|
||||
}
|
||||
if (variantNames.length != 0) {
|
||||
|
@ -2309,7 +2309,7 @@ public final class Locale implements Cloneable, Serializable {
|
|||
String variant = (String)fields.get("variant", "");
|
||||
String extStr = (String)fields.get("extensions", "");
|
||||
baseLocale = BaseLocale.getInstance(convertOldISOCodes(language), script, country, variant);
|
||||
if (extStr.length() > 0) {
|
||||
if (!extStr.isEmpty()) {
|
||||
try {
|
||||
InternalLocaleBuilder bldr = new InternalLocaleBuilder();
|
||||
bldr.setExtensions(extStr);
|
||||
|
@ -2367,13 +2367,13 @@ public final class Locale implements Cloneable, Serializable {
|
|||
LocaleExtensions extensions = null;
|
||||
// Special cases for backward compatibility support
|
||||
if (LocaleUtils.caseIgnoreMatch(language, "ja")
|
||||
&& script.length() == 0
|
||||
&& script.isEmpty()
|
||||
&& LocaleUtils.caseIgnoreMatch(country, "jp")
|
||||
&& "JP".equals(variant)) {
|
||||
// ja_JP_JP -> u-ca-japanese (calendar = japanese)
|
||||
extensions = LocaleExtensions.CALENDAR_JAPANESE;
|
||||
} else if (LocaleUtils.caseIgnoreMatch(language, "th")
|
||||
&& script.length() == 0
|
||||
&& script.isEmpty()
|
||||
&& LocaleUtils.caseIgnoreMatch(country, "th")
|
||||
&& "TH".equals(variant)) {
|
||||
// th_TH_TH -> u-nu-thai (numbersystem = thai)
|
||||
|
@ -2806,7 +2806,7 @@ public final class Locale implements Cloneable, Serializable {
|
|||
public Locale build() {
|
||||
BaseLocale baseloc = localeBuilder.getBaseLocale();
|
||||
LocaleExtensions extensions = localeBuilder.getLocaleExtensions();
|
||||
if (extensions == null && baseloc.getVariant().length() > 0) {
|
||||
if (extensions == null && !baseloc.getVariant().isEmpty()) {
|
||||
extensions = getCompatibilityExtensions(baseloc.getLanguage(), baseloc.getScript(),
|
||||
baseloc.getRegion(), baseloc.getVariant());
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ import sun.util.ResourceBundleEnumeration;
|
|||
* input stream, then the {@code PropertyResourceBundle} instance resets to the state
|
||||
* before the exception, re-reads the input stream in {@code ISO-8859-1}, and
|
||||
* continues reading. If the system property
|
||||
* {@code java.util.PropertyResourceBundle.encoding} is set to either
|
||||
* {@systemProperty java.util.PropertyResourceBundle.encoding} is set to either
|
||||
* "ISO-8859-1" or "UTF-8", the input stream is solely read in that encoding,
|
||||
* and throws the exception if it encounters an invalid sequence.
|
||||
* If "ISO-8859-1" is specified, characters that cannot be represented in
|
||||
|
|
|
@ -771,8 +771,8 @@ public abstract class ResourceBundle {
|
|||
@Override
|
||||
public String toString() {
|
||||
String l = locale.toString();
|
||||
if (l.length() == 0) {
|
||||
if (locale.getVariant().length() != 0) {
|
||||
if (l.isEmpty()) {
|
||||
if (!locale.getVariant().isEmpty()) {
|
||||
l = "__" + locale.getVariant();
|
||||
} else {
|
||||
l = "\"\"";
|
||||
|
@ -2903,7 +2903,7 @@ public abstract class ResourceBundle {
|
|||
List<Locale> bokmalList = new LinkedList<>();
|
||||
for (Locale l : tmpList) {
|
||||
bokmalList.add(l);
|
||||
if (l.getLanguage().length() == 0) {
|
||||
if (l.getLanguage().isEmpty()) {
|
||||
break;
|
||||
}
|
||||
bokmalList.add(Locale.getInstance("no", l.getScript(), l.getCountry(),
|
||||
|
@ -2921,7 +2921,7 @@ public abstract class ResourceBundle {
|
|||
}
|
||||
// Special handling for Chinese
|
||||
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
|
||||
// as bundle names (recommended for Java7+)
|
||||
switch (region) {
|
||||
|
@ -2944,7 +2944,7 @@ public abstract class ResourceBundle {
|
|||
private static List<Locale> getDefaultList(String language, String script, String region, String variant) {
|
||||
List<String> variants = null;
|
||||
|
||||
if (variant.length() > 0) {
|
||||
if (!variant.isEmpty()) {
|
||||
variants = new LinkedList<>();
|
||||
int idx = variant.length();
|
||||
while (idx != -1) {
|
||||
|
@ -2960,14 +2960,14 @@ public abstract class ResourceBundle {
|
|||
list.add(Locale.getInstance(language, script, region, v, null));
|
||||
}
|
||||
}
|
||||
if (region.length() > 0) {
|
||||
if (!region.isEmpty()) {
|
||||
list.add(Locale.getInstance(language, script, region, "", null));
|
||||
}
|
||||
if (script.length() > 0) {
|
||||
if (!script.isEmpty()) {
|
||||
list.add(Locale.getInstance(language, script, "", "", null));
|
||||
// Special handling for Chinese
|
||||
if (language.equals("zh")) {
|
||||
if (region.length() == 0) {
|
||||
if (region.isEmpty()) {
|
||||
// Supply region(country) for users who still package Chinese
|
||||
// bundles using old convension.
|
||||
switch (script) {
|
||||
|
@ -2988,11 +2988,11 @@ public abstract class ResourceBundle {
|
|||
list.add(Locale.getInstance(language, "", region, v, null));
|
||||
}
|
||||
}
|
||||
if (region.length() > 0) {
|
||||
if (!region.isEmpty()) {
|
||||
list.add(Locale.getInstance(language, "", region, "", null));
|
||||
}
|
||||
}
|
||||
if (language.length() > 0) {
|
||||
if (!language.isEmpty()) {
|
||||
list.add(Locale.getInstance(language, "", "", "", null));
|
||||
}
|
||||
// Add root locale at the end
|
||||
|
|
|
@ -1297,16 +1297,16 @@ public final class Scanner implements Iterator<String>, Closeable {
|
|||
nanString = "\\Q" + dfs.getNaN() + "\\E";
|
||||
infinityString = "\\Q" + dfs.getInfinity() + "\\E";
|
||||
positivePrefix = df.getPositivePrefix();
|
||||
if (positivePrefix.length() > 0)
|
||||
if (!positivePrefix.isEmpty())
|
||||
positivePrefix = "\\Q" + positivePrefix + "\\E";
|
||||
negativePrefix = df.getNegativePrefix();
|
||||
if (negativePrefix.length() > 0)
|
||||
if (!negativePrefix.isEmpty())
|
||||
negativePrefix = "\\Q" + negativePrefix + "\\E";
|
||||
positiveSuffix = df.getPositiveSuffix();
|
||||
if (positiveSuffix.length() > 0)
|
||||
if (!positiveSuffix.isEmpty())
|
||||
positiveSuffix = "\\Q" + positiveSuffix + "\\E";
|
||||
negativeSuffix = df.getNegativeSuffix();
|
||||
if (negativeSuffix.length() > 0)
|
||||
if (!negativeSuffix.isEmpty())
|
||||
negativeSuffix = "\\Q" + negativeSuffix + "\\E";
|
||||
|
||||
// Force rebuilding and recompilation of locale dependent
|
||||
|
|
|
@ -284,7 +284,7 @@ import java.util.function.LongConsumer;
|
|||
* }}</pre>
|
||||
*
|
||||
* @implNote
|
||||
* If the boolean system property {@code org.openjdk.java.util.stream.tripwire}
|
||||
* If the boolean system property {@systemProperty org.openjdk.java.util.stream.tripwire}
|
||||
* is set to {@code true} then diagnostic warnings are reported if boxing of
|
||||
* primitive values occur when operating on primitive subtype specializations.
|
||||
*
|
||||
|
|
|
@ -445,7 +445,8 @@ public class ForkJoinPool extends AbstractExecutorService {
|
|||
* if to its current value). This would be extremely costly. So
|
||||
* we relax it in several ways: (1) Producers only signal when
|
||||
* their queue is possibly empty at some point during a push
|
||||
* operation. (2) Other workers propagate this signal
|
||||
* operation (which requires conservatively checking size zero or
|
||||
* one to cover races). (2) Other workers propagate this signal
|
||||
* when they find tasks in a queue with size greater than one. (3)
|
||||
* Workers only enqueue after scanning (see below) and not finding
|
||||
* any tasks. (4) Rather than CASing ctl to its current value in
|
||||
|
@ -761,8 +762,10 @@ public class ForkJoinPool extends AbstractExecutorService {
|
|||
|
||||
/**
|
||||
* The maximum number of top-level polls per worker before
|
||||
* checking other queues, expressed as a bit shift. See above for
|
||||
* rationale.
|
||||
* checking other queues, expressed as a bit shift to, in effect,
|
||||
* multiply by pool size, and then use as random value mask, so
|
||||
* average bound is about poolSize*(1<<TOP_BOUND_SHIFT). See
|
||||
* above for rationale.
|
||||
*/
|
||||
static final int TOP_BOUND_SHIFT = 10;
|
||||
|
||||
|
@ -838,17 +841,18 @@ public class ForkJoinPool extends AbstractExecutorService {
|
|||
*/
|
||||
final void push(ForkJoinTask<?> task) {
|
||||
ForkJoinTask<?>[] a;
|
||||
int s = top, d = s - base, cap, m;
|
||||
int s = top, d, cap, m;
|
||||
ForkJoinPool p = pool;
|
||||
if ((a = array) != null && (cap = a.length) > 0) {
|
||||
QA.setRelease(a, (m = cap - 1) & s, task);
|
||||
top = s + 1;
|
||||
if (d == m)
|
||||
growArray(false);
|
||||
else if (QA.getAcquire(a, m & (s - 1)) == null && p != null) {
|
||||
VarHandle.fullFence(); // was empty
|
||||
p.signalWork(null);
|
||||
if (((d = s - (int)BASE.getAcquire(this)) & ~1) == 0 &&
|
||||
p != null) { // size 0 or 1
|
||||
VarHandle.fullFence();
|
||||
p.signalWork();
|
||||
}
|
||||
else if (d == m)
|
||||
growArray(false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -859,16 +863,16 @@ public class ForkJoinPool extends AbstractExecutorService {
|
|||
final boolean lockedPush(ForkJoinTask<?> task) {
|
||||
ForkJoinTask<?>[] a;
|
||||
boolean signal = false;
|
||||
int s = top, d = s - base, cap, m;
|
||||
int s = top, b = base, cap, d;
|
||||
if ((a = array) != null && (cap = a.length) > 0) {
|
||||
a[(m = (cap - 1)) & s] = task;
|
||||
a[(cap - 1) & s] = task;
|
||||
top = s + 1;
|
||||
if (d == m)
|
||||
if (b - s + cap - 1 == 0)
|
||||
growArray(true);
|
||||
else {
|
||||
phase = 0; // full volatile unlock
|
||||
if (a[m & (s - 1)] == null)
|
||||
signal = true; // was empty
|
||||
if (((s - base) & ~1) == 0) // size 0 or 1
|
||||
signal = true;
|
||||
}
|
||||
}
|
||||
return signal;
|
||||
|
@ -1010,30 +1014,25 @@ public class ForkJoinPool extends AbstractExecutorService {
|
|||
* queue, up to bound n (to avoid infinite unfairness).
|
||||
*/
|
||||
final void topLevelExec(ForkJoinTask<?> t, WorkQueue q, int n) {
|
||||
int nstolen = 1;
|
||||
for (int j = 0;;) {
|
||||
if (t != null)
|
||||
if (t != null && q != null) { // hoist checks
|
||||
int nstolen = 1;
|
||||
for (;;) {
|
||||
t.doExec();
|
||||
if (j++ <= n)
|
||||
t = nextLocalTask();
|
||||
else {
|
||||
j = 0;
|
||||
t = null;
|
||||
}
|
||||
if (t == null) {
|
||||
if (q != null && (t = q.poll()) != null) {
|
||||
++nstolen;
|
||||
j = 0;
|
||||
}
|
||||
else if (j != 0)
|
||||
if (n-- < 0)
|
||||
break;
|
||||
else if ((t = nextLocalTask()) == null) {
|
||||
if ((t = q.poll()) == null)
|
||||
break;
|
||||
else
|
||||
++nstolen;
|
||||
}
|
||||
}
|
||||
ForkJoinWorkerThread thread = owner;
|
||||
nsteals += nstolen;
|
||||
source = 0;
|
||||
if (thread != null)
|
||||
thread.afterTopLevelExec();
|
||||
}
|
||||
ForkJoinWorkerThread thread = owner;
|
||||
nsteals += nstolen;
|
||||
source = 0;
|
||||
if (thread != null)
|
||||
thread.afterTopLevelExec();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1456,7 +1455,7 @@ public class ForkJoinPool extends AbstractExecutorService {
|
|||
|
||||
if (!tryTerminate(false, false) && // possibly replace worker
|
||||
w != null && w.array != null) // avoid repeated failures
|
||||
signalWork(null);
|
||||
signalWork();
|
||||
|
||||
if (ex == null) // help clean on way out
|
||||
ForkJoinTask.helpExpungeStaleExceptions();
|
||||
|
@ -1466,9 +1465,8 @@ public class ForkJoinPool extends AbstractExecutorService {
|
|||
|
||||
/**
|
||||
* Tries to create or release a worker if too few are running.
|
||||
* @param q if non-null recheck if empty on CAS failure
|
||||
*/
|
||||
final void signalWork(WorkQueue q) {
|
||||
final void signalWork() {
|
||||
for (;;) {
|
||||
long c; int sp; WorkQueue[] ws; int i; WorkQueue v;
|
||||
if ((c = ctl) >= 0L) // enough workers
|
||||
|
@ -1495,8 +1493,6 @@ public class ForkJoinPool extends AbstractExecutorService {
|
|||
LockSupport.unpark(vt);
|
||||
break;
|
||||
}
|
||||
else if (q != null && q.isEmpty()) // no need to retry
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1617,24 +1613,19 @@ public class ForkJoinPool extends AbstractExecutorService {
|
|||
else if (rc <= 0 && (md & SHUTDOWN) != 0 &&
|
||||
tryTerminate(false, false))
|
||||
break; // quiescent shutdown
|
||||
else if (w.phase < 0) {
|
||||
if (rc <= 0 && pred != 0 && phase == (int)c) {
|
||||
long nc = (UC_MASK & (c - TC_UNIT)) | (SP_MASK & pred);
|
||||
long d = keepAlive + System.currentTimeMillis();
|
||||
LockSupport.parkUntil(this, d);
|
||||
if (ctl == c && // drop on timeout if all idle
|
||||
d - System.currentTimeMillis() <= TIMEOUT_SLOP &&
|
||||
CTL.compareAndSet(this, c, nc)) {
|
||||
w.phase = QUIET;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
LockSupport.park(this);
|
||||
if (w.phase < 0) // one spurious wakeup check
|
||||
LockSupport.park(this);
|
||||
else if (rc <= 0 && pred != 0 && phase == (int)c) {
|
||||
long nc = (UC_MASK & (c - TC_UNIT)) | (SP_MASK & pred);
|
||||
long d = keepAlive + System.currentTimeMillis();
|
||||
LockSupport.parkUntil(this, d);
|
||||
if (ctl == c && // drop on timeout if all idle
|
||||
d - System.currentTimeMillis() <= TIMEOUT_SLOP &&
|
||||
CTL.compareAndSet(this, c, nc)) {
|
||||
w.phase = QUIET;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (w.phase < 0)
|
||||
LockSupport.park(this); // OK if spuriously woken
|
||||
w.source = 0; // disable signal
|
||||
}
|
||||
}
|
||||
|
@ -1650,8 +1641,8 @@ public class ForkJoinPool extends AbstractExecutorService {
|
|||
WorkQueue[] ws; int n;
|
||||
if ((ws = workQueues) != null && (n = ws.length) > 0 && w != null) {
|
||||
for (int m = n - 1, j = r & m;;) {
|
||||
WorkQueue q; int b, s;
|
||||
if ((q = ws[j]) != null && (s = q.top) != (b = q.base)) {
|
||||
WorkQueue q; int b;
|
||||
if ((q = ws[j]) != null && q.top != (b = q.base)) {
|
||||
int qid = q.id;
|
||||
ForkJoinTask<?>[] a; int cap, k; ForkJoinTask<?> t;
|
||||
if ((a = q.array) != null && (cap = a.length) > 0) {
|
||||
|
@ -1660,10 +1651,10 @@ public class ForkJoinPool extends AbstractExecutorService {
|
|||
QA.compareAndSet(a, k, t, null)) {
|
||||
q.base = b;
|
||||
w.source = qid;
|
||||
if (s != b && a[(cap - 1) & b] != null)
|
||||
signalWork(q); // help signal if more tasks
|
||||
if (q.top - b > 0)
|
||||
signalWork();
|
||||
w.topLevelExec(t, q, // random fairness bound
|
||||
(r | (1 << TOP_BOUND_SHIFT)) & SMASK);
|
||||
r & ((n << TOP_BOUND_SHIFT) - 1));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
@ -1909,7 +1900,7 @@ public class ForkJoinPool extends AbstractExecutorService {
|
|||
r = ThreadLocalRandom.advanceProbe(r);
|
||||
else {
|
||||
if (q.lockedPush(task))
|
||||
signalWork(null);
|
||||
signalWork();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,6 +36,8 @@ import java.util.Set;
|
|||
|
||||
import sun.util.logging.PlatformLogger;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
/**
|
||||
* The Attributes class maps Manifest attribute names to associated string
|
||||
* values. Valid attribute names are case-insensitive, are restricted to
|
||||
|
@ -298,25 +300,16 @@ public class Attributes implements Map<Object,Object>, Cloneable {
|
|||
* Writes the current attributes to the specified data output stream.
|
||||
* XXX Need to handle UTF8 values and break up lines longer than 72 bytes
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
void write(DataOutputStream os) throws IOException {
|
||||
for (Entry<Object, Object> e : entrySet()) {
|
||||
StringBuffer buffer = new StringBuffer(
|
||||
((Name) e.getKey()).toString());
|
||||
buffer.append(": ");
|
||||
|
||||
String value = (String) e.getValue();
|
||||
if (value != null) {
|
||||
byte[] vb = value.getBytes("UTF8");
|
||||
value = new String(vb, 0, 0, vb.length);
|
||||
}
|
||||
buffer.append(value);
|
||||
|
||||
Manifest.make72Safe(buffer);
|
||||
buffer.append("\r\n");
|
||||
os.writeBytes(buffer.toString());
|
||||
}
|
||||
os.writeBytes("\r\n");
|
||||
void write(DataOutputStream out) throws IOException {
|
||||
StringBuilder buffer = new StringBuilder(72);
|
||||
for (Entry<Object, Object> e : entrySet()) {
|
||||
buffer.setLength(0);
|
||||
buffer.append(e.getKey().toString());
|
||||
buffer.append(": ");
|
||||
buffer.append(e.getValue());
|
||||
Manifest.println72(out, buffer.toString());
|
||||
}
|
||||
Manifest.println(out); // empty line after individual section
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -326,9 +319,9 @@ public class Attributes implements Map<Object,Object>, Cloneable {
|
|||
*
|
||||
* XXX Need to handle UTF8 values and break up lines longer than 72 bytes
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
void writeMain(DataOutputStream out) throws IOException
|
||||
{
|
||||
void writeMain(DataOutputStream out) throws IOException {
|
||||
StringBuilder buffer = new StringBuilder(72);
|
||||
|
||||
// write out the *-Version header first, if it exists
|
||||
String vername = Name.MANIFEST_VERSION.toString();
|
||||
String version = getValue(vername);
|
||||
|
@ -338,7 +331,11 @@ public class Attributes implements Map<Object,Object>, Cloneable {
|
|||
}
|
||||
|
||||
if (version != null) {
|
||||
out.writeBytes(vername+": "+version+"\r\n");
|
||||
buffer.append(vername);
|
||||
buffer.append(": ");
|
||||
buffer.append(version);
|
||||
out.write(buffer.toString().getBytes(UTF_8));
|
||||
Manifest.println(out);
|
||||
}
|
||||
|
||||
// write out all attributes except for the version
|
||||
|
@ -346,34 +343,24 @@ public class Attributes implements Map<Object,Object>, Cloneable {
|
|||
for (Entry<Object, Object> e : entrySet()) {
|
||||
String name = ((Name) e.getKey()).toString();
|
||||
if ((version != null) && !(name.equalsIgnoreCase(vername))) {
|
||||
|
||||
StringBuffer buffer = new StringBuffer(name);
|
||||
buffer.setLength(0);
|
||||
buffer.append(name);
|
||||
buffer.append(": ");
|
||||
|
||||
String value = (String) e.getValue();
|
||||
if (value != null) {
|
||||
byte[] vb = value.getBytes("UTF8");
|
||||
value = new String(vb, 0, 0, vb.length);
|
||||
}
|
||||
buffer.append(value);
|
||||
|
||||
Manifest.make72Safe(buffer);
|
||||
buffer.append("\r\n");
|
||||
out.writeBytes(buffer.toString());
|
||||
buffer.append(e.getValue());
|
||||
Manifest.println72(out, buffer.toString());
|
||||
}
|
||||
}
|
||||
out.writeBytes("\r\n");
|
||||
|
||||
Manifest.println(out); // empty line after main attributes section
|
||||
}
|
||||
|
||||
/*
|
||||
* Reads attributes from the specified input stream.
|
||||
* XXX Need to handle UTF8 values.
|
||||
*/
|
||||
void read(Manifest.FastInputStream is, byte[] lbuf) throws IOException {
|
||||
read(is, lbuf, null, 0);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
int read(Manifest.FastInputStream is, byte[] lbuf, String filename, int lineNumber) throws IOException {
|
||||
String name = null, value;
|
||||
byte[] lastline = null;
|
||||
|
@ -409,7 +396,7 @@ public class Attributes implements Map<Object,Object>, Cloneable {
|
|||
lastline = buf;
|
||||
continue;
|
||||
}
|
||||
value = new String(buf, 0, buf.length, "UTF8");
|
||||
value = new String(buf, 0, buf.length, UTF_8);
|
||||
lastline = null;
|
||||
} else {
|
||||
while (lbuf[i++] != ':') {
|
||||
|
@ -422,13 +409,13 @@ public class Attributes implements Map<Object,Object>, Cloneable {
|
|||
throw new IOException("invalid header field ("
|
||||
+ Manifest.getErrorPosition(filename, lineNumber) + ")");
|
||||
}
|
||||
name = new String(lbuf, 0, 0, i - 2);
|
||||
name = new String(lbuf, 0, i - 2, UTF_8);
|
||||
if (is.peek() == ' ') {
|
||||
lastline = new byte[len - i];
|
||||
System.arraycopy(lbuf, i, lastline, 0, len - i);
|
||||
continue;
|
||||
}
|
||||
value = new String(lbuf, i, len - i, "UTF8");
|
||||
value = new String(lbuf, i, len - i, UTF_8);
|
||||
}
|
||||
try {
|
||||
if ((putValue(name, value) != null) && (!lineContinued)) {
|
||||
|
|
|
@ -35,6 +35,8 @@ import java.util.Map;
|
|||
|
||||
import sun.security.util.SecurityProperties;
|
||||
|
||||
import static java.nio.charset.StandardCharsets.UTF_8;
|
||||
|
||||
/**
|
||||
* The Manifest class is used to maintain Manifest entry names and their
|
||||
* associated Attributes. There are main Manifest Attributes as well as
|
||||
|
@ -197,31 +199,28 @@ public class Manifest implements Cloneable {
|
|||
* @exception IOException if an I/O error has occurred
|
||||
* @see #getMainAttributes
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public void write(OutputStream out) throws IOException {
|
||||
DataOutputStream dos = new DataOutputStream(out);
|
||||
// Write out the main attributes for the manifest
|
||||
attr.writeMain(dos);
|
||||
// Now write out the per-entry attributes
|
||||
StringBuilder buffer = entries.isEmpty() ? null : new StringBuilder(72);
|
||||
for (Map.Entry<String, Attributes> e : entries.entrySet()) {
|
||||
StringBuffer buffer = new StringBuffer("Name: ");
|
||||
String value = e.getKey();
|
||||
if (value != null) {
|
||||
byte[] vb = value.getBytes("UTF8");
|
||||
value = new String(vb, 0, 0, vb.length);
|
||||
}
|
||||
buffer.append(value);
|
||||
make72Safe(buffer);
|
||||
buffer.append("\r\n");
|
||||
dos.writeBytes(buffer.toString());
|
||||
buffer.setLength(0);
|
||||
buffer.append("Name: ");
|
||||
buffer.append(e.getKey());
|
||||
println72(dos, buffer.toString());
|
||||
e.getValue().write(dos);
|
||||
}
|
||||
dos.flush();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds line breaks to enforce a maximum 72 bytes per line.
|
||||
* Adds line breaks to enforce a maximum of 72 bytes per line.
|
||||
*
|
||||
* @deprecation Replaced with {@link #println72}.
|
||||
*/
|
||||
@Deprecated(since = "13")
|
||||
static void make72Safe(StringBuffer line) {
|
||||
int length = line.length();
|
||||
int index = 72;
|
||||
|
@ -230,7 +229,38 @@ public class Manifest implements Cloneable {
|
|||
index += 74; // + line width + line break ("\r\n")
|
||||
length += 3; // + line break ("\r\n") and space
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes {@code line} to {@code out} with line breaks and continuation
|
||||
* spaces within the limits of 72 bytes of contents per line followed
|
||||
* by a line break.
|
||||
*/
|
||||
static void println72(OutputStream out, String line) throws IOException {
|
||||
if (!line.isEmpty()) {
|
||||
byte[] lineBytes = line.getBytes(UTF_8);
|
||||
int length = lineBytes.length;
|
||||
// first line can hold one byte more than subsequent lines which
|
||||
// start with a continuation line break space
|
||||
out.write(lineBytes[0]);
|
||||
int pos = 1;
|
||||
while (length - pos > 71) {
|
||||
out.write(lineBytes, pos, 71);
|
||||
pos += 71;
|
||||
println(out);
|
||||
out.write(' ');
|
||||
}
|
||||
out.write(lineBytes, pos, length - pos);
|
||||
}
|
||||
println(out);
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a line break to {@code out}.
|
||||
*/
|
||||
static void println(OutputStream out) throws IOException {
|
||||
out.write('\r');
|
||||
out.write('\n');
|
||||
}
|
||||
|
||||
static String getErrorPosition(String filename, final int lineNumber) {
|
||||
|
@ -304,7 +334,7 @@ public class Manifest implements Cloneable {
|
|||
lastline = buf;
|
||||
continue;
|
||||
}
|
||||
name = new String(buf, 0, buf.length, "UTF8");
|
||||
name = new String(buf, 0, buf.length, UTF_8);
|
||||
lastline = null;
|
||||
}
|
||||
Attributes attr = getAttributes(name);
|
||||
|
@ -330,7 +360,7 @@ public class Manifest implements Cloneable {
|
|||
toLower(lbuf[2]) == 'm' && toLower(lbuf[3]) == 'e' &&
|
||||
lbuf[4] == ':' && lbuf[5] == ' ') {
|
||||
try {
|
||||
return new String(lbuf, 6, len - 6, "UTF8");
|
||||
return new String(lbuf, 6, len - 6, UTF_8);
|
||||
}
|
||||
catch (Exception e) {
|
||||
}
|
||||
|
|
|
@ -112,7 +112,7 @@ public abstract class Pack200 {
|
|||
/**
|
||||
* Obtain new instance of a class that implements Packer.
|
||||
* <ul>
|
||||
* <li><p>If the system property {@code java.util.jar.Pack200.Packer}
|
||||
* <li><p>If the system property {@systemProperty java.util.jar.Pack200.Packer}
|
||||
* is defined, then the value is taken to be the fully-qualified name
|
||||
* of a concrete implementation class, which must implement Packer.
|
||||
* This class is loaded and instantiated. If this process fails
|
||||
|
@ -138,7 +138,7 @@ public abstract class Pack200 {
|
|||
/**
|
||||
* Obtain new instance of a class that implements Unpacker.
|
||||
* <ul>
|
||||
* <li><p>If the system property {@code java.util.jar.Pack200.Unpacker}
|
||||
* <li><p>If the system property {@systemProperty java.util.jar.Pack200.Unpacker}
|
||||
* is defined, then the value is taken to be the fully-qualified
|
||||
* name of a concrete implementation class, which must implement Unpacker.
|
||||
* The class is loaded and instantiated. If this process fails
|
||||
|
|
|
@ -1390,7 +1390,7 @@ public final class Pattern
|
|||
localTCNCount = 0;
|
||||
|
||||
// if length > 0, the Pattern is lazily compiled
|
||||
if (pattern.length() == 0) {
|
||||
if (pattern.isEmpty()) {
|
||||
root = new Start(lastAccept);
|
||||
matchRoot = lastAccept;
|
||||
compiled = true;
|
||||
|
@ -1423,7 +1423,7 @@ public final class Pattern
|
|||
localCount = 0;
|
||||
localTCNCount = 0;
|
||||
|
||||
if (pattern.length() > 0) {
|
||||
if (!pattern.isEmpty()) {
|
||||
compile();
|
||||
} else {
|
||||
root = new Start(lastAccept);
|
||||
|
|
|
@ -113,7 +113,7 @@ import java.util.Locale;
|
|||
* described above as if the locale was not supported.
|
||||
* <p>
|
||||
* The search order of locale sensitive services can
|
||||
* be configured by using the "java.locale.providers" system property.
|
||||
* be configured by using the {@systemProperty java.locale.providers} system property.
|
||||
* This system property declares the user's preferred order for looking up
|
||||
* the locale sensitive services separated by a comma. It is only read at
|
||||
* the Java runtime startup, so the later call to System.setProperty() won't
|
||||
|
|
|
@ -341,7 +341,7 @@ public class Cipher {
|
|||
throw new NoSuchAlgorithmException("Invalid transformation " +
|
||||
"format:" + transformation);
|
||||
}
|
||||
if ((parts[0] == null) || (parts[0].length() == 0)) {
|
||||
if ((parts[0] == null) || (parts[0].isEmpty())) {
|
||||
throw new NoSuchAlgorithmException("Invalid transformation:" +
|
||||
"algorithm not specified-"
|
||||
+ transformation);
|
||||
|
@ -445,10 +445,10 @@ public class Cipher {
|
|||
String alg = parts[0];
|
||||
String mode = parts[1];
|
||||
String pad = parts[2];
|
||||
if ((mode != null) && (mode.length() == 0)) {
|
||||
if ((mode != null) && (mode.isEmpty())) {
|
||||
mode = null;
|
||||
}
|
||||
if ((pad != null) && (pad.length() == 0)) {
|
||||
if ((pad != null) && (pad.isEmpty())) {
|
||||
pad = null;
|
||||
}
|
||||
|
||||
|
@ -634,7 +634,7 @@ public class Cipher {
|
|||
if ((transformation == null) || transformation.isEmpty()) {
|
||||
throw new NoSuchAlgorithmException("Null or empty transformation");
|
||||
}
|
||||
if ((provider == null) || (provider.length() == 0)) {
|
||||
if ((provider == null) || (provider.isEmpty())) {
|
||||
throw new IllegalArgumentException("Missing provider");
|
||||
}
|
||||
Provider p = Security.getProvider(provider);
|
||||
|
|
|
@ -337,7 +337,7 @@ public class SealedObject implements Serializable {
|
|||
if (key == null) {
|
||||
throw new NullPointerException("key is null");
|
||||
}
|
||||
if (provider == null || provider.length() == 0) {
|
||||
if (provider == null || provider.isEmpty()) {
|
||||
throw new IllegalArgumentException("missing provider");
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -187,7 +187,7 @@ public interface SSLSession {
|
|||
* Removes the object bound to the given name in the session's
|
||||
* application layer data. Does nothing if there is no object
|
||||
* bound to the given name. If the bound existing object
|
||||
* implements the {@code SessionBindingListener} interface,
|
||||
* implements the {@code SSLSessionBindingListener} interface,
|
||||
* it is notified appropriately.
|
||||
* <p>
|
||||
* For security reasons, the same named values may not be
|
||||
|
|
|
@ -133,7 +133,7 @@ public abstract class SSLSocketFactory extends SocketFactory
|
|||
String s = java.security.Security.getProperty(name);
|
||||
if (s != null) {
|
||||
s = s.trim();
|
||||
if (s.length() == 0) {
|
||||
if (s.isEmpty()) {
|
||||
s = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -312,7 +312,7 @@ public final class PrivateCredentialPermission extends Permission {
|
|||
|
||||
private void init(String name) {
|
||||
|
||||
if (name == null || name.trim().length() == 0) {
|
||||
if (name == null || name.trim().isEmpty()) {
|
||||
throw new IllegalArgumentException("invalid empty name");
|
||||
}
|
||||
|
||||
|
|
|
@ -98,13 +98,13 @@ public class ChoiceCallback implements Callback, java.io.Serializable {
|
|||
public ChoiceCallback(String prompt, String[] choices,
|
||||
int defaultChoice, boolean multipleSelectionsAllowed) {
|
||||
|
||||
if (prompt == null || prompt.length() == 0 ||
|
||||
if (prompt == null || prompt.isEmpty() ||
|
||||
choices == null || choices.length == 0 ||
|
||||
defaultChoice < 0 || defaultChoice >= choices.length)
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -248,7 +248,7 @@ public class ConfirmationCallback implements Callback, java.io.Serializable {
|
|||
throw new IllegalArgumentException();
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -294,7 +294,7 @@ public class ConfirmationCallback implements Callback, java.io.Serializable {
|
|||
public ConfirmationCallback(String prompt, int messageType,
|
||||
int optionType, int defaultOption) {
|
||||
|
||||
if (prompt == null || prompt.length() == 0 ||
|
||||
if (prompt == null || prompt.isEmpty() ||
|
||||
messageType < INFORMATION || messageType > ERROR ||
|
||||
optionType < YES_NO_OPTION || optionType > OK_CANCEL_OPTION)
|
||||
throw new IllegalArgumentException();
|
||||
|
@ -357,14 +357,14 @@ public class ConfirmationCallback implements Callback, java.io.Serializable {
|
|||
public ConfirmationCallback(String prompt, int messageType,
|
||||
String[] options, int defaultOption) {
|
||||
|
||||
if (prompt == null || prompt.length() == 0 ||
|
||||
if (prompt == null || prompt.isEmpty() ||
|
||||
messageType < INFORMATION || messageType > ERROR ||
|
||||
options == null || options.length == 0 ||
|
||||
defaultOption < 0 || defaultOption >= options.length)
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ public class NameCallback implements Callback, java.io.Serializable {
|
|||
* or if {@code prompt} has a length of 0.
|
||||
*/
|
||||
public NameCallback(String prompt) {
|
||||
if (prompt == null || prompt.length() == 0)
|
||||
if (prompt == null || prompt.isEmpty())
|
||||
throw new IllegalArgumentException();
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
@ -82,8 +82,8 @@ public class NameCallback implements Callback, java.io.Serializable {
|
|||
* or if {@code defaultName} has a length of 0.
|
||||
*/
|
||||
public NameCallback(String prompt, String defaultName) {
|
||||
if (prompt == null || prompt.length() == 0 ||
|
||||
defaultName == null || defaultName.length() == 0)
|
||||
if (prompt == null || prompt.isEmpty() ||
|
||||
defaultName == null || defaultName.isEmpty())
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
this.prompt = prompt;
|
||||
|
|
|
@ -67,7 +67,7 @@ public class PasswordCallback implements Callback, java.io.Serializable {
|
|||
* if {@code prompt} has a length of 0.
|
||||
*/
|
||||
public PasswordCallback(String prompt, boolean echoOn) {
|
||||
if (prompt == null || prompt.length() == 0)
|
||||
if (prompt == null || prompt.isEmpty())
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
this.prompt = prompt;
|
||||
|
|
|
@ -63,7 +63,7 @@ public class TextInputCallback implements Callback, java.io.Serializable {
|
|||
* or if {@code prompt} has a length of 0.
|
||||
*/
|
||||
public TextInputCallback(String prompt) {
|
||||
if (prompt == null || prompt.length() == 0)
|
||||
if (prompt == null || prompt.isEmpty())
|
||||
throw new IllegalArgumentException();
|
||||
this.prompt = prompt;
|
||||
}
|
||||
|
@ -83,8 +83,8 @@ public class TextInputCallback implements Callback, java.io.Serializable {
|
|||
* or if {@code defaultText} has a length of 0.
|
||||
*/
|
||||
public TextInputCallback(String prompt, String defaultText) {
|
||||
if (prompt == null || prompt.length() == 0 ||
|
||||
defaultText == null || defaultText.length() == 0)
|
||||
if (prompt == null || prompt.isEmpty() ||
|
||||
defaultText == null || defaultText.isEmpty())
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
this.prompt = prompt;
|
||||
|
|
|
@ -74,7 +74,7 @@ public class TextOutputCallback implements Callback, java.io.Serializable {
|
|||
public TextOutputCallback(int messageType, String message) {
|
||||
if ((messageType != INFORMATION &&
|
||||
messageType != WARNING && messageType != ERROR) ||
|
||||
message == null || message.length() == 0)
|
||||
message == null || message.isEmpty())
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
this.messageType = messageType;
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue