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

java.io.RandomAccessFile.seek() specification is not precise

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      1.2fcs
    • CPU:
      generic, x86, sparc
    • OS:
      generic, solaris_2.5, solaris_2.6
    • Verification:
      Not verified

      Description

      This method does not throw an IOException if argument is greater than the length
      of the file.
      ==== Java Language Specification v1.0 says (22.23.5) ====
      public void seek(long pos) throws IOException
      ... An IOException is thrown if pos is less than zero or greater than the length of file ...
      ==== Here is the minimized test ====
      import java.io.*;

      public class java_io_RandomAccessFile_seek {
        public static void main( String argv[] ) {
          try {
            RandomAccessFile f=new RandomAccessFile("f","rw");
            System.out.println("file length is: "+f.length());
            f.seek(1000);
            f.write(1);
            System.out.println("file length is: "+f.length());
            f.close();
          }
          catch (IOException e) {
          }
        }
       
      }
      ==== Here is the output of the test ====
      file length is: 0
      file length is: 1001

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              gbrachasunw Gilad Bracha (Inactive)
              Reporter:
              mgorshen Mikhail Gorshenev (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: