<i18n dev> RFR: 8274544: Langtools command's usage were garbled on Japanese Windows [v3]
Ichiroh Takiguchi
itakiguchi at openjdk.java.net
Wed Oct 13 18:11:49 UTC 2021
On Fri, 8 Oct 2021 21:07:32 GMT, Naoto Sato <naoto at openjdk.org> wrote:
>> Ichiroh Takiguchi has updated the pull request incrementally with one additional commit since the last revision:
>>
>> 8274544: Langtools command's usage were garbled on Japanese Windows
>
> BTW, does the PoC in the jshell bug report really causing the issue?
>
> System.out.println("\u3042")
>
> This is ASCII, so save/restore does not seem to cause any issues across JDKs with and without JEP400. Did you mean `Systemout.println("あ")` instead?
Hello @naotoj .
Sorry I'm late.
I'd like to show you jshell issue step by step.
1. `System.out.println(...)` did not work if non-ASCII character was printed on JDK18-b13.
Because jshell output encoding was MS932, jshell agent output encoding was UTF-8

2. Above fix was applied against `JShellToolProvider.java` only.
The issue was not fixed.

3. Just applied lahodaj's fix `JShellToolBuilder.java`.
It worked fine as expected

4. I checked compatibility between JDK17 and this fix by using `/save` and `/open`
It seemed saved a.jsh's encoding was MS932

5. I think jshell and agent should use same `file.encoding` system property. I applied following fix.
--- a/src/jdk.jshell/share/classes/jdk/jshell/execution/JdiInitiator.java
+++ b/src/jdk.jshell/share/classes/jdk/jshell/execution/JdiInitiator.java
@@ -27,6 +27,7 @@ package jdk.jshell.execution;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
+import java.nio.charset.Charset;
import java.nio.file.Files;
import java.util.ArrayList;
import java.util.HashMap;
@@ -86,6 +87,17 @@ public class JdiInitiator {
Map<String, String> customConnectorArgs) {
this.remoteAgent = remoteAgent;
this.connectTimeout = (int) (timeout * CONNECT_TIMEOUT_FACTOR);
+ if (!StandardCharsets.UTF_8.equals(Charset.defaultCharset())) {
+ boolean encodingFlag = true;
+ for (String s : remoteVMOptions.toArray(new String[0])) {
+ if (s.startsWith("-Dfile.encoding="))
+ encodingFlag = false;
+ }
+ if (encodingFlag) {
+ remoteVMOptions.add("-Dfile.encoding="
+ +Charset.defaultCharset().name());
+ }
+ }
String connectorName
= isLaunch
? "com.sun.jdi.CommandLineLaunch"

I think `JShellToolBuilder.java` and `JdiInitiator.java`.
Could you give me some suggestions ?
-------------
PR: https://git.openjdk.java.net/jdk/pull/5771
More information about the i18n-dev
mailing list