code: public boolean isLegalReplacement(byte[] repl) {
          /* J2ObjC: Removed use of WeakReference.
          WeakReference<CharsetDecoder> wr = cachedDecoder;
          CharsetDecoder dec = null;
          if ((wr == null) || ((dec = wr.get()) == null)) {*/
          CharsetDecoder dec = cachedDecoder;
          if (dec == null) {
              dec = charset().newDecoder();
              dec.onMalformedInput(CodingErrorAction.REPORT);
              dec.onUnmappableCharacter(CodingErrorAction.REPORT);
              //cachedDecoder = new WeakReference<CharsetDecoder>(dec);
              cachedDecoder = dec;
          } else {
              dec.reset();
          }
          ByteBuffer bb = ByteBuffer.wrap(repl);
          CharBuffer cb = CharBuffer.allocate((int)(bb.remaining()
                                                    * dec.maxCharsPerByte()));
          CoderResult cr = dec.decode(bb, cb, true);
          return !cr.isError();
      }
docs: Tells whether or not the given byte array is a legal replacement value
  for this encoder.
  
  <p> A replacement is legal if, and only if, it is a legal sequence of
  bytes in this encoder's charset; that is, it must be possible to decode
  the replacement into one or more sixteen-bit Unicode characters.
  
  <p> The default implementation of this method is not very efficient; it
  should generally be overridden to improve performance.  </p>
  
  @param  repl  The byte array to be tested
  
  @return  <tt>true</tt> if, and only if, the given byte array
  is a legal replacement value for this encoder