Skip to content

Commit 67dadc2

Browse files
committed
Add method java.lang.String.getBytes(byte[], int, byte)
Add method java.lang.String.getBytes(byte[], int, byte) to MJI model class for java.lang.String This also fixes: [junit] java.lang.NoSuchMethodError: java.lang.String.getBytes([BIB)V [junit] at java.lang.AbstractStringBuilder.putStringAt(AbstractStringBuilder.java:1641)
1 parent e655058 commit 67dadc2

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/classes/modules/java.base/java/lang/String.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,19 @@ public byte[] getBytes(Charset x){
241241
return StringCoding.encode(x, coder(), value);
242242
}
243243

244+
/**
245+
* If two coders are different and target is big enough,
246+
* invoker guarantees that the target is in UTF16
247+
*/
248+
void getBytes(byte dst[], int dstBegin, byte coder) {
249+
assert coder == UTF16;
250+
if (coder() == coder) {
251+
System.arraycopy(value, 0, dst, dstBegin << coder, value.length);
252+
} else { // this.coder == LATIN1 && coder == UTF16
253+
StringLatin1.inflate(value, 0, dst, dstBegin, value.length);
254+
}
255+
}
256+
244257
native public byte[] getBytes();
245258
@Override
246259
native public boolean equals(Object anObject);

0 commit comments

Comments
 (0)