Error if argument passed to java.exe contains non-ASCII character

Alan Bateman Alan.Bateman at oracle.com
Fri Jun 17 14:55:12 UTC 2022


On 17/06/2022 00:53, Stephanie Crater wrote:
>
> Hi,
>
> I've been investigating an error on Windows in which compilation fails 
> when the SDK file path includes a Chinese character (and more broadly, 
> if any string argument passed to java.exe contains a non-ASCII 
> character). This happens because command line arguments are read using 
> GetCommandLine() [1]. In the Windows file processenv.h, this resolves 
> to GetCommandLineW [2] if UNICODE is defined and GetCommandLineA [3] 
> otherwise. As UNICODE is not defined, GetCommandLineA is used and 
> Chinese characters on the command line are converted to "?", causing 
> the following:
>
> Compilation failed with an internal error.
>
> Exception in thread "main" java.nio.file.InvalidPathException: Illegal 
> char <?> at index 34: C:\Program Files 
> (x86)\Android\SDK????\platforms\android-31\android.jar
>
> This error has been reported before, including JDK-8124977 [4] 
> (describes command line encoding challenges on Windows, created in 
> 2015 and still unresolved)
>

Someone in Microsoft did propose a patch in 2015 on this. It lead to an 
8 month discussion on the issues/implications (the core-libs-dev archive 
from 2015 and 2016). Several things have changed since then, including 
moving to UTF-8 by default and defining system properties for the native 
and console encoding. I don't disagree that it may be time to look at 
this again. The core-libs-dev mailing list is the right place rather 
than jdk-dev.

-Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jdk-dev/attachments/20220617/0237b6f1/attachment-0001.htm>


More information about the jdk-dev mailing list