mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
8286287: Reading file as UTF-16 causes Error which "shouldn't happen"
Reviewed-by: jpai, bpb, rriggs
This commit is contained in:
parent
82aa045584
commit
cc7560e995
2 changed files with 52 additions and 2 deletions
|
@ -658,8 +658,6 @@ public final class String
|
|||
|
||||
// decode using CharsetDecoder
|
||||
int en = scale(length, cd.maxCharsPerByte());
|
||||
cd.onMalformedInput(CodingErrorAction.REPLACE)
|
||||
.onUnmappableCharacter(CodingErrorAction.REPLACE);
|
||||
char[] ca = new char[en];
|
||||
if (charset.getClass().getClassLoader0() != null &&
|
||||
System.getSecurityManager() != null) {
|
||||
|
@ -1207,6 +1205,8 @@ public final class String
|
|||
private static int decodeWithDecoder(CharsetDecoder cd, char[] dst, byte[] src, int offset, int length) {
|
||||
ByteBuffer bb = ByteBuffer.wrap(src, offset, length);
|
||||
CharBuffer cb = CharBuffer.wrap(dst, 0, dst.length);
|
||||
cd.onMalformedInput(CodingErrorAction.REPLACE)
|
||||
.onUnmappableCharacter(CodingErrorAction.REPLACE);
|
||||
try {
|
||||
CoderResult cr = cd.decode(bb, cb, true);
|
||||
if (!cr.isUnderflow())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue