mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-02 14:38:28 +00:00
8353197: Document preconditions for JavaLangAccess methods
Reviewed-by: pminborg, liach
This commit is contained in:
parent
3df8ca1eba
commit
8fcfddb2d2
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1994, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1994, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2024, Alibaba Group Holding Limited. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
@ -595,11 +595,11 @@ loop: while (true) {
|
||||
int chararr_count=0;
|
||||
|
||||
in.readFully(bytearr, 0, utflen);
|
||||
int ascii = JLA.countPositives(bytearr, 0, utflen);
|
||||
int ascii = JLA.uncheckedCountPositives(bytearr, 0, utflen);
|
||||
if (ascii == utflen) {
|
||||
String str;
|
||||
if (trusted) {
|
||||
str = JLA.newStringNoRepl(bytearr, StandardCharsets.ISO_8859_1);
|
||||
str = JLA.uncheckedNewStringNoRepl(bytearr, StandardCharsets.ISO_8859_1);
|
||||
} else {
|
||||
str = new String(bytearr, 0, utflen, StandardCharsets.ISO_8859_1);
|
||||
}
|
||||
@ -621,7 +621,7 @@ loop: while (true) {
|
||||
}
|
||||
|
||||
if (ascii != 0) {
|
||||
JLA.inflateBytesToChars(bytearr, 0, chararr, 0, ascii);
|
||||
JLA.uncheckedInflateBytesToChars(bytearr, 0, chararr, 0, ascii);
|
||||
count += ascii;
|
||||
chararr_count += ascii;
|
||||
}
|
||||
|
||||
@ -3536,7 +3536,7 @@ public class ObjectInputStream
|
||||
if (utflen > 0 && utflen < Integer.MAX_VALUE) {
|
||||
// Scan for leading ASCII chars
|
||||
int avail = end - pos;
|
||||
int ascii = JLA.countPositives(buf, pos, Math.min(avail, (int)utflen));
|
||||
int ascii = JLA.uncheckedCountPositives(buf, pos, Math.min(avail, (int)utflen));
|
||||
if (ascii == utflen) {
|
||||
// Complete match, consume the buf[pos ... pos + ascii] range and return.
|
||||
// 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
|
||||
// cbuf is large enough
|
||||
if (avail >= utflen && utflen <= CHAR_BUF_SIZE) {
|
||||
JLA.inflateBytesToChars(buf, pos, cbuf, 0, ascii);
|
||||
JLA.uncheckedInflateBytesToChars(buf, pos, cbuf, 0, ascii);
|
||||
pos += ascii;
|
||||
int cbufPos = readUTFSpan(ascii, utflen - ascii);
|
||||
return new String(cbuf, 0, cbufPos);
|
||||
|
||||
@ -2118,22 +2118,22 @@ public final class System {
|
||||
return ModuleLayer.layers(loader);
|
||||
}
|
||||
|
||||
public int countPositives(byte[] bytes, int offset, int length) {
|
||||
public int uncheckedCountPositives(byte[] bytes, int offset, int length) {
|
||||
return StringCoding.countPositives(bytes, offset, length);
|
||||
}
|
||||
public int countNonZeroAscii(String s) {
|
||||
return StringCoding.countNonZeroAscii(s);
|
||||
}
|
||||
public String newStringNoRepl(byte[] bytes, Charset cs) throws CharacterCodingException {
|
||||
public String uncheckedNewStringNoRepl(byte[] bytes, Charset cs) throws CharacterCodingException {
|
||||
return String.newStringNoRepl(bytes, cs);
|
||||
}
|
||||
public char getUTF16Char(byte[] bytes, int index) {
|
||||
public char uncheckedGetUTF16Char(byte[] bytes, int index) {
|
||||
return StringUTF16.getChar(bytes, index);
|
||||
}
|
||||
public void putCharUTF16(byte[] bytes, int index, int ch) {
|
||||
public void uncheckedPutCharUTF16(byte[] bytes, int index, int ch) {
|
||||
StringUTF16.putChar(bytes, index, ch);
|
||||
}
|
||||
public byte[] getBytesNoRepl(String s, Charset cs) throws CharacterCodingException {
|
||||
public byte[] uncheckedGetBytesNoRepl(String s, Charset cs) throws CharacterCodingException {
|
||||
return String.getBytesNoRepl(s, cs);
|
||||
}
|
||||
|
||||
@ -2145,15 +2145,15 @@ public final class System {
|
||||
return String.getBytesUTF8NoRepl(s);
|
||||
}
|
||||
|
||||
public void inflateBytesToChars(byte[] src, int srcOff, char[] dst, int dstOff, int len) {
|
||||
public void uncheckedInflateBytesToChars(byte[] src, int srcOff, char[] dst, int dstOff, int len) {
|
||||
StringLatin1.inflate(src, srcOff, dst, dstOff, len);
|
||||
}
|
||||
|
||||
public int decodeASCII(byte[] src, int srcOff, char[] dst, int dstOff, int len) {
|
||||
public int uncheckedDecodeASCII(byte[] src, int srcOff, char[] dst, int dstOff, int len) {
|
||||
return String.decodeASCII(src, srcOff, dst, dstOff, len);
|
||||
}
|
||||
|
||||
public int encodeASCII(char[] src, int srcOff, byte[] dst, int dstOff, int len) {
|
||||
public int uncheckedEncodeASCII(char[] src, int srcOff, byte[] dst, int dstOff, int len) {
|
||||
return StringCoding.implEncodeAsciiArray(src, srcOff, dst, dstOff, len);
|
||||
}
|
||||
|
||||
@ -2189,7 +2189,7 @@ public final class System {
|
||||
return StringConcatHelper.mix(lengthCoder, value);
|
||||
}
|
||||
|
||||
public Object stringConcat1(String[] constants) {
|
||||
public Object uncheckedStringConcat1(String[] constants) {
|
||||
return new StringConcatHelper.Concat1(constants);
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2024, Alibaba Group Holding Limited. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
@ -1258,7 +1258,7 @@ public final class StringConcatFactory {
|
||||
|
||||
// 1 argument use built-in method
|
||||
if (args.parameterCount() == 1) {
|
||||
Object concat1 = JLA.stringConcat1(constants);
|
||||
Object concat1 = JLA.uncheckedStringConcat1(constants);
|
||||
var handle = lookup.findVirtual(concat1.getClass(), METHOD_NAME, concatArgs);
|
||||
return handle.bindTo(concat1);
|
||||
}
|
||||
|
||||
@ -4142,7 +4142,7 @@ public class BigDecimal extends Number implements Comparable<BigDecimal> {
|
||||
buf[highIntSize] = '.';
|
||||
DecimalDigits.putPairLatin1(buf, highIntSize + 1, lowInt);
|
||||
try {
|
||||
return JLA.newStringNoRepl(buf, StandardCharsets.ISO_8859_1);
|
||||
return JLA.uncheckedNewStringNoRepl(buf, StandardCharsets.ISO_8859_1);
|
||||
} catch (CharacterCodingException cce) {
|
||||
throw new AssertionError(cce);
|
||||
}
|
||||
|
||||
@ -3043,7 +3043,7 @@ public final class Files {
|
||||
byte[] ba = readAllBytes(path);
|
||||
if (path.getClass().getModule() != Object.class.getModule())
|
||||
ba = ba.clone();
|
||||
return JLA.newStringNoRepl(ba, cs);
|
||||
return JLA.uncheckedNewStringNoRepl(ba, cs);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -3362,7 +3362,7 @@ public final class Files {
|
||||
Objects.requireNonNull(csq);
|
||||
Objects.requireNonNull(cs);
|
||||
|
||||
byte[] bytes = JLA.getBytesNoRepl(String.valueOf(csq), cs);
|
||||
byte[] bytes = JLA.uncheckedGetBytesNoRepl(String.valueOf(csq), cs);
|
||||
if (path.getClass().getModule() != Object.class.getModule())
|
||||
bytes = bytes.clone();
|
||||
write(path, bytes, options);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2020, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2024, Alibaba Group Holding Limited. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
@ -462,7 +462,7 @@ public final class HexFormat {
|
||||
}
|
||||
try {
|
||||
// Return a new string using the bytes without making a copy
|
||||
return jla.newStringNoRepl(rep, StandardCharsets.ISO_8859_1);
|
||||
return jla.uncheckedNewStringNoRepl(rep, StandardCharsets.ISO_8859_1);
|
||||
} catch (CharacterCodingException cce) {
|
||||
throw new AssertionError(cce);
|
||||
}
|
||||
@ -696,7 +696,7 @@ public final class HexFormat {
|
||||
rep[0] = (byte)toHighHexDigit(value);
|
||||
rep[1] = (byte)toLowHexDigit(value);
|
||||
try {
|
||||
return jla.newStringNoRepl(rep, StandardCharsets.ISO_8859_1);
|
||||
return jla.uncheckedNewStringNoRepl(rep, StandardCharsets.ISO_8859_1);
|
||||
} catch (CharacterCodingException cce) {
|
||||
throw new AssertionError(cce);
|
||||
}
|
||||
@ -732,7 +732,7 @@ public final class HexFormat {
|
||||
rep[3] = (byte)toLowHexDigit((byte)value);
|
||||
|
||||
try {
|
||||
return jla.newStringNoRepl(rep, StandardCharsets.ISO_8859_1);
|
||||
return jla.uncheckedNewStringNoRepl(rep, StandardCharsets.ISO_8859_1);
|
||||
} catch (CharacterCodingException cce) {
|
||||
throw new AssertionError(cce);
|
||||
}
|
||||
@ -760,7 +760,7 @@ public final class HexFormat {
|
||||
rep[7] = (byte)toLowHexDigit((byte)value);
|
||||
|
||||
try {
|
||||
return jla.newStringNoRepl(rep, StandardCharsets.ISO_8859_1);
|
||||
return jla.uncheckedNewStringNoRepl(rep, StandardCharsets.ISO_8859_1);
|
||||
} catch (CharacterCodingException cce) {
|
||||
throw new AssertionError(cce);
|
||||
}
|
||||
@ -796,7 +796,7 @@ public final class HexFormat {
|
||||
rep[15] = (byte)toLowHexDigit((byte)value);
|
||||
|
||||
try {
|
||||
return jla.newStringNoRepl(rep, StandardCharsets.ISO_8859_1);
|
||||
return jla.uncheckedNewStringNoRepl(rep, StandardCharsets.ISO_8859_1);
|
||||
} catch (CharacterCodingException cce) {
|
||||
throw new AssertionError(cce);
|
||||
}
|
||||
@ -824,7 +824,7 @@ public final class HexFormat {
|
||||
value = value >>> 4;
|
||||
}
|
||||
try {
|
||||
return jla.newStringNoRepl(rep, StandardCharsets.ISO_8859_1);
|
||||
return jla.uncheckedNewStringNoRepl(rep, StandardCharsets.ISO_8859_1);
|
||||
} catch (CharacterCodingException cce) {
|
||||
throw new AssertionError(cce);
|
||||
}
|
||||
|
||||
@ -481,7 +481,7 @@ public final class UUID implements java.io.Serializable, Comparable<UUID> {
|
||||
HexDigits.put4(buf, 28, i3 >> 16);
|
||||
HexDigits.put4(buf, 32, i3);
|
||||
try {
|
||||
return jla.newStringNoRepl(buf, StandardCharsets.ISO_8859_1);
|
||||
return jla.uncheckedNewStringNoRepl(buf, StandardCharsets.ISO_8859_1);
|
||||
} catch (CharacterCodingException cce) {
|
||||
throw new AssertionError(cce);
|
||||
}
|
||||
|
||||
@ -266,7 +266,7 @@ class ZipCoder {
|
||||
return 0;
|
||||
}
|
||||
int end = off + len;
|
||||
int asciiLen = JLA.countPositives(a, off, len);
|
||||
int asciiLen = JLA.uncheckedCountPositives(a, off, len);
|
||||
if (asciiLen != len) {
|
||||
// Non-ASCII, fall back to decoding a String
|
||||
// We avoid using decoder() here since the UTF8ZipCoder is
|
||||
@ -289,7 +289,7 @@ class ZipCoder {
|
||||
@Override
|
||||
byte compare(String str, byte[] b, int off, int len, boolean matchDirectory) {
|
||||
try {
|
||||
byte[] encoded = JLA.getBytesNoRepl(str, UTF_8.INSTANCE);
|
||||
byte[] encoded = JLA.uncheckedGetBytesNoRepl(str, UTF_8.INSTANCE);
|
||||
int mismatch = Arrays.mismatch(encoded, 0, encoded.length, b, off, off+len);
|
||||
if (mismatch == -1) {
|
||||
return EXACT_MATCH;
|
||||
|
||||
@ -302,8 +302,10 @@ public interface JavaLangAccess {
|
||||
|
||||
/**
|
||||
* Count the number of leading positive bytes in the range.
|
||||
* <p>
|
||||
* <b>WARNING: This method does not perform any bound checks.</b>
|
||||
*/
|
||||
int countPositives(byte[] ba, int off, int len);
|
||||
int uncheckedCountPositives(byte[] ba, int off, int len);
|
||||
|
||||
/**
|
||||
* Count the number of leading non-zero ascii chars in the String.
|
||||
@ -311,37 +313,40 @@ public interface JavaLangAccess {
|
||||
int countNonZeroAscii(String s);
|
||||
|
||||
/**
|
||||
* Constructs a new {@code String} by decoding the specified subarray of
|
||||
* bytes using the specified {@linkplain java.nio.charset.Charset charset}.
|
||||
*
|
||||
* The caller of this method shall relinquish and transfer the ownership of
|
||||
* the byte array to the callee since the later will not make a copy.
|
||||
* Constructs a new {@code String} by decoding the specified byte array
|
||||
* using the specified {@linkplain java.nio.charset.Charset charset}.
|
||||
* <p>
|
||||
* <b>WARNING: The caller of this method shall relinquish and transfer the
|
||||
* ownership of the byte array to the callee</b>, since the latter will not
|
||||
* make a copy.
|
||||
*
|
||||
* @param bytes the byte array source
|
||||
* @param cs the Charset
|
||||
* @return the newly created string
|
||||
* @throws CharacterCodingException for malformed or unmappable bytes
|
||||
*/
|
||||
String newStringNoRepl(byte[] bytes, Charset cs) throws CharacterCodingException;
|
||||
String uncheckedNewStringNoRepl(byte[] bytes, Charset cs) throws CharacterCodingException;
|
||||
|
||||
/**
|
||||
* Encode the given string into a sequence of bytes using the specified Charset.
|
||||
*
|
||||
* This method avoids copying the String's internal representation if the input
|
||||
* is ASCII.
|
||||
*
|
||||
* This method throws CharacterCodingException instead of replacing when
|
||||
* malformed input or unmappable characters are encountered.
|
||||
* Encode the given string into a sequence of bytes using the specified
|
||||
* {@linkplain java.nio.charset.Charset charset}.
|
||||
* <p>
|
||||
* <b>WARNING: This method returns the {@code byte[]} backing the provided
|
||||
* {@code String}, if the input is ASCII. Hence, the returned byte array
|
||||
* must not be modified.</b>
|
||||
* <p>
|
||||
* This method throws {@code CharacterCodingException} instead of replacing
|
||||
* when malformed input or unmappable characters are encountered.
|
||||
*
|
||||
* @param s the string to encode
|
||||
* @param cs the charset
|
||||
* @return the encoded bytes
|
||||
* @throws CharacterCodingException for malformed input or unmappable characters
|
||||
*/
|
||||
byte[] getBytesNoRepl(String s, Charset cs) throws CharacterCodingException;
|
||||
byte[] uncheckedGetBytesNoRepl(String s, Charset cs) throws CharacterCodingException;
|
||||
|
||||
/**
|
||||
* Returns a new string by decoding from the given utf8 bytes array.
|
||||
* Returns a new string by decoding from the given UTF-8 bytes array.
|
||||
*
|
||||
* @param off the index of the first byte to decode
|
||||
* @param len the number of bytes to decode
|
||||
@ -351,23 +356,27 @@ public interface JavaLangAccess {
|
||||
String newStringUTF8NoRepl(byte[] bytes, int off, int len);
|
||||
|
||||
/**
|
||||
* Get the char at index in a byte[] in internal UTF-16 representation,
|
||||
* with no bounds checks.
|
||||
* Get the {@code char} at {@code index} in a {@code byte[]} in internal
|
||||
* UTF-16 representation.
|
||||
* <p>
|
||||
* <b>WARNING: This method does not perform any bound checks.</b>
|
||||
*
|
||||
* @param bytes the UTF-16 encoded bytes
|
||||
* @param index of the char to retrieve, 0 <= index < (bytes.length >> 1)
|
||||
* @return the char value
|
||||
*/
|
||||
char getUTF16Char(byte[] bytes, int index);
|
||||
char uncheckedGetUTF16Char(byte[] bytes, int index);
|
||||
|
||||
/**
|
||||
* Put the char at index in a byte[] in internal UTF-16 representation,
|
||||
* with no bounds checks.
|
||||
* Put the {@code ch} at {@code index} in a {@code byte[]} in internal
|
||||
* UTF-16 representation.
|
||||
* <p>
|
||||
* <b>WARNING: This method does not perform any bound checks.</b>
|
||||
*
|
||||
* @param bytes the UTF-16 encoded bytes
|
||||
* @param index of the char to retrieve, 0 <= index < (bytes.length >> 1)
|
||||
*/
|
||||
void putCharUTF16(byte[] bytes, int index, int ch);
|
||||
void uncheckedPutCharUTF16(byte[] bytes, int index, int ch);
|
||||
|
||||
/**
|
||||
* Encode the given string into a sequence of bytes using utf8.
|
||||
@ -379,17 +388,22 @@ public interface JavaLangAccess {
|
||||
byte[] getBytesUTF8NoRepl(String s);
|
||||
|
||||
/**
|
||||
* Inflated copy from byte[] to char[], as defined by StringLatin1.inflate
|
||||
* Inflated copy from {@code byte[]} to {@code char[]}, as defined by
|
||||
* {@code StringLatin1.inflate}.
|
||||
* <p>
|
||||
* <b>WARNING: This method does not perform any bound checks.</b>
|
||||
*/
|
||||
void inflateBytesToChars(byte[] src, int srcOff, char[] dst, int dstOff, int len);
|
||||
void uncheckedInflateBytesToChars(byte[] src, int srcOff, char[] dst, int dstOff, int len);
|
||||
|
||||
/**
|
||||
* Decodes ASCII from the source byte array into the destination
|
||||
* char array.
|
||||
* <p>
|
||||
* <b>WARNING: This method does not perform any bound checks.</b>
|
||||
*
|
||||
* @return the number of bytes successfully decoded, at most len
|
||||
*/
|
||||
int decodeASCII(byte[] src, int srcOff, char[] dst, int dstOff, int len);
|
||||
int uncheckedDecodeASCII(byte[] src, int srcOff, char[] dst, int dstOff, int len);
|
||||
|
||||
/**
|
||||
* Returns the initial `System.in` to determine if it is replaced
|
||||
@ -403,13 +417,15 @@ public interface JavaLangAccess {
|
||||
PrintStream initialSystemErr();
|
||||
|
||||
/**
|
||||
* Encodes ASCII codepoints as possible from the source array into
|
||||
* Encodes as many ASCII codepoints as possible from the source array into
|
||||
* the destination byte array, assuming that the encoding is ASCII
|
||||
* compatible
|
||||
* compatible.
|
||||
* <p>
|
||||
* <b>WARNING: This method does not perform any bound checks.</b>
|
||||
*
|
||||
* @return the number of bytes successfully encoded, or 0 if none
|
||||
*/
|
||||
int encodeASCII(char[] src, int srcOff, byte[] dst, int dstOff, int len);
|
||||
int uncheckedEncodeASCII(char[] src, int srcOff, byte[] dst, int dstOff, int len);
|
||||
|
||||
/**
|
||||
* Set the cause of Throwable
|
||||
@ -442,7 +458,14 @@ public interface JavaLangAccess {
|
||||
*/
|
||||
long stringConcatMix(long lengthCoder, char value);
|
||||
|
||||
Object stringConcat1(String[] constants);
|
||||
/**
|
||||
* Creates helper for string concatenation.
|
||||
* <p>
|
||||
* <b>WARNING: The caller of this method shall relinquish and transfer the
|
||||
* ownership of the string array to the callee</b>, since the latter will not
|
||||
* make a copy.
|
||||
*/
|
||||
Object uncheckedStringConcat1(String[] constants);
|
||||
|
||||
/**
|
||||
* Get the string initial coder, When COMPACT_STRINGS is on, it returns 0, and when it is off, it returns 1.
|
||||
|
||||
@ -218,7 +218,7 @@ public abstract sealed class AbstractPoolEntry {
|
||||
* two-times-three-byte format instead.
|
||||
*/
|
||||
private void inflate() {
|
||||
int singleBytes = JLA.countPositives(rawBytes, offset, rawLen);
|
||||
int singleBytes = JLA.uncheckedCountPositives(rawBytes, offset, rawLen);
|
||||
int hash = ArraysSupport.hashCodeOfUnsigned(rawBytes, offset, singleBytes, 0);
|
||||
if (singleBytes == rawLen) {
|
||||
this.contentHash = hash;
|
||||
@ -233,7 +233,7 @@ public abstract sealed class AbstractPoolEntry {
|
||||
char[] chararr = new char[rawLen];
|
||||
int chararr_count = singleBytes;
|
||||
// Inflate prefix of bytes to characters
|
||||
JLA.inflateBytesToChars(rawBytes, offset, chararr, 0, singleBytes);
|
||||
JLA.uncheckedInflateBytesToChars(rawBytes, offset, chararr, 0, singleBytes);
|
||||
|
||||
int px = offset + singleBytes;
|
||||
int utfend = offset + rawLen;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2024, Alibaba Group Holding Limited. All Rights Reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
@ -58,7 +58,7 @@ abstract sealed class ToDecimal permits DoubleToDecimal, FloatToDecimal {
|
||||
if (latin1) {
|
||||
str[index] = (byte) c;
|
||||
} else {
|
||||
JLA.putCharUTF16(str, index, (char) c);
|
||||
JLA.uncheckedPutCharUTF16(str, index, (char) c);
|
||||
}
|
||||
return index + 1;
|
||||
}
|
||||
@ -93,7 +93,7 @@ abstract sealed class ToDecimal permits DoubleToDecimal, FloatToDecimal {
|
||||
int y = y(m);
|
||||
for (int i = 0; i < 8; ++i) {
|
||||
int t = 10 * y;
|
||||
JLA.putCharUTF16(str, index + i, '0' + (t >>> 28));
|
||||
JLA.uncheckedPutCharUTF16(str, index + i, '0' + (t >>> 28));
|
||||
y = t & MASK_28;
|
||||
}
|
||||
}
|
||||
@ -122,11 +122,11 @@ abstract sealed class ToDecimal permits DoubleToDecimal, FloatToDecimal {
|
||||
++index;
|
||||
}
|
||||
} else {
|
||||
while (JLA.getUTF16Char(str, index - 1) == '0') {
|
||||
while (JLA.uncheckedGetUTF16Char(str, index - 1) == '0') {
|
||||
--index;
|
||||
}
|
||||
/* ... but do not remove the one directly to the right of '.' */
|
||||
if (JLA.getUTF16Char(str, index - 1) == '.') {
|
||||
if (JLA.uncheckedGetUTF16Char(str, index - 1) == '.') {
|
||||
++index;
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,7 +298,7 @@ public class ArraysSupport {
|
||||
public static int hashCodeOfUTF16(byte[] a, int fromIndex, int length, int initialValue) {
|
||||
return switch (length) {
|
||||
case 0 -> initialValue;
|
||||
case 1 -> 31 * initialValue + JLA.getUTF16Char(a, fromIndex);
|
||||
case 1 -> 31 * initialValue + JLA.uncheckedGetUTF16Char(a, fromIndex);
|
||||
default -> vectorizedHashCode(a, fromIndex, length, initialValue, T_CHAR);
|
||||
};
|
||||
}
|
||||
@ -420,7 +420,7 @@ public class ArraysSupport {
|
||||
private static int utf16hashCode(int result, byte[] value, int fromIndex, int length) {
|
||||
int end = fromIndex + length;
|
||||
for (int i = fromIndex; i < end; i++) {
|
||||
result = 31 * result + JLA.getUTF16Char(value, i);
|
||||
result = 31 * result + JLA.uncheckedGetUTF16Char(value, i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2024, 2025, 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
|
||||
@ -168,16 +168,16 @@ public final class HexDigits {
|
||||
public static int getCharsUTF16(long value, int index, byte[] buffer) {
|
||||
while ((value & ~0xFF) != 0) {
|
||||
int pair = (int) DIGITS[((int) value) & 0xFF];
|
||||
JLA.putCharUTF16(buffer, --index, pair >> 8);
|
||||
JLA.putCharUTF16(buffer, --index, pair & 0xFF);
|
||||
JLA.uncheckedPutCharUTF16(buffer, --index, pair >> 8);
|
||||
JLA.uncheckedPutCharUTF16(buffer, --index, pair & 0xFF);
|
||||
value >>>= 8;
|
||||
}
|
||||
|
||||
int digits = DIGITS[(int) (value & 0xFF)];
|
||||
JLA.putCharUTF16(buffer, --index, (byte) (digits >> 8));
|
||||
JLA.uncheckedPutCharUTF16(buffer, --index, (byte) (digits >> 8));
|
||||
|
||||
if (0xF < value) {
|
||||
JLA.putCharUTF16(buffer, --index, (byte) (digits & 0xFF));
|
||||
JLA.uncheckedPutCharUTF16(buffer, --index, (byte) (digits & 0xFF));
|
||||
}
|
||||
|
||||
return index;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2025, 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
|
||||
@ -196,7 +196,7 @@ class CESU_8 extends Unicode
|
||||
int dp = doff + dst.position();
|
||||
int dl = doff + dst.limit();
|
||||
|
||||
int n = JLA.decodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp));
|
||||
int n = JLA.uncheckedDecodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp));
|
||||
sp += n;
|
||||
dp += n;
|
||||
|
||||
@ -446,7 +446,7 @@ class CESU_8 extends Unicode
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
|
||||
// Handle ASCII-only prefix
|
||||
int n = JLA.encodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp));
|
||||
int n = JLA.uncheckedEncodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp));
|
||||
sp += n;
|
||||
dp += n;
|
||||
|
||||
@ -551,7 +551,7 @@ class CESU_8 extends Unicode
|
||||
int dp = 0;
|
||||
|
||||
// Handle ASCII-only prefix
|
||||
int n = JLA.encodeASCII(sa, sp, da, dp, Math.min(len, da.length));
|
||||
int n = JLA.uncheckedEncodeASCII(sa, sp, da, dp, Math.min(len, da.length));
|
||||
sp += n;
|
||||
dp += n;
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2009, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2009, 2025, 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
|
||||
@ -35,9 +35,7 @@ import java.util.Arrays;
|
||||
|
||||
import jdk.internal.access.JavaLangAccess;
|
||||
import jdk.internal.access.SharedSecrets;
|
||||
import sun.nio.cs.Surrogate;
|
||||
import sun.nio.cs.ArrayDecoder;
|
||||
import sun.nio.cs.ArrayEncoder;
|
||||
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
/*
|
||||
@ -170,7 +168,7 @@ public class DoubleByte {
|
||||
|
||||
try {
|
||||
if (isASCIICompatible) {
|
||||
int n = JLA.decodeASCII(sa, sp, da, dp, Math.min(dl - dp, sl - sp));
|
||||
int n = JLA.uncheckedDecodeASCII(sa, sp, da, dp, Math.min(dl - dp, sl - sp));
|
||||
dp += n;
|
||||
sp += n;
|
||||
}
|
||||
@ -602,7 +600,7 @@ public class DoubleByte {
|
||||
|
||||
try {
|
||||
if (isASCIICompatible) {
|
||||
int n = JLA.encodeASCII(sa, sp, da, dp, Math.min(dl - dp, sl - sp));
|
||||
int n = JLA.uncheckedEncodeASCII(sa, sp, da, dp, Math.min(dl - dp, sl - sp));
|
||||
sp += n;
|
||||
dp += n;
|
||||
}
|
||||
@ -688,7 +686,7 @@ public class DoubleByte {
|
||||
int dp = 0;
|
||||
int sl = sp + len;
|
||||
if (isASCIICompatible) {
|
||||
int n = JLA.encodeASCII(src, sp, dst, dp, len);
|
||||
int n = JLA.uncheckedEncodeASCII(src, sp, dst, dp, len);
|
||||
sp += n;
|
||||
dp += n;
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2025, 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
|
||||
@ -87,7 +87,7 @@ public class ISO_8859_1
|
||||
int dl = doff + dst.limit();
|
||||
|
||||
int decodeLen = Math.min(sl - sp, dl - dp);
|
||||
JLA.inflateBytesToChars(sa, sp, da, dp, decodeLen);
|
||||
JLA.uncheckedInflateBytesToChars(sa, sp, da, dp, decodeLen);
|
||||
sp += decodeLen;
|
||||
dp += decodeLen;
|
||||
src.position(sp - soff);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2025, 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
|
||||
@ -35,7 +35,7 @@ import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.util.Arrays;
|
||||
|
||||
import static sun.nio.cs.CharsetMapping.*;
|
||||
|
||||
public class SingleByte
|
||||
@ -95,7 +95,7 @@ public class SingleByte
|
||||
}
|
||||
|
||||
if (isASCIICompatible) {
|
||||
int n = JLA.decodeASCII(sa, sp, da, dp, Math.min(dl - dp, sl - sp));
|
||||
int n = JLA.uncheckedDecodeASCII(sa, sp, da, dp, Math.min(dl - dp, sl - sp));
|
||||
sp += n;
|
||||
dp += n;
|
||||
}
|
||||
@ -217,7 +217,7 @@ public class SingleByte
|
||||
int len = Math.min(dl - dp, sl - sp);
|
||||
|
||||
if (isASCIICompatible) {
|
||||
int n = JLA.encodeASCII(sa, sp, da, dp, len);
|
||||
int n = JLA.uncheckedEncodeASCII(sa, sp, da, dp, len);
|
||||
sp += n;
|
||||
dp += n;
|
||||
len -= n;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2025, 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
|
||||
@ -83,7 +83,7 @@ public class US_ASCII
|
||||
int dl = doff + dst.limit();
|
||||
|
||||
// ASCII only loop
|
||||
int n = JLA.decodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp));
|
||||
int n = JLA.uncheckedDecodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp));
|
||||
sp += n;
|
||||
dp += n;
|
||||
src.position(sp - soff);
|
||||
@ -159,7 +159,7 @@ public class US_ASCII
|
||||
assert (dp <= dl);
|
||||
dp = (dp <= dl ? dp : dl);
|
||||
|
||||
int n = JLA.encodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp));
|
||||
int n = JLA.uncheckedEncodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp));
|
||||
sp += n;
|
||||
dp += n;
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2000, 2025, 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
|
||||
@ -35,7 +35,6 @@ import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CharsetEncoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.nio.charset.CodingErrorAction;
|
||||
|
||||
/* Legal UTF-8 Byte Sequences
|
||||
*
|
||||
@ -228,7 +227,7 @@ public final class UTF_8 extends Unicode {
|
||||
int dp = doff + dst.position();
|
||||
int dl = doff + dst.limit();
|
||||
|
||||
int n = JLA.decodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp));
|
||||
int n = JLA.uncheckedDecodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp));
|
||||
sp += n;
|
||||
dp += n;
|
||||
|
||||
@ -453,7 +452,7 @@ public final class UTF_8 extends Unicode {
|
||||
int dl = dst.arrayOffset() + dst.limit();
|
||||
|
||||
// Handle ASCII-only prefix
|
||||
int n = JLA.encodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp));
|
||||
int n = JLA.uncheckedEncodeASCII(sa, sp, da, dp, Math.min(sl - sp, dl - dp));
|
||||
sp += n;
|
||||
dp += n;
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2008, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2008, 2025, 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
|
||||
@ -126,7 +126,7 @@ class UnixPath implements Path {
|
||||
private static byte[] encode(UnixFileSystem fs, String input) {
|
||||
input = fs.normalizeNativePath(input);
|
||||
try {
|
||||
return JLA.getBytesNoRepl(input, Util.jnuEncoding());
|
||||
return JLA.uncheckedGetBytesNoRepl(input, Util.jnuEncoding());
|
||||
} catch (CharacterCodingException cce) {
|
||||
throw new InvalidPathException(input,
|
||||
"Malformed input or input contains unmappable characters");
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2025, 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
|
||||
@ -309,7 +309,7 @@ public class EUC_JP
|
||||
|
||||
try {
|
||||
if (enc0201.isASCIICompatible()) {
|
||||
int n = JLA.encodeASCII(sa, sp, da, dp, Math.min(dl - dp, sl - sp));
|
||||
int n = JLA.uncheckedEncodeASCII(sa, sp, da, dp, Math.min(dl - dp, sl - sp));
|
||||
sp += n;
|
||||
dp += n;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user