JDK-6600199 : (process) Decode system error messages using platform encoding (unix)
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.lang
  • Affected Version: 7
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: solaris_10
  • CPU: sparc
  • Submitted: 2007-09-03
  • Updated: 2011-05-17
  • Resolved: 2011-05-17
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7
6u10Fixed 7 b21Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
OS : Solaris 9/10 (japanese locale(LOCALE=ja))
     WindowsXP(SP2, Japanese)
JDK : 6.0u2/JDK7b16

REPRODUCE : 
 1) Compile the attached test program
 2) Invoke "java Command"
 3) Please look at the message when IOException occurs in java.lang.Runtime#exec
    (The test program tests other cases. The licensee focus on the IOException message.)

 This does not occur in 1.3.1, 1.4.2_XX and 5.0ux.

NOTE : 
 The test program checks several cases. The above issues occurs in IOException check.
 

INVESTIGATION :

[j2se/src/solaris/native/java.lang/UNIXProcess_md.c]
 .....
  static void
  throwIOException(JNIEnv *env, int errnum, const char *defaultDetail)
  {
      static const char * const format = "error=%d, %s";
      const char *detail = defaultDetail;
      char *errmsg;
      if (errnum != 0) {
	  const char *s = strerror(errnum);
	  if (strcmp(s, "Unknown error") != 0)
	      detail = s;
      }
      /* ASCII Decimal representation uses 2.4 times as many bits as binary. */
      errmsg = NEW(char, strlen(format) + strlen(detail) + 3 * sizeof(errnum));
      sprintf(errmsg, format, errnum, detail);
      JNU_ThrowIOException(env, errmsg);
      free(errmsg);
  }
  .....

The return value(Japanese EUC encoding ) from strerr() is used in UTF-8.
That's why the error message can not be displayed correctly.


OTHERS:
 Please see the strong requests in "comment section".

Comments
EVALUATION Here is a proposed fix: --- /tmp/geta17181 2007-09-04 17:26:50.878145000 -0700 +++ UNIXProcess_md.c 2007-09-04 17:20:30.406136000 -0700 @@ -332,23 +332,31 @@ static void throwIOException(JNIEnv *env, int errnum, const char *defaultDetail) { static const char * const format = "error=%d, %s"; const char *detail = defaultDetail; char *errmsg; + jstring s; + if (errnum != 0) { const char *s = strerror(errnum); if (strcmp(s, "Unknown error") != 0) detail = s; } /* ASCII Decimal representation uses 2.4 times as many bits as binary. */ errmsg = NEW(char, strlen(format) + strlen(detail) + 3 * sizeof(errnum)); sprintf(errmsg, format, errnum, detail); - JNU_ThrowIOException(env, errmsg); + s = JNU_NewStringPlatform(env, errmsg); + if (s != NULL) { + jobject x = JNU_NewObjectByName(env, "java/io/IOException", + "(Ljava/lang/String;)V", s); + if (x != NULL) + (*env)->Throw(env, x); + } free(errmsg); } #ifdef DEBUG_PROCESS /* Debugging process code is difficult; where to write debug output? */ static void debugPrint(char *format, ...)
05-09-2007

EVALUATION Confirmed. Caused by the fixes for 4052517: (process) Solaris Runtime.exec won't execute programs belonging to other groups 4811767: (process) Runtime.exec should throw IOException when workdir does not exist (Unix) 5033302: (process) Can't execute Solaris NFS programs with uid>64k on Linux-amd64 in 6-b81 The diagnosis is amusing. I had tested this with some ISO-8859-x locale, and it appeared to "work", but this is because the UTF-8 decoder in hotspot falls back to decoding using ISO-8859-1 (see UTF8::next in utf8.cpp in the hotspot sources)
04-09-2007