Merge pull request #26315 from thjaeckle/bugfix/26286
Make copyUSAsciiStrToBytes more robust w.r.t. JDK for Java9+ #26286
This commit is contained in:
commit
b3ec17871a
1 changed files with 3 additions and 3 deletions
|
|
@ -46,7 +46,7 @@ public final class Unsafe {
|
|||
public static void copyUSAsciiStrToBytes(String str, byte[] bytes) {
|
||||
if (isJavaVersion9Plus) {
|
||||
final byte[] chars = (byte[]) instance.getObject(str, stringValueFieldOffset);
|
||||
System.arraycopy(chars, 0, bytes, 0, chars.length);
|
||||
System.arraycopy(chars, 0, bytes, 0, str.length());
|
||||
} else {
|
||||
final char[] chars = (char[]) instance.getObject(str, stringValueFieldOffset);
|
||||
int i = 0;
|
||||
|
|
@ -63,7 +63,7 @@ public final class Unsafe {
|
|||
|
||||
if (isJavaVersion9Plus) {
|
||||
final byte[] chars = (byte[]) instance.getObject(str, stringValueFieldOffset);
|
||||
while (i < chars.length) {
|
||||
while (i < str.length()) {
|
||||
long x = s0 ^ (long)chars[i++]; // Mix character into PRNG state
|
||||
long y = s1;
|
||||
|
||||
|
|
@ -76,7 +76,7 @@ public final class Unsafe {
|
|||
}
|
||||
} else {
|
||||
final char[] chars = (char[]) instance.getObject(str, stringValueFieldOffset);
|
||||
while (i < chars.length) {
|
||||
while (i < str.length()) {
|
||||
long x = s0 ^ (long)chars[i++]; // Mix character into PRNG state
|
||||
long y = s1;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue