mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-04 13:10:15 +00:00
Rename getBytesLength to getByteLength
This commit is contained in:
parent
6acd11914b
commit
f23b5c24f6
@ -2116,7 +2116,7 @@ public final class String
|
||||
* @param cs The {@link Charset} used to the compute the length
|
||||
* @since 27
|
||||
*/
|
||||
public int getBytesLength(Charset cs) {
|
||||
public int getByteLength(Charset cs) {
|
||||
Objects.requireNonNull(cs);
|
||||
if (cs == UTF_8.INSTANCE) {
|
||||
return encodedLengthUTF8(coder, value);
|
||||
|
||||
@ -106,9 +106,9 @@ public class Encodings {
|
||||
if (!equals(bs, bytes))
|
||||
throw new Exception(charset + ": String.getBytes failed");
|
||||
|
||||
/* String.getBytesLength(Charset charset) */
|
||||
if (bs.length != str.getBytesLength(charset))
|
||||
throw new Exception(charset + ": String.getBytesLength failed");
|
||||
/* String.getByteLength(Charset charset) */
|
||||
if (bs.length != str.getByteLength(charset))
|
||||
throw new Exception(charset + ": String.getByteLength failed");
|
||||
|
||||
// Calls to String.getBytes(Charset) shouldn't automatically
|
||||
// use the cached thread-local encoder.
|
||||
|
||||
@ -397,11 +397,11 @@ public class Exceptions {
|
||||
}});
|
||||
}
|
||||
|
||||
private static void getBytesLength() {
|
||||
System.out.println("getBytesLength(Charset charset)");
|
||||
private static void getByteLength() {
|
||||
System.out.println("getByteLength(Charset charset)");
|
||||
tryCatch(" null", NullPointerException.class, new Runnable() {
|
||||
public void run() {
|
||||
"foo".getBytesLength((Charset)null);
|
||||
"foo".getByteLength((Charset)null);
|
||||
}});
|
||||
}
|
||||
|
||||
@ -648,7 +648,7 @@ public class Exceptions {
|
||||
// getBytes(Locale)
|
||||
// getBytes(String)
|
||||
// getBytes(Charset)
|
||||
getBytesLength(); // getBytesLength(Charset)
|
||||
getByteLength(); // getByteLength(Charset)
|
||||
contentEquals(); // contentEquals(StringBuffer)
|
||||
compareTo(); // compareTo(String), compareTo(Object)
|
||||
compareToIgnoreCase();// compareToIgnoreCase(String)
|
||||
|
||||
@ -169,11 +169,11 @@ public class TestStringCoding {
|
||||
if (!Arrays.equals(baSC, baNIO)) {
|
||||
throw new RuntimeException("getBytes(cs) failed -> " + cs.name());
|
||||
}
|
||||
//getBytesLength(cs);
|
||||
int getBytesLength = str.getBytesLength(cs);
|
||||
if (baSC.length != getBytesLength) {
|
||||
throw new RuntimeException(String.format("getBytesLength failed (%d != %d) -> %s",
|
||||
baSC.length, getBytesLength, cs.name()));
|
||||
//getByteLength(cs);
|
||||
int getByteLength = str.getByteLength(cs);
|
||||
if (baSC.length != getByteLength) {
|
||||
throw new RuntimeException(String.format("getByteLength failed (%d != %d) -> %s",
|
||||
baSC.length, getByteLength, cs.name()));
|
||||
}
|
||||
return baSC;
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ public class StringLoopJmhBenchmark {
|
||||
}
|
||||
|
||||
@Benchmark
|
||||
public int getBytesLength() throws Exception {
|
||||
return stringData.getBytesLength(StandardCharsets.UTF_8);
|
||||
public int getByteLength() throws Exception {
|
||||
return stringData.getByteLength(StandardCharsets.UTF_8);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user