<i18n dev> RFR: 8277398: javac does not accept encoding name COMPAT [v2]

Ichiroh Takiguchi itakiguchi at openjdk.java.net
Wed Nov 24 14:39:07 UTC 2021


On Wed, 24 Nov 2021 08:47:54 GMT, Alan Bateman <alanb at openjdk.org> wrote:

>> Ichiroh Takiguchi has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   8277398: javac does not accept encoding name COMPAT
>
> I see this PR has been re-purposed to add "COMPAT" as a charset that can be specified to Charset.forName. I don't think we should do that.  "COMPAT" is a special value for the file.encoding property, it's not meant to be in the charset tables as proposed here. The system property "native.encoding" was added in Java 17 as a standard way to obtain the encoding, you can pass its value to Charset.forName. I think we need a clear summary as to what the issue is, is -J-Dfile.encoding=COMPAT working or not?

Hello @AlanBateman and @naotoj .
I'd like to show some commands output.
As you told me, -J-Dfile.encoding=COMPAT works for compilation.
Hello.java is encoded by EUC-JP.

$ export LANG=ja_JP.eucjp
$ cat Hello.java
public class Hello {
  public static void main(String[] args) throws Exception {
    System.out.println("こんにちは");
  }
}
$ xxd Hello.java
0000000: 7075 626c 6963 2063 6c61 7373 2048 656c  public class Hel
0000010: 6c6f 207b 0a20 2070 7562 6c69 6320 7374  lo {.  public st
0000020: 6174 6963 2076 6f69 6420 6d61 696e 2853  atic void main(S
0000030: 7472 696e 675b 5d20 6172 6773 2920 7468  tring[] args) th
0000040: 726f 7773 2045 7863 6570 7469 6f6e 207b  rows Exception {
0000050: 0a20 2020 2053 7973 7465 6d2e 6f75 742e  .    System.out.
0000060: 7072 696e 746c 6e28 22a4 b3a4 f3a4 cba4  println(".......
0000070: c1a4 cf22 293b 0a20 207d 0a7d 0a         ...");.  }.}.
$ build/linux-x86_64-server-release/images/jdk/bin/javac -J-Dfile.encoding=COMPAT Hello.java
$ build/linux-x86_64-server-release/images/jdk/bin/java Hello
こんにちは
$ build/linux-x86_64-server-release/images/jdk/bin/javac -J-Dfile.encoding=COMPAT -verbose Hello.java 2>&1 | head
[SimpleFileObject[/home/jdktest/openjdk/jdk/Hello.java]を構文解析開始]
[13ミリ秒で構文解析完了]
[/modules/jdk.internal.vm.compiler/module-info.classを読込み中]
[/modules/jdk.incubator.foreign/module-info.classを読込み中]
[/modules/jdk.xml.dom/module-info.classを読込み中]
[/modules/jdk.jdwp.agent/module-info.classを読込み中]
[/modules/jdk.editpad/module-info.classを読込み中]
[/modules/jdk.crypto.ec/module-info.classを読込み中]
[/modules/java.management.rmi/module-info.classを読込み中]
[/modules/java.management/module-info.classを読込み中]

When I use -Xstdout option for javac, javac's output is redirect to file.


$ build/linux-x86_64-server-release/images/jdk/bin/javac -Xstdout out.log -J-Dfile.encoding=COMPAT -verbose Hello.java

According to head command, out.log was encoded by EUC-JP.
But I'd like to get UTF-8 encoded out.log. 

$ head out.log
[SimpleFileObject[/home/jdktest/openjdk/jdk/Hello.java]を構文解析開始]
[13ミリ秒で構文解析完了]
[/modules/jdk.nio.mapmode/module-info.classを読込み中]
[/modules/jdk.security.auth/module-info.classを読込み中]
[/modules/jdk.internal.vm.compiler.management/module-info.classを読込み中]
[/modules/java.scripting/module-info.classを読込み中]
[/modules/java.datatransfer/module-info.classを読込み中]
[/modules/jdk.attach/module-info.classを読込み中]
[/modules/jdk.management.agent/module-info.classを読込み中]
[/modules/jdk.jdi/module-info.classを読込み中]

If I use -encoding option against javac command, out.log was encoded by UTF-8.

$ build/linux-x86_64-server-release/images/jdk/bin/java -XshowSettings:properties -version 2>&1 | grep encoding
    file.encoding = UTF-8
    native.encoding = EUC-JP-LINUX
    sun.io.unicode.encoding = UnicodeLittle
    sun.jnu.encoding = EUC-JP-LINUX
$ build/linux-x86_64-server-release/images/jdk/bin/javac -Xstdout out.log -encoding EUC-JP-LINUX -verbose Hello.java
$ head out.log
[SimpleFileObject[/home/jdktest/openjdk/jdk/Hello.java]罕茹f
$ head out.log | iconv -f UTF-8 -t EUC-JP
[SimpleFileObject[/home/jdktest/openjdk/jdk/Hello.java]を構文解析開始]
[12ミリ秒で構文解析完了]
[/modules/jdk.jdi/module-info.classを読込み中]
[/modules/jdk.internal.jvmstat/module-info.classを読込み中]
[/modules/jdk.jartool/module-info.classを読込み中]
[/modules/jdk.compiler/module-info.classを読込み中]
[/modules/jdk.unsupported.desktop/module-info.classを読込み中]
[/modules/java.desktop/module-info.classを読込み中]
[/modules/java.xml/module-info.classを読込み中]
[/modules/jdk.jcmd/module-info.classを読込み中]

I don't want to find out encoding name each locale or platform.
javac and javadoc should be support COMPAT encoding name or COMPAT charset should be supported.

-------------

PR: https://git.openjdk.java.net/jdk/pull/6475


More information about the i18n-dev mailing list