JDK-4375816 : java ignores -Dfile.encoding parameter
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.3.0
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.6
  • CPU: sparc
  • Submitted: 2000-10-03
  • Updated: 2000-10-12
  • Resolved: 2000-10-12
Related Reports
Duplicate :  
Description

Name: dfR10049			Date: 10/03/2000



Java ignores -Dfile.encoding while creating Reader/Writer with default 
encoding. It always uses system default on Solaris 2.7. 

On Solaris 2.6 if LC_CTYPE=ru it also ignores -Dfile.encoding parameter. 

jdk1.1.* works correctly.

This is the test demonstrated the bug:

-------------------------------------
import java.io.*;

public class Test {

  static public void main (String[] args) {
        System.out.println("file.encoding " + 
                System.getProperty("file.encoding"));
        OutputStreamWriter wtr =
                new OutputStreamWriter(new ByteArrayOutputStream());
    	System.out.println("encoding " + wtr.getEncoding());  
  }
}

-------- output from the text on Solaris 2.7 ----------------
(jdk versions: 1.4)

#> uname -a
SunOS falcon 5.7 Generic_106541-12 sun4u sparc SUNW,Ultra-5_10
#> java -version
java version "1.4.0beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0beta-b34)
Java HotSpot(TM) Core VM (build 1.3-internal, interpreted mode)

#> export LC_CTYPE=C

#> java Test
file.encoding 646
encoding ASCII

#> java -Dfile.encoding=Cp037 Test
file.encoding Cp037
encoding ASCII

#> export LC_CTYPE=ru

#> java Test
file.encoding ISO8859-5
encoding ISO8859_5

#> java -Dfile.encoding=Cp037 Test
file.encoding Cp037
encoding ISO8859_5

example of correctly behavior on Solaris 2.7:

#> /usr/local/java/jdk1.1.8/solaris/bin/java -Dfile.encoding=Cp037 Test
K@��������%@��������%


-------- output from the text on Solaris 2.6 ----------------
#> uname -a
SunOS helmet 5.6 Generic_105181-16 sun4u sparc SUNW,Ultra-

#> java -version
java version "1.4.0beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0beta-b34)
Java HotSpot(TM) Core VM (build 1.3-internal, interpreted mode)

correctly works when LC_CTYPE=C

#> export LC_CTYPE=C
#> java Test
file.encoding 8859_1
encoding ISO8859_1

#> java -Dfile.encoding=Cp037 Test
K@��������@��������

Incorrectly works when LC_CTYPE=ru
#> export LC_CTYPE=ru

#> java Test
file.encoding koi8-r
encoding KOI8_R

#> java -Dfile.encoding=Cp037 Test
file.encoding Cp037
encoding KOI8_R


----------------------------------------------

======================================================================

Comments
EVALUATION Not a bug; the file.encoding property is read-only. -- mr@eng 2000/10/12
178-08-10 0