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

-Dfile.encoding does not work

XMLWordPrintable

    • generic
    • generic



      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*/);
          }
      }

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

            mr Mark Reinhold
            dkhukhrosunw Dmitry Khukhro (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: