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

System.getenv() returns unexpected value if environment variable has non ASCII character

    XMLWordPrintable

Details

    • 18
    • b24
    • linux
    • Verified

    Backports

      Description

        On JDK19 with Linux ja_JP.eucjp locale,
        System.getenv() returns unexpected value if environment variable has Japanese EUC characters.
        It seems this issue happens because of JEP 400.

        Please check following output.
        ================================
        $ locale
        LANG=ja_JP.eucjp
        LC_CTYPE="ja_JP.eucjp"
        LC_NUMERIC="ja_JP.eucjp"
        LC_TIME="ja_JP.eucjp"
        LC_COLLATE="ja_JP.eucjp"
        LC_MONETARY="ja_JP.eucjp"
        LC_MESSAGES="ja_JP.eucjp"
        LC_PAPER="ja_JP.eucjp"
        LC_NAME="ja_JP.eucjp"
        LC_ADDRESS="ja_JP.eucjp"
        LC_TELEPHONE="ja_JP.eucjp"
        LC_MEASUREMENT="ja_JP.eucjp"
        LC_IDENTIFICATION="ja_JP.eucjp"
        LC_ALL=
        $ cat Env.java
        public class Env {
            public static void main(String[] args) throws Exception {
                for (String s : args)
                    System.out.println(s+"="+System.getenv(s));
            }
        }
        $ export DATE=`date`
        $ echo $DATE
        2022年 4月 23日 土曜日 22:33:29 JST
        $ ~/jdk-17.0.2/bin/java -showversion Env.java DATE
        openjdk version "17.0.2" 2022-01-18
        OpenJDK Runtime Environment (build 17.0.2+8-86)
        OpenJDK 64-Bit Server VM (build 17.0.2+8-86, mixed mode, sharing)
        DATE=2022年 4月 23日 土曜日 22:33:29 JST
        $ ~/jdk-19+b19/bin/java -showversion Env.java DATE
        openjdk version "19-ea" 2022-09-20
        OpenJDK Runtime Environment (build 19-ea+19-1283)
        OpenJDK 64-Bit Server VM (build 19-ea+19-1283, mixed mode, sharing)
        DATE=2022? 4?? 23?? ?????? 22:33:29 JST
        ================================

        When I wrote jtreg testcase, I found ProcessBuilder had same kind of issue.

        Attachments

          Issue Links

            Activity

              People

                itakiguchi Ichiroh Takiguchi
                itakiguchi Ichiroh Takiguchi
                Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                  Created:
                  Updated:
                  Resolved: