public final ByteBuffer encode(CharBuffer cb) { try { CharsetEncoder encoder = (CharsetEncoder) cachedEncoder.get(); if (encoder == null) { encoder = newEncoder().onMalformedInput(CodingErrorAction.REPLACE).onUnmappableCharacter(CodingErrorAction.REPLACE); cachedEncoder.set(encoder);
public final ByteBuffer encode (CharBuffer cb) { try {     synchronized (Charset.class) { if (cachedEncoder == null) { cachedEncoder = newEncoder () .onMalformedInput (CodingErrorAction.REPLACE) .onUnmappableCharacter (CodingErrorAction.REPLACE);
	public final ByteBuffer encode(CharBuffer cb) {		try {			CharsetEncoder encoder = (CharsetEncoder) cachedEncoder.get();			if (encoder == null) {				encoder = newEncoder().onMalformedInput(CodingErrorAction.REPLACE).onUnmappableCharacter(CodingErrorAction.REPLACE);				cachedEncoder.set(encoder);			}			return encoder.encode(cb);		} catch (CharacterCodingException e) {			throw new AssertionError(e);		}	}