Code example for BufferOverflowException

0
        public MockMalfunctionEncoder(Charset cs) {
            super(cs, 1, 3, new byte[] { (byte) '?' });
        } 
 
        protected CoderResult encodeLoop(CharBuffer in, ByteBuffer out) {
            throw new BufferOverflowException();
        } 
    } 
 
    /* 
     * Test reserve bytes encode(CharBuffer,ByteBuffer,boolean) 
     */ 
    @TestTargetNew( 
        level = TestLevel.PARTIAL, 
        notes = "Functional test.", 
        method = "encode", 
        args = {java.nio.CharBuffer.class, java.nio.ByteBuffer.class, boolean.class}
    ) 
    public void test_EncodeLjava_nio_CharBufferLjava_nio_ByteBufferB() { 
        CharsetEncoder encoder = Charset.forName("utf-8").newEncoder();
        CharBuffer in1 = CharBuffer.wrap("\ud800");