Issue | Fix Version | Assignee | Priority | Status | Resolution | Resolved In Build |
---|---|---|---|---|---|---|
JDK-8072317 | 7u85 | Ivan Gerasimov | P3 | Resolved | Fixed | b01 |
JDK-8062068 | 7u80 | Ivan Gerasimov | P3 | Resolved | Fixed | b03 |
Only Windows platform is affected.
The problem can be easily reproduced on non-English Windows (e.g., russian Windows 7 when Cp1251 character page is in use) using following snippet:
try {
Runtime.getRuntime().exec("ttttttttt");
} catch (IOException ex) {
ex.printStackTrace();
}
As the result you can see following output with invalid characters:
java.io.IOException: Cannot run program "ttttttttt": CreateProcess error=2, ?? ??????? ????? ????????? ????
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
...
Caused by: java.io.IOException: CreateProcess error=2, ?? ??????? ????? ????????? ????
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 6 more
Note, that detailed message with correct encoding can be obtained using the following trick:
new String(ex.getMessage().getBytes("ISO-8859-1"),Charset.defaultCharset().displayName());
The bug is reside in native part of JDK at jdk\src\windows\native\java\lang\ProcessImpl_md.c
See "static void win32Error(JNIEnv *env, const char *functionName)" method there.
This method does not consider character page of underlying system.
As an example how to correctly process encoding of the error message you can look at
jdk\src\share\native\common\jni_util.c, method JNIEXPORT void JNICALL JNU_ThrowByNameWithLastError(JNIEnv *env, const char *name, const char *defaultDetail)
The problem can be easily reproduced on non-English Windows (e.g., russian Windows 7 when Cp1251 character page is in use) using following snippet:
try {
Runtime.getRuntime().exec("ttttttttt");
} catch (IOException ex) {
ex.printStackTrace();
}
As the result you can see following output with invalid characters:
java.io.IOException: Cannot run program "ttttttttt": CreateProcess error=2, ?? ??????? ????? ????????? ????
at java.lang.ProcessBuilder.start(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
...
Caused by: java.io.IOException: CreateProcess error=2, ?? ??????? ????? ????????? ????
at java.lang.ProcessImpl.create(Native Method)
at java.lang.ProcessImpl.<init>(Unknown Source)
at java.lang.ProcessImpl.start(Unknown Source)
... 6 more
Note, that detailed message with correct encoding can be obtained using the following trick:
new String(ex.getMessage().getBytes("ISO-8859-1"),Charset.defaultCharset().displayName());
The bug is reside in native part of JDK at jdk\src\windows\native\java\lang\ProcessImpl_md.c
See "static void win32Error(JNIEnv *env, const char *functionName)" method there.
This method does not consider character page of underlying system.
As an example how to correctly process encoding of the error message you can look at
jdk\src\share\native\common\jni_util.c, method JNIEXPORT void JNICALL JNU_ThrowByNameWithLastError(JNIEnv *env, const char *name, const char *defaultDetail)
- backported by
-
JDK-8062068 (process) IOException thrown by ProcessBuilder.start() method is incorrectly encoded
- Resolved
-
JDK-8072317 (process) IOException thrown by ProcessBuilder.start() method is incorrectly encoded
- Resolved
- relates to
-
JDK-8011105 Locale Issue in the Native Function GetLastErrorString()
- Resolved
-
JDK-8210345 The Japanese message of FileNotFoundException garbled.
- Closed