Skip to content

Commit

Permalink
Add missing newArray(int) method
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Dec 30, 2024
1 parent 74f0233 commit 88edbe9
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/java.base/share/classes/java/lang/StringConcatHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,19 @@ static byte[] newArray(long indexCoder) {
return (byte[]) UNSAFE.allocateUninitializedArray(byte.class, index);
}

/**
* Allocates an uninitialized byte array based on the length
* @param length
* @return the newly allocated byte array
*/
@ForceInline
static byte[] newArray(int length) {
if (length < 0) {
throw new OutOfMemoryError("Overflow: String length out of range");
}
return (byte[]) UNSAFE.allocateUninitializedArray(byte.class, length);
}

/**
* Provides the initial coder for the String.
* @return initial coder, adjusted into the upper half
Expand Down

0 comments on commit 88edbe9

Please sign in to comment.