CharsetDecoderUtil { public static CharBuffer decode(String charsetName, ByteBuffer byteBuffer) { try { return decode(charsetName, CodingErrorAction.REPLACE, byteBuffer); } catch (CharacterCodingException characterCodingException) { throw new Error(characterCodingException); } }  static CharBuffer decode(String charsetName, ByteBuffer byteBuffer); static CharBuffer decode(
			String charsetName, CodingErrorAction codingErrorAction,
			ByteBuffer byteBuffer); static CharsetDecoder getCharsetDecoder(String charsetName); static CharsetDecoder getCharsetDecoder(
		String charsetName, CodingErrorAction codingErrorAction);  }
@Test public void testDecode() throws Exception { Assert.assertEquals( CharBuffer.wrap("abc"), CharsetDecoderUtil.decode( "US-ASCII", CodingErrorAction.REPORT, ByteBuffer.wrap("abc".getBytes("US-ASCII")))); try { CharsetDecoderUtil.decode( "US-ASCII", CodingErrorAction.REPORT, ByteBuffer.wrap(new byte[] {-1, -2, -3, -4})); Assert.fail(); } catch (MalformedInputException malformedInputException) { Assert.assertEquals(1, malformedInputException.getInputLength()); } TestCharset testCharset = new TestCharset(); Object cache1 = ReflectionTestUtil.getAndSetFieldValue( Charset.class, "cache1", new Object[] {testCharset.name(), testCharset}); try { CharsetDecoderUtil.decode( testCharset.name(), ByteBuffer.wrap(new byte[0])); Assert.fail(); } catch (Error e) { Assert.assertSame( testCharset.getCharacterCodingException(), e.getCause()); } finally { ReflectionTestUtil.setFieldValue(Charset.class, "cache1", cache1); } }