Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6636319

Encoders should implement isLegalReplacement(byte[] repl)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 7
    • 7
    • core-libs

      CharsetEncoder provides an implementation of isLegalReplacement,
      but it is not very efficient.

           * <p> The default implementation of this method is not very efficient; it
           * should generally be overridden to improve performance. </p>
           *
            */
          public boolean isLegalReplacement(byte[] repl) {

      The intent was likely that JDK-provided Encoders would implement this,
      but it has not happened.

      This is particularly important because creation of an Encoder causes an
      entire decoding operation to be performed, which makes creation of Encoders
      much more expensive than creation of Decoders.

      For a number of Encoders, the implementation is a trivial { return true; }

            sherman Xueming Shen
            martin Martin Buchholz
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: