Java Solaris Communities Sun Store Join SDN My Profile Why Join?
 
Bug Database
Bug Detail
Quick Lists
Top 25 Bugs
Top 25 RFE's
Recently Closed Bugs
Printable Page Printable Page


Bug Database
Bug ID: 5052844
Votes 0
Synopsis file.encoding parameter ignored on Intel Linux
Category java:classes_io
Reported Against 1.4.2
Release Fixed
State 11-Closed, duplicate of 4163515, bug
Priority: 4-Low
Related Bugs 4163515
Submit Date 25-MAY-2004
Description




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  customer 

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) 
======================================================================
Work Around
N/A
Evaluation
N/A
Comments
  
  Include a link with my name & email   


PLEASE NOTE: JDK6 is formerly known as Project Mustang