JDK-4263816 : -Dfile.encoding does not work
  • Type: Bug
  • Component: hotspot
  • Sub-Component: runtime
  • Affected Version: 1.3.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 1999-08-19
  • Updated: 1999-08-20
  • Resolved: 1999-08-20
Related Reports
Duplicate :  
Relates :  
Description

Name: dkC59003			Date: 08/19/99



Classic VMs (from 1.2 to Kestrel fcs) fail to pass the test below (return value is 97)
both on win32 and Solaris: setting the file encoding on the command line does not
affect the default file Encoding classes used by the sun.io ByteToCharConverter and 
CharToByteConverter classes.
For instance:

$ java -classic -version
java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-A)
Classic VM (build 1.3.0-A, green threads, nojit)
$ java -classic -Dfile.encoding=8859_1 b4242737
encProperty == '8859_1'
Default ByteToChar Class == 'sun.io.ByteToCharISO8859_5'
Default CharToByte Class == 'sun.io.CharToByteISO8859_5'
$ echo $status
97

As well the test is failed by HotSpot VMs 1.3beta and by HotSpot 1.0.1fcs-G.
The test is passed by classic VM 1.1.8 on Solaris. 

The test was developed as a regression test for the bug filed against 
HotSpot 1.0_fcs:
#4242737 Synopsis: 1.1: -Dfile.encoding does not work with HOTSPOT and JAVA2 (1.2.1) 
(Integrated in releases: 1.1_alpha).

----------------------------------------------------------- b4242737.java
import java.io.PrintStream;
import sun.io.*;

public class b4242737 {

    public static void main(String argv[]) {
        System.exit(run(argv, System.out) + 95/*STATUS_TEMP*/);
    }

    public static int run(String args[], PrintStream out) {
	String encProperty = System.getProperty("file.encoding");
   	String byteToCharClass = 
sun.io.ByteToCharConverter.getDefault().getClass().getName();
   	String charToByteClass = 
sun.io.CharToByteConverter.getDefault().getClass().getName();
	boolean res = true;

	out.println("encProperty == '" + encProperty + "'");
	if (! byteToCharClass.equals("sun.io.ByteToCharISO8859_1")) {
	    out.println("Default ByteToChar Class == '" + byteToCharClass + "'");
	    res = false;
	}
	if (! charToByteClass.equals("sun.io.CharToByteISO8859_1")) {
	    out.println("Default CharToByte Class == '" + charToByteClass + "'");
	    res = false;
	}
	return (res ? 0/*STATUS_PASSED*/ : 2/*STATUS_FAILED*/);
    }
}

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

Comments
EVALUATION Not a bug. See 4163515. The file.encoding property is read-only, so changing its value on the command line is not intended to have any effect. -- mr@eng 1999/8/19
08-07-0185