Skip to content

Commit

Permalink
Add String.getBytes for JDK16
Browse files Browse the repository at this point in the history
Related: eclipse-openj9#11312

Signed-off-by: Babneet Singh <sbabneet@ca.ibm.com>
  • Loading branch information
babsingh committed Dec 2, 2020
1 parent f6fcc17 commit 1861891
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions jcl/src/java.base/share/classes/java/lang/String.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,31 @@ byte coder() {
}
}

/*[IF JAVA_SPEC_VERSION >= 16]*/
/**
* Copy bytes from value starting at srcIndex into the bytes array starting at
* destIndex. No range checking is needed. Caller ensures bytes is in UTF16.
*
* @param bytes copy destination
* @param srcIndex index into value
* @param destIndex index into bytes
* @param coder LATIN1 or UTF16
* @param length the number of elements to copy
*/
void getBytes(byte[] bytes, int srcIndex, int destIndex, byte coder, int length) {
// Check if the String is compressed
if (enableCompression && (null == compressionFlag || this.coder == LATIN1)) {
if (String.LATIN1 == coder) {
compressedArrayCopy(value, srcIndex, bytes, destIndex, length);
} else {
decompress(value, srcIndex, bytes, destIndex, length);
}
} else {
decompressedArrayCopy(value, srcIndex, bytes, destIndex, length);
}
}
/*[ENDIF] JAVA_SPEC_VERSION >= 16 */

// no range checking, caller ensures bytes is in UTF16
// coder is one of LATIN1 or UTF16
void getBytes(byte[] bytes, int offset, byte coder) {
Expand Down

0 comments on commit 1861891

Please sign in to comment.