JDK-4397522 : Read only status of file.encoding varies by platform
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version: 1.3.0
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • OS: generic
  • CPU: generic
  • Submitted: 2000-12-13
  • Updated: 2001-05-24
  • Resolved: 2001-05-24
Related Reports
Relates :  

Name: skT45625			Date: 12/12/2000

Windows: java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0-C)
Java HotSpot(TM) Client VM (build 1.3.0-C, mixed mode)

java version "1.3.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)

file.encoding is read-only with linux jre 1.3, but Windows
98 1.3 jre allows file.encoding to be set on command line
(both java and javaw).

Example a: In windows 98 'java -Dfile.encoding=bogus foo'
yields "Error occurred during initialization of VM
java/lang/ClassNotFoundException: sun/io/CharToBytebogus"

Example b: Under linux 'java -Dfile.encoding=bogus foo'
yields "Exception in thread "main"
java.lang.NoClassDefFoundError: foo"
(Review ID: 113683) 

WORK AROUND Name: skT45625 Date: 12/12/2000 Because the property accessibility depends on the jvm implementation it is a weakness in java portability. I argue for the following: 1. Make all the jvm's treat the file.encoding the same 2. Make file.encoding r/w instead of r-o Why read/write? Because in practice many people work with languages that are not primary to their os, in multiple languages, and with encodings unspecific to a locale. By making file.encoding r/w you are removing a pesky limitation from such users. Also- although every library in the world should allow encoding switching but many, like some jdbc drivers, don't and file.encoding is the only way to get at it. ======================================================================

EVALUATION This is not a bug. The file.encoding system property is read-only and not listed as one of the system properties which can be changed. The fact that it does on some platforms should not be relied upon. Please see bug 4163515 for more information. Ian.Little@Ireland 5/24/2001