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

langtools/tools/javac/newlines/NewLineTest.java is failing on Japanese Windows

XMLWordPrintable

    • 18
    • b23
    • generic
    • windows

        When running langtools/tools/javac/newlines/NewLineTest.java on Japanese Windows, it always fails by MalformedInputException.

        Java version:
        openjdk version "23-internal" 2024-09-17
        OpenJDK Runtime Environment (build 23-internal-adhoc.Administrator.jdk)
        OpenJDK 64-Bit Server VM (build 23-internal-adhoc.Administrator.jdk, mixed mode, sharing)

        Environment:
        I tested on Windows 10.
        $ locale
        LANG=ja_JP.UTF-8
        LC_CTYPE="ja_JP.UTF-8"
        LC_NUMERIC="ja_JP.UTF-8"
        LC_TIME="ja_JP.UTF-8"
        LC_COLLATE="ja_JP.UTF-8"
        LC_MONETARY="ja_JP.UTF-8"
        LC_MESSAGES="ja_JP.UTF-8"
        LC_ALL=

        Exception:
        java.nio.charset.MalformedInputException: Input length = 1
        at java.base/java.nio.charset.CoderResult.throwException(CoderResult.java:279)
        at java.base/sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:405)
        at java.base/sun.nio.cs.StreamDecoder.lockedRead(StreamDecoder.java:217)
        at java.base/sun.nio.cs.StreamDecoder.read(StreamDecoder.java:171)
        at java.base/java.io.InputStreamReader.read(InputStreamReader.java:190)
        at java.base/java.io.BufferedReader.fill(BufferedReader.java:160)
        at java.base/java.io.BufferedReader.implReadLine(BufferedReader.java:370)
        at java.base/java.io.BufferedReader.readLine(BufferedReader.java:347)
        at java.base/java.io.BufferedReader.readLine(BufferedReader.java:436)
        at java.base/java.nio.file.Files.readAllLines(Files.java:3419)
        at NewLineTest.main(NewLineTest.java:61)
        at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
        at java.base/java.lang.reflect.Method.invoke(Method.java:580)
        at com.sun.javatest.regtest.agent.MainActionHelper$AgentVMRunnable.run(MainActionHelper.java:333)
        at java.base/java.lang.Thread.run(Thread.java:1575)

        I verified this test passed on English Windows and Linux. Also, this problem does not occur in jdk17.
        This exception is probably related to the change in default charset in JEP 400.
        The exception message indicates that it failed to read a file to which the output of javac run in the test was redirected. JEP400 changed Charset.defaultCharset() to return UTF-8. However, the encoding of Javac's standard output is still derived from the host environment and/or the user's settings. As a result, the test fails on Windows with non-English locale in jdk18 and later.

              tkiriyama Takuya Kiriyama
              tkiriyama Takuya Kiriyama
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: