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

Initialize charset mapping data lazily

XMLWordPrintable

      Running this will have the side effect of initializing all Charsets in the JDK (and in any application provided extensions):

      public class CharsetAvailable {
          public static void main(String ... args) {
              java.nio.charset.Charset.availableCharsets();
          }
      }

      When analyzing the cost of this, it's apparent that the majority of time is spent initializing the charset encoding and decoding mapping data. Since it's unlikely more than a few charsets will actually be used in any given application, doing this initialization lazily - by means of holder classes - seems profitable.

      Using a holder class idiom also mean that all DoubleByte charsets - which currently use lazy initialization using DCL - can optimize better.

            redestad Claes Redestad
            redestad Claes Redestad
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: