[K/N] Deprecate ArrayIndexOutOfBoundsException
As a part of efforts to stabilize Native stdlib.
This commit is contained in:
committed by
Space Team
parent
be87b6950c
commit
8e995e6c62
@@ -92,6 +92,8 @@ public actual open class IndexOutOfBoundsException : RuntimeException {
|
||||
actual constructor(message: String?) : super(message)
|
||||
}
|
||||
|
||||
@Deprecated("Use IndexOutOfBoundsException instead.")
|
||||
@DeprecatedSinceKotlin(warningSince = "1.9")
|
||||
public open class ArrayIndexOutOfBoundsException : IndexOutOfBoundsException {
|
||||
|
||||
constructor() : super()
|
||||
|
||||
@@ -9,33 +9,33 @@ import kotlin.native.internal.GCUnsafeCall
|
||||
/**
|
||||
* Those operations allows to extract primitive values out of the [ByteArray] byte buffers.
|
||||
* Data is treated as if it was in Least-Significant-Byte first (little-endian) byte order.
|
||||
* If index is outside of array boundaries - [ArrayIndexOutOfBoundsException] is thrown.
|
||||
* If index is outside of array boundaries - [IndexOutOfBoundsException] is thrown.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Gets [UByte] out of the [ByteArray] byte buffer at specified index [index]
|
||||
* @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
* @throws IndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
*/
|
||||
@ExperimentalUnsignedTypes
|
||||
public fun ByteArray.getUByteAt(index: Int): UByte = UByte(get(index))
|
||||
|
||||
/**
|
||||
* Gets [Char] out of the [ByteArray] byte buffer at specified index [index]
|
||||
* @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
* @throws IndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
*/
|
||||
@GCUnsafeCall("Kotlin_ByteArray_getCharAt")
|
||||
public external fun ByteArray.getCharAt(index: Int): Char
|
||||
|
||||
/**
|
||||
* Gets [Short] out of the [ByteArray] byte buffer at specified index [index]
|
||||
* @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
* @throws IndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
*/
|
||||
@GCUnsafeCall("Kotlin_ByteArray_getShortAt")
|
||||
public external fun ByteArray.getShortAt(index: Int): Short
|
||||
|
||||
/**
|
||||
* Gets [UShort] out of the [ByteArray] byte buffer at specified index [index]
|
||||
* @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
* @throws IndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
*/
|
||||
@GCUnsafeCall("Kotlin_ByteArray_getShortAt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@@ -43,14 +43,14 @@ public external fun ByteArray.getUShortAt(index: Int): UShort
|
||||
|
||||
/**
|
||||
* Gets [Int] out of the [ByteArray] byte buffer at specified index [index]
|
||||
* @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
* @throws IndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
*/
|
||||
@GCUnsafeCall("Kotlin_ByteArray_getIntAt")
|
||||
public external fun ByteArray.getIntAt(index: Int): Int
|
||||
|
||||
/**
|
||||
* Gets [UInt] out of the [ByteArray] byte buffer at specified index [index]
|
||||
* @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
* @throws IndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
*/
|
||||
@GCUnsafeCall("Kotlin_ByteArray_getIntAt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@@ -58,14 +58,14 @@ public external fun ByteArray.getUIntAt(index: Int): UInt
|
||||
|
||||
/**
|
||||
* Gets [Long] out of the [ByteArray] byte buffer at specified index [index]
|
||||
* @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
* @throws IndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
*/
|
||||
@GCUnsafeCall("Kotlin_ByteArray_getLongAt")
|
||||
public external fun ByteArray.getLongAt(index: Int): Long
|
||||
|
||||
/**
|
||||
* Gets [ULong] out of the [ByteArray] byte buffer at specified index [index]
|
||||
* @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
* @throws IndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
*/
|
||||
@GCUnsafeCall("Kotlin_ByteArray_getLongAt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@@ -73,42 +73,42 @@ public external fun ByteArray.getULongAt(index: Int): ULong
|
||||
|
||||
/**
|
||||
* Gets [Float] out of the [ByteArray] byte buffer at specified index [index]
|
||||
* @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
* @throws IndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
*/
|
||||
@GCUnsafeCall("Kotlin_ByteArray_getFloatAt")
|
||||
public external fun ByteArray.getFloatAt(index: Int): Float
|
||||
|
||||
/**
|
||||
* Gets [Double] out of the [ByteArray] byte buffer at specified index [index]
|
||||
* @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
* @throws IndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
*/
|
||||
@GCUnsafeCall("Kotlin_ByteArray_getDoubleAt")
|
||||
public external fun ByteArray.getDoubleAt(index: Int): Double
|
||||
|
||||
/**
|
||||
* Sets [UByte] out of the [ByteArray] byte buffer at specified index [index]
|
||||
* @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
* @throws IndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
*/
|
||||
@GCUnsafeCall("Kotlin_ByteArray_set")
|
||||
public external fun ByteArray.setUByteAt(index: Int, value: UByte)
|
||||
|
||||
/**
|
||||
* Sets [Char] out of the [ByteArray] byte buffer at specified index [index]
|
||||
* @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
* @throws IndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
*/
|
||||
@GCUnsafeCall("Kotlin_ByteArray_setCharAt")
|
||||
public external fun ByteArray.setCharAt(index: Int, value: Char)
|
||||
|
||||
/**
|
||||
* Sets [Short] out of the [ByteArray] byte buffer at specified index [index]
|
||||
* @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
* @throws IndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
*/
|
||||
@GCUnsafeCall("Kotlin_ByteArray_setShortAt")
|
||||
public external fun ByteArray.setShortAt(index: Int, value: Short)
|
||||
|
||||
/**
|
||||
* Sets [UShort] out of the [ByteArray] byte buffer at specified index [index]
|
||||
* @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
* @throws IndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
*/
|
||||
@GCUnsafeCall("Kotlin_ByteArray_setShortAt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@@ -116,28 +116,28 @@ public external fun ByteArray.setUShortAt(index: Int, value: UShort)
|
||||
|
||||
/**
|
||||
* Sets [Int] out of the [ByteArray] byte buffer at specified index [index]
|
||||
* @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
* @throws IndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
*/
|
||||
@GCUnsafeCall("Kotlin_ByteArray_setIntAt")
|
||||
public external fun ByteArray.setIntAt(index: Int, value: Int)
|
||||
|
||||
/**
|
||||
* Sets [UInt] out of the [ByteArray] byte buffer at specified index [index]
|
||||
* @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
* @throws IndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
*/
|
||||
@GCUnsafeCall("Kotlin_ByteArray_setIntAt")
|
||||
public external fun ByteArray.setUIntAt(index: Int, value: UInt)
|
||||
|
||||
/**
|
||||
* Sets [Long] out of the [ByteArray] byte buffer at specified index [index]
|
||||
* @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
* @throws IndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
*/
|
||||
@GCUnsafeCall("Kotlin_ByteArray_setLongAt")
|
||||
public external fun ByteArray.setLongAt(index: Int, value: Long)
|
||||
|
||||
/**
|
||||
* Sets [ULong] out of the [ByteArray] byte buffer at specified index [index]
|
||||
* @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
* @throws IndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
*/
|
||||
@GCUnsafeCall("Kotlin_ByteArray_setLongAt")
|
||||
@ExperimentalUnsignedTypes
|
||||
@@ -145,14 +145,14 @@ public external fun ByteArray.setULongAt(index: Int, value: ULong)
|
||||
|
||||
/**
|
||||
* Sets [Float] out of the [ByteArray] byte buffer at specified index [index]
|
||||
* @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
* @throws IndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
*/
|
||||
@GCUnsafeCall("Kotlin_ByteArray_setFloatAt")
|
||||
public external fun ByteArray.setFloatAt(index: Int, value: Float)
|
||||
|
||||
/**
|
||||
* Sets [Double] out of the [ByteArray] byte buffer at specified index [index]
|
||||
* @throws ArrayIndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
* @throws IndexOutOfBoundsException if [index] is outside of array boundaries.
|
||||
*/
|
||||
@GCUnsafeCall("Kotlin_ByteArray_setDoubleAt")
|
||||
public external fun ByteArray.setDoubleAt(index: Int, value: Double)
|
||||
|
||||
@@ -23,6 +23,7 @@ internal fun ThrowIndexOutOfBoundsException(): Nothing {
|
||||
|
||||
@ExportForCppRuntime
|
||||
internal fun ThrowArrayIndexOutOfBoundsException(): Nothing {
|
||||
@Suppress("DEPRECATION")
|
||||
throw ArrayIndexOutOfBoundsException()
|
||||
}
|
||||
|
||||
|
||||
@@ -334,7 +334,7 @@ public actual fun String(chars: CharArray): String = chars.concatToString()
|
||||
@DeprecatedSinceKotlin(warningSince = "1.4", errorSince = "1.5")
|
||||
public actual fun String(chars: CharArray, offset: Int, length: Int): String {
|
||||
if (offset < 0 || length < 0 || offset + length > chars.size)
|
||||
throw ArrayIndexOutOfBoundsException()
|
||||
throw IndexOutOfBoundsException()
|
||||
|
||||
return unsafeStringFromCharArray(chars, offset, length)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user