United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
Bug ID: JDK-6600199 (process) Decode system error messages using platform encoding (unix)
JDK-6600199 : (process) Decode system error messages using platform encoding (unix)

Details
Type:
Bug
Submit Date:
2007-09-03
Status:
Closed
Updated Date:
2011-05-17
Project Name:
JDK
Resolved Date:
2011-05-17
Component:
core-libs
OS:
solaris_10
Sub-Component:
java.lang
CPU:
sparc
Priority:
P3
Resolution:
Fixed
Affected Versions:
7
Fixed Versions:

Related Reports
Backport:
Relates:
Relates:
Relates:
Relates:
Relates:

Sub Tasks

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

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)
                                     
2007-09-04
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, ...)
                                     
2007-09-05



Hardware and Software, Engineered to Work Together