Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-5052844

file.encoding parameter ignored on Intel Linux

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.4.2
    • core-libs
    • x86
    • linux



      Name: rmT116609 Date: 05/25/2004


      FULL PRODUCT VERSION :
      java version "1.4.2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2-b28)
      Java HotSpot(TM) Client VM (build 1.4.2-b28, mixed mode)

      java version "1.5.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-beta-b32c)
      Java HotSpot(TM) Client VM (build 1.5.0-beta-b32c, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Red Hat, Linux 2.4.2 on Intel

      A DESCRIPTION OF THE PROBLEM :
      Specifing the -Dfile.encoding value on the Java command line does not set the default encoding used the the IO libraries on Linux. It works fine on Windows and on Mac OS X.

      The parameter is passed into the runtime system with no problem but the IO libriaries are not using it. The IO libraries appear to be using the file encoding part of the LANG enviroment variable instead.


      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Execute the code below on a linux machine. Try with something like

      java -Dfile.enocoding=US-ASCII FileEncodingTest

      Set the encoding to be what ever you like. The actual value used will not change.


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The actual default encoding using by the streams library should be of the same type as that of the file.encoding parameter, so long as that parameter contains a valid encoding.
      ACTUAL -
      The value printed out as the "actual value" is always the LANG environment variable encoding value. The file.encoding parameter is passed in, but ignored.

      This works as expected on Windows and on Mac OS X.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.io.*;

      public class FileEncodingTest {
          public static void main(String[] args) {
              String property = System.getProperty("file.encoding");
              String actual = new OutputStreamWriter(
                             new ByteArrayOutputStream()).getEncoding();
              System.out.println("property=" + property + ", actual=" + actual);
          }
      }
      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Change the LANG enviroment variable.
      (Incident Review ID: 274951)
      ======================================================================

            martin Martin Buchholz
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: