Convert String::newStringNoRepl with Latin-1 to String::newStringLatin1NoRepl

XMLWordPrintable

    • Type: Enhancement
    • Resolution: Duplicate
    • Priority: P4
    • None
    • Affects Version/s: None
    • Component/s: core-libs
    • None

      We propose a new package-private static method in String, newStringLatin1NoRepl, which is shared via JLA. It creates a Latin-1 string from the trusted byte array, or if compact string is disabled, inflates the array and creates a string with UTF-16 coder.

      Rationale:
      1. Latin-1 case has a special logic used in multiple places even within String itself; pulling it out can simplify code much.
      2. Most usages of newStringNoRepl via JLA is in `HexFormat` and is ISO_8859_1, which is Latin-1. The only other usage is one in `Files`, taking a Charset argument from user input. The replacement of newStringNoRepl with newStringLatin1NoRepl avoids going through extra logic and meaningless catch blocks in the source code. (There's a similar newStringUTF8NoRepl, which justifies the existence of a Latin1 version)

            Assignee:
            Unassigned
            Reporter:
            Chen Liang
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: