}
  public final ByteBuffer encode (CharBuffer cb)  {    try      {        // NB: This implementation serializes different threads calling        // Charset.encode(), a potential performance problem.  It might        // be better to remove the cache, or use ThreadLocal to cache on        // a per-thread basis.        synchronized (Charset.class)          {            if (cachedEncoder == null)              {                cachedEncoder = newEncoder ()                  .onMalformedInput (CodingErrorAction.REPLACE)                  .onUnmappableCharacter (CodingErrorAction.REPLACE);              } else 	        cachedEncoder.reset();            return cachedEncoder.encode (cb);          }      }    catch (CharacterCodingException e)      {        throw new AssertionError (e);		}	}