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

JCK13a: test api/java_io/FileWriter/index.html#FWConstructor2Test fails

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2
    • Resolution: Duplicate
    • Affects Version/s: 1.4.0
    • Fix Version/s: None
    • Component/s: core-libs
    • Subcomponent:
    • CPU:
      x86
    • OS:
      linux, windows_2000

      Description



      Name: iaR10016 Date: 03/22/2001



      The constructor FileWriter.FileWriter(File file, boolean append) works
      incorrectly under Windows OS.

      JavaTM 2 Platform Std. Ed. v1.4.0 reads:

      ...
      public FileWriter(File file, boolean append) throws IOException

      Constructs a FileWriter object given a File object.
      If the second argument is true, then bytes will be written to
      the end of the file rather than the beginning.
      ...

      FileWriter(File file, boolean append) works correctly under Linux OS.
      But under Windows bytes become written into the begining of the file
      irrespective of the "append" meaning.

      Failing Test:
      =============
      api/java_io/FileWriter/index.html#FWConstructor2Test

      JCK :
      =====
      JCK1.3a

      Test source location:
      ====================
      /net/jdk/export/disk8/local.java/jck1.3a/JCK-runtime-13a/tests/api/java_io/FileWriter/FWCons2Test.java

      Platforms:
      =============
      Windows

      JDK, switches Info:
      ===================
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b56)
      Java HotSpot(TM) Client VM (build 1.4-beta-B56, mixed mode)

      -hotspot -Xmixed
      -server -Xmixed
      -server -Xcomp

      jtr file location:
      ==================

      /net/jtgb4u4c.eng/export/sail16/results/merlin/b56/jck13a/win32/win2000_client_linux-17/workDir/api/java_io/FileWriter/index_FWConstructor2Test.jtr

      How to reproduce:
      ====================

      Compile and run the following code:

      ------------------------ test.java -----------------------

      import java.io.*;

      public class test {

          private static void fileWrite(String filePath, char i) {
              try {
                  FileWriter fw = new FileWriter( filePath, true );
                  fw.write(i);
                  fw.close();
              }
              catch(Exception e) {
                  System.out.println(e);
              }
          }

         public static void ReadFile(String filePath, boolean flg) {
              System.out.println("Reading the file:");
              char[] cbuf = new char[2];
              try {
                  FileReader fr = new FileReader(filePath);
                  int i=fr.read(cbuf);
                  for( int j=0; j<i; j++) System.out.println(cbuf[j]);
                  if (flg & i!=2) System.out.println("Text was not appended correctly!");
                  fr.close();
              }
              catch(Exception e) {
                  System.out.println(e);
              }
         }

          public static void main(String[] args) {
              String filePath = "TempFile.txt";
              new File(".", "TempFile.txt").delete();
              fileWrite(filePath,'1');
              ReadFile(filePath, false);
              fileWrite(filePath,'2');
              ReadFile(filePath, true);
          }

      }

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

      Test output:
      =============

      Windows:

      [H:/ira/tests] C:/jdk1.4.0/bin/java -version
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b56)
      Java HotSpot(TM) Client VM (build 1.4-beta-B56, mixed mode)
      [H:/ira/tests] C:/jdk1.4.0/bin/java test
      Reading the file:
      1
      Reading the file:
      2
      Text was not appended correctly!
      [H:/ira/tests]

      Linux:

      $ /net/linux-15/export/home/jdk1.4.0/linux/bin/java -version
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b56)
      Java HotSpot(TM) Client VM (build 1.4-beta-B56, mixed mode)
      $ /net/linux-15/export/home/jdk1.4.0/linux/bin/java test
      Reading the file:
      1
      Reading the file:
      1
      2
      $

      Specific Machine Info:
      =====================
      Hostname: linux-16

      Additional JCK related info:
      ============================
      URL to find JCK test owners: http://javaweb.eng/jct/sqe/JCK-tck/usr/owners.jto
      JCK FAQ: http://javaweb.eng/jck/usr/ConformanceTesting/JCKconformanceFaq.html

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mmcclosksunw Michael Mccloskey (Inactive)
              Reporter:
              irasunw Ira Ira (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: