Skip to content

Commit e918a59

Browse files
committed
8357821: Revert incorrectly named JavaLangAccess::unchecked* methods
Reviewed-by: pminborg
1 parent 28acca6 commit e918a59

File tree

12 files changed

+25
-25
lines changed

12 files changed

+25
-25
lines changed

src/java.base/share/classes/java/io/DataInputStream.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,7 @@ public static final String readUTF(DataInput in) throws IOException {
595595
int chararr_count=0;
596596

597597
in.readFully(bytearr, 0, utflen);
598-
int ascii = JLA.uncheckedCountPositives(bytearr, 0, utflen);
598+
int ascii = JLA.countPositives(bytearr, 0, utflen);
599599
if (ascii == utflen) {
600600
String str;
601601
if (trusted) {
@@ -621,7 +621,7 @@ public static final String readUTF(DataInput in) throws IOException {
621621
}
622622

623623
if (ascii != 0) {
624-
JLA.uncheckedInflateBytesToChars(bytearr, 0, chararr, 0, ascii);
624+
JLA.inflateBytesToChars(bytearr, 0, chararr, 0, ascii);
625625
count += ascii;
626626
chararr_count += ascii;
627627
}

src/java.base/share/classes/java/io/ObjectInputStream.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3536,7 +3536,7 @@ private String readUTFBody(long utflen) throws IOException {
35363536
if (utflen > 0 && utflen < Integer.MAX_VALUE) {
35373537
// Scan for leading ASCII chars
35383538
int avail = end - pos;
3539-
int ascii = JLA.uncheckedCountPositives(buf, pos, Math.min(avail, (int)utflen));
3539+
int ascii = JLA.countPositives(buf, pos, Math.min(avail, (int)utflen));
35403540
if (ascii == utflen) {
35413541
// Complete match, consume the buf[pos ... pos + ascii] range and return.
35423542
// Modified UTF-8 and ISO-8859-1 are both ASCII-compatible encodings bytes
@@ -3549,7 +3549,7 @@ private String readUTFBody(long utflen) throws IOException {
35493549
// Avoid allocating a StringBuilder if there's enough data in buf and
35503550
// cbuf is large enough
35513551
if (avail >= utflen && utflen <= CHAR_BUF_SIZE) {
3552-
JLA.uncheckedInflateBytesToChars(buf, pos, cbuf, 0, ascii);
3552+
JLA.inflateBytesToChars(buf, pos, cbuf, 0, ascii);
35533553
pos += ascii;
35543554
int cbufPos = readUTFSpan(ascii, utflen - ascii);
35553555
return new String(cbuf, 0, cbufPos);

src/java.base/share/classes/java/lang/System.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2118,7 +2118,7 @@ public Stream<ModuleLayer> layers(ClassLoader loader) {
21182118
return ModuleLayer.layers(loader);
21192119
}
21202120

2121-
public int uncheckedCountPositives(byte[] bytes, int offset, int length) {
2121+
public int countPositives(byte[] bytes, int offset, int length) {
21222122
return StringCoding.countPositives(bytes, offset, length);
21232123
}
21242124
public int countNonZeroAscii(String s) {
@@ -2145,11 +2145,11 @@ public byte[] getBytesUTF8NoRepl(String s) {
21452145
return String.getBytesUTF8NoRepl(s);
21462146
}
21472147

2148-
public void uncheckedInflateBytesToChars(byte[] src, int srcOff, char[] dst, int dstOff, int len) {
2148+
public void inflateBytesToChars(byte[] src, int srcOff, char[] dst, int dstOff, int len) {
21492149
StringLatin1.inflate(src, srcOff, dst, dstOff, len);
21502150
}
21512151

2152-
public int uncheckedDecodeASCII(byte[] src, int srcOff, char[] dst, int dstOff, int len) {
2152+
public int decodeASCII(byte[] src, int srcOff, char[] dst, int dstOff, int len) {
21532153
return String.decodeASCII(src, srcOff, dst, dstOff, len);
21542154
}
21552155

src/java.base/share/classes/java/util/zip/ZipCoder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ int checkedHash(byte[] a, int off, int len) throws Exception {
266266
return 0;
267267
}
268268
int end = off + len;
269-
int asciiLen = JLA.uncheckedCountPositives(a, off, len);
269+
int asciiLen = JLA.countPositives(a, off, len);
270270
if (asciiLen != len) {
271271
// Non-ASCII, fall back to decoding a String
272272
// We avoid using decoder() here since the UTF8ZipCoder is

src/java.base/share/classes/jdk/internal/access/JavaLangAccess.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -302,10 +302,10 @@ public interface JavaLangAccess {
302302

303303
/**
304304
* Count the number of leading positive bytes in the range.
305-
* <p>
306-
* <b>WARNING: This method does not perform any bound checks.</b>
305+
*
306+
* @implSpec Implementations of this method must perform bounds checks.
307307
*/
308-
int uncheckedCountPositives(byte[] ba, int off, int len);
308+
int countPositives(byte[] ba, int off, int len);
309309

310310
/**
311311
* Count the number of leading non-zero ascii chars in the String.
@@ -390,20 +390,20 @@ public interface JavaLangAccess {
390390
/**
391391
* Inflated copy from {@code byte[]} to {@code char[]}, as defined by
392392
* {@code StringLatin1.inflate}.
393-
* <p>
394-
* <b>WARNING: This method does not perform any bound checks.</b>
393+
*
394+
* @implSpec Implementations of this method must perform bounds checks.
395395
*/
396-
void uncheckedInflateBytesToChars(byte[] src, int srcOff, char[] dst, int dstOff, int len);
396+
void inflateBytesToChars(byte[] src, int srcOff, char[] dst, int dstOff, int len);
397397

398398
/**
399399
* Decodes ASCII from the source byte array into the destination
400400
* char array.
401-
* <p>
402-
* <b>WARNING: This method does not perform any bound checks.</b>
401+
*
402+
* @implSpec Implementations of this method must perform bounds checks.
403403
*
404404
* @return the number of bytes successfully decoded, at most len
405405
*/
406-
int uncheckedDecodeASCII(byte[] src, int srcOff, char[] dst, int dstOff, int len);
406+
int decodeASCII(byte[] src, int srcOff, char[] dst, int dstOff, int len);
407407

408408
/**
409409
* Returns the initial `System.in` to determine if it is replaced

src/java.base/share/classes/jdk/internal/classfile/impl/AbstractPoolEntry.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public int tag() {
218218
* two-times-three-byte format instead.
219219
*/
220220
private void inflate() {
221-
int singleBytes = JLA.uncheckedCountPositives(rawBytes, offset, rawLen);
221+
int singleBytes = JLA.countPositives(rawBytes, offset, rawLen);
222222
int hash = ArraysSupport.hashCodeOfUnsigned(rawBytes, offset, singleBytes, 0);
223223
if (singleBytes == rawLen) {
224224
this.contentHash = hash;
@@ -233,7 +233,7 @@ private void inflateNonAscii(int singleBytes, int hash) {
233233
char[] chararr = new char[rawLen];
234234
int chararr_count = singleBytes;
235235
// Inflate prefix of bytes to characters
236-
JLA.uncheckedInflateBytesToChars(rawBytes, offset, chararr, 0, singleBytes);
236+
JLA.inflateBytesToChars(rawBytes, offset, chararr, 0, singleBytes);
237237

238238
int px = offset + singleBytes;
239239
int utfend = offset + rawLen;

src/java.base/share/classes/sun/nio/cs/CESU_8.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ private CoderResult decodeArrayLoop(ByteBuffer src,
196196
int dp = doff + dst.position();
197197
int dl = doff + dst.limit();
198198

199-
int n = JLA.uncheckedDecodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp));
199+
int n = JLA.decodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp));
200200
sp += n;
201201
dp += n;
202202

src/java.base/share/classes/sun/nio/cs/DoubleByte.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ protected CoderResult decodeArrayLoop(ByteBuffer src, CharBuffer dst) {
168168

169169
try {
170170
if (isASCIICompatible) {
171-
int n = JLA.uncheckedDecodeASCII(sa, sp, da, dp, Math.min(dl - dp, sl - sp));
171+
int n = JLA.decodeASCII(sa, sp, da, dp, Math.min(dl - dp, sl - sp));
172172
dp += n;
173173
sp += n;
174174
}

src/java.base/share/classes/sun/nio/cs/ISO_8859_1.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ private CoderResult decodeArrayLoop(ByteBuffer src,
8787
int dl = doff + dst.limit();
8888

8989
int decodeLen = Math.min(sl - sp, dl - dp);
90-
JLA.uncheckedInflateBytesToChars(sa, sp, da, dp, decodeLen);
90+
JLA.inflateBytesToChars(sa, sp, da, dp, decodeLen);
9191
sp += decodeLen;
9292
dp += decodeLen;
9393
src.position(sp - soff);

src/java.base/share/classes/sun/nio/cs/SingleByte.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ private CoderResult decodeArrayLoop(ByteBuffer src, CharBuffer dst) {
9595
}
9696

9797
if (isASCIICompatible) {
98-
int n = JLA.uncheckedDecodeASCII(sa, sp, da, dp, Math.min(dl - dp, sl - sp));
98+
int n = JLA.decodeASCII(sa, sp, da, dp, Math.min(dl - dp, sl - sp));
9999
sp += n;
100100
dp += n;
101101
}

0 commit comments

Comments
 (0)