8357821: Revert incorrectly named JavaLangAccess::unchecked* methods

Reviewed-by: pminborg
This commit is contained in:
Volkan Yazici 2025-06-06 06:26:09 +00:00
parent 28acca609b
commit e918a59b1d
12 changed files with 25 additions and 25 deletions

View File

@ -595,7 +595,7 @@ loop: while (true) {
int chararr_count=0; int chararr_count=0;
in.readFully(bytearr, 0, utflen); in.readFully(bytearr, 0, utflen);
int ascii = JLA.uncheckedCountPositives(bytearr, 0, utflen); int ascii = JLA.countPositives(bytearr, 0, utflen);
if (ascii == utflen) { if (ascii == utflen) {
String str; String str;
if (trusted) { if (trusted) {
@ -621,7 +621,7 @@ loop: while (true) {
} }
if (ascii != 0) { if (ascii != 0) {
JLA.uncheckedInflateBytesToChars(bytearr, 0, chararr, 0, ascii); JLA.inflateBytesToChars(bytearr, 0, chararr, 0, ascii);
count += ascii; count += ascii;
chararr_count += ascii; chararr_count += ascii;
} }

View File

@ -3536,7 +3536,7 @@ public class ObjectInputStream
if (utflen > 0 && utflen < Integer.MAX_VALUE) { if (utflen > 0 && utflen < Integer.MAX_VALUE) {
// Scan for leading ASCII chars // Scan for leading ASCII chars
int avail = end - pos; int avail = end - pos;
int ascii = JLA.uncheckedCountPositives(buf, pos, Math.min(avail, (int)utflen)); int ascii = JLA.countPositives(buf, pos, Math.min(avail, (int)utflen));
if (ascii == utflen) { if (ascii == utflen) {
// Complete match, consume the buf[pos ... pos + ascii] range and return. // Complete match, consume the buf[pos ... pos + ascii] range and return.
// Modified UTF-8 and ISO-8859-1 are both ASCII-compatible encodings bytes // Modified UTF-8 and ISO-8859-1 are both ASCII-compatible encodings bytes
@ -3549,7 +3549,7 @@ public class ObjectInputStream
// Avoid allocating a StringBuilder if there's enough data in buf and // Avoid allocating a StringBuilder if there's enough data in buf and
// cbuf is large enough // cbuf is large enough
if (avail >= utflen && utflen <= CHAR_BUF_SIZE) { if (avail >= utflen && utflen <= CHAR_BUF_SIZE) {
JLA.uncheckedInflateBytesToChars(buf, pos, cbuf, 0, ascii); JLA.inflateBytesToChars(buf, pos, cbuf, 0, ascii);
pos += ascii; pos += ascii;
int cbufPos = readUTFSpan(ascii, utflen - ascii); int cbufPos = readUTFSpan(ascii, utflen - ascii);
return new String(cbuf, 0, cbufPos); return new String(cbuf, 0, cbufPos);

View File

@ -2118,7 +2118,7 @@ public final class System {
return ModuleLayer.layers(loader); return ModuleLayer.layers(loader);
} }
public int uncheckedCountPositives(byte[] bytes, int offset, int length) { public int countPositives(byte[] bytes, int offset, int length) {
return StringCoding.countPositives(bytes, offset, length); return StringCoding.countPositives(bytes, offset, length);
} }
public int countNonZeroAscii(String s) { public int countNonZeroAscii(String s) {
@ -2145,11 +2145,11 @@ public final class System {
return String.getBytesUTF8NoRepl(s); return String.getBytesUTF8NoRepl(s);
} }
public void uncheckedInflateBytesToChars(byte[] src, int srcOff, char[] dst, int dstOff, int len) { public void inflateBytesToChars(byte[] src, int srcOff, char[] dst, int dstOff, int len) {
StringLatin1.inflate(src, srcOff, dst, dstOff, len); StringLatin1.inflate(src, srcOff, dst, dstOff, len);
} }
public int uncheckedDecodeASCII(byte[] src, int srcOff, char[] dst, int dstOff, int len) { public int decodeASCII(byte[] src, int srcOff, char[] dst, int dstOff, int len) {
return String.decodeASCII(src, srcOff, dst, dstOff, len); return String.decodeASCII(src, srcOff, dst, dstOff, len);
} }

View File

@ -266,7 +266,7 @@ class ZipCoder {
return 0; return 0;
} }
int end = off + len; int end = off + len;
int asciiLen = JLA.uncheckedCountPositives(a, off, len); int asciiLen = JLA.countPositives(a, off, len);
if (asciiLen != len) { if (asciiLen != len) {
// Non-ASCII, fall back to decoding a String // Non-ASCII, fall back to decoding a String
// We avoid using decoder() here since the UTF8ZipCoder is // We avoid using decoder() here since the UTF8ZipCoder is

View File

@ -302,10 +302,10 @@ public interface JavaLangAccess {
/** /**
* Count the number of leading positive bytes in the range. * Count the number of leading positive bytes in the range.
* <p> *
* <b>WARNING: This method does not perform any bound checks.</b> * @implSpec Implementations of this method must perform bounds checks.
*/ */
int uncheckedCountPositives(byte[] ba, int off, int len); int countPositives(byte[] ba, int off, int len);
/** /**
* Count the number of leading non-zero ascii chars in the String. * Count the number of leading non-zero ascii chars in the String.
@ -390,20 +390,20 @@ public interface JavaLangAccess {
/** /**
* Inflated copy from {@code byte[]} to {@code char[]}, as defined by * Inflated copy from {@code byte[]} to {@code char[]}, as defined by
* {@code StringLatin1.inflate}. * {@code StringLatin1.inflate}.
* <p> *
* <b>WARNING: This method does not perform any bound checks.</b> * @implSpec Implementations of this method must perform bounds checks.
*/ */
void uncheckedInflateBytesToChars(byte[] src, int srcOff, char[] dst, int dstOff, int len); void inflateBytesToChars(byte[] src, int srcOff, char[] dst, int dstOff, int len);
/** /**
* Decodes ASCII from the source byte array into the destination * Decodes ASCII from the source byte array into the destination
* char array. * char array.
* <p> *
* <b>WARNING: This method does not perform any bound checks.</b> * @implSpec Implementations of this method must perform bounds checks.
* *
* @return the number of bytes successfully decoded, at most len * @return the number of bytes successfully decoded, at most len
*/ */
int uncheckedDecodeASCII(byte[] src, int srcOff, char[] dst, int dstOff, int len); int decodeASCII(byte[] src, int srcOff, char[] dst, int dstOff, int len);
/** /**
* Returns the initial `System.in` to determine if it is replaced * Returns the initial `System.in` to determine if it is replaced

View File

@ -218,7 +218,7 @@ public abstract sealed class AbstractPoolEntry {
* two-times-three-byte format instead. * two-times-three-byte format instead.
*/ */
private void inflate() { private void inflate() {
int singleBytes = JLA.uncheckedCountPositives(rawBytes, offset, rawLen); int singleBytes = JLA.countPositives(rawBytes, offset, rawLen);
int hash = ArraysSupport.hashCodeOfUnsigned(rawBytes, offset, singleBytes, 0); int hash = ArraysSupport.hashCodeOfUnsigned(rawBytes, offset, singleBytes, 0);
if (singleBytes == rawLen) { if (singleBytes == rawLen) {
this.contentHash = hash; this.contentHash = hash;
@ -233,7 +233,7 @@ public abstract sealed class AbstractPoolEntry {
char[] chararr = new char[rawLen]; char[] chararr = new char[rawLen];
int chararr_count = singleBytes; int chararr_count = singleBytes;
// Inflate prefix of bytes to characters // Inflate prefix of bytes to characters
JLA.uncheckedInflateBytesToChars(rawBytes, offset, chararr, 0, singleBytes); JLA.inflateBytesToChars(rawBytes, offset, chararr, 0, singleBytes);
int px = offset + singleBytes; int px = offset + singleBytes;
int utfend = offset + rawLen; int utfend = offset + rawLen;

View File

@ -196,7 +196,7 @@ class CESU_8 extends Unicode
int dp = doff + dst.position(); int dp = doff + dst.position();
int dl = doff + dst.limit(); int dl = doff + dst.limit();
int n = JLA.uncheckedDecodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp)); int n = JLA.decodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp));
sp += n; sp += n;
dp += n; dp += n;

View File

@ -168,7 +168,7 @@ public class DoubleByte {
try { try {
if (isASCIICompatible) { if (isASCIICompatible) {
int n = JLA.uncheckedDecodeASCII(sa, sp, da, dp, Math.min(dl - dp, sl - sp)); int n = JLA.decodeASCII(sa, sp, da, dp, Math.min(dl - dp, sl - sp));
dp += n; dp += n;
sp += n; sp += n;
} }

View File

@ -87,7 +87,7 @@ public class ISO_8859_1
int dl = doff + dst.limit(); int dl = doff + dst.limit();
int decodeLen = Math.min(sl - sp, dl - dp); int decodeLen = Math.min(sl - sp, dl - dp);
JLA.uncheckedInflateBytesToChars(sa, sp, da, dp, decodeLen); JLA.inflateBytesToChars(sa, sp, da, dp, decodeLen);
sp += decodeLen; sp += decodeLen;
dp += decodeLen; dp += decodeLen;
src.position(sp - soff); src.position(sp - soff);

View File

@ -95,7 +95,7 @@ public class SingleByte
} }
if (isASCIICompatible) { if (isASCIICompatible) {
int n = JLA.uncheckedDecodeASCII(sa, sp, da, dp, Math.min(dl - dp, sl - sp)); int n = JLA.decodeASCII(sa, sp, da, dp, Math.min(dl - dp, sl - sp));
sp += n; sp += n;
dp += n; dp += n;
} }

View File

@ -83,7 +83,7 @@ public class US_ASCII
int dl = doff + dst.limit(); int dl = doff + dst.limit();
// ASCII only loop // ASCII only loop
int n = JLA.uncheckedDecodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp)); int n = JLA.decodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp));
sp += n; sp += n;
dp += n; dp += n;
src.position(sp - soff); src.position(sp - soff);

View File

@ -227,7 +227,7 @@ public final class UTF_8 extends Unicode {
int dp = doff + dst.position(); int dp = doff + dst.position();
int dl = doff + dst.limit(); int dl = doff + dst.limit();
int n = JLA.uncheckedDecodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp)); int n = JLA.decodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp));
sp += n; sp += n;
dp += n; dp += n;