diff --git a/src/java.base/share/classes/sun/nio/cs/UnicodeDecoder.java b/src/java.base/share/classes/sun/nio/cs/UnicodeDecoder.java index c3509d7..e6bcef7 100644 --- a/src/java.base/share/classes/sun/nio/cs/UnicodeDecoder.java +++ b/src/java.base/share/classes/sun/nio/cs/UnicodeDecoder.java @@ -91,11 +91,6 @@ abstract class UnicodeDecoder extends CharsetDecoder { char c = decode(b1, b2); - if (c == REVERSED_MARK) { - // A reversed BOM cannot occur within middle of stream - return CoderResult.malformedForLength(2); - } - // Surrogates if (Character.isSurrogate(c)) { if (Character.isHighSurrogate(c)) { diff --git a/test/jdk/sun/nio/cs/TestUTF_16.java b/test/jdk/sun/nio/cs/TestUTF_16.java index 25344dd..a3f3e2d 100644 --- a/test/jdk/sun/nio/cs/TestUTF_16.java +++ b/test/jdk/sun/nio/cs/TestUTF_16.java @@ -184,7 +184,24 @@ public class TestUTF_16 { throw new Exception ("Incorrectly parsed BOM in middle of input"); */ - // Fixed included with bug 4403848 fixes buffer sizing + // Test 7: Decoding does not report unicode non-character (U+FFFE) + if (StandardCharsets.UTF_16LE.newDecoder() + .onMalformedInput(CodingErrorAction.REPORT) + .decode(ByteBuffer.allocate(6) + .put(new byte[] + {(byte) 0x61, (byte) 0x00, + (byte) 0xfe, (byte) 0xff, + (byte) 0x64, (byte) 0x00}) + .flip(), + CharBuffer.allocate(3), + true) + .isMalformed()) { + + throw new Exception("REGTEST TestUTF16 non-character U+FFFE test failed"); + } + + + // Fixed included with bug 4403848 fixes buffer sizing // issue due to non provision of additional 2 bytes // headroom for initial BOM bytes for UTF-16 encoding. System.err.println ("OVERALL PASS OF UTF-16 Test");