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

Re-examine the initialization of JNU Charset in StaticProperty

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P4 P4
    • 21
    • core-libs
    • None
    • behavioral
    • medium
    • Hide
      Applications that are run with the file.encoding system property set to the value of a charset that is not in java.base may be surprised as the default charset will be UTF-8. It was mostly an accidently/oversight that it was possible to set this property to a charset outside of java.base prior to JDK 18.
      Show
      Applications that are run with the file.encoding system property set to the value of a charset that is not in java.base may be surprised as the default charset will be UTF-8. It was mostly an accidently/oversight that it was possible to set this property to a charset outside of java.base prior to JDK 18.
    • Java API, System or security property
    • JDK

      Summary

      Make Charset.defaultCharset() return a charset from java.base module for stable system initialization.

      Problem

      There were situations, such as those mentioned in the PR (https://github.com/openjdk/jdk/pull/12132), in which the default charset initialization was fragile, resulting in the default charset being loaded from the jdk.charsets service provider module.

      Solution

      Instead of looking for all the charset providers, the initialization of the default charset only loads the standard charset provider that instantiates a charset within java.base module.

      Specification

      N/A. This is a behavioral change only.

            naoto Naoto Sato
            naoto Naoto Sato
            Alan Bateman
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: