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

AssertionError thrown from FileChannel.map()

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 5.0
    • 5.0
    • core-libs
    • b28
    • generic, sparc
    • generic, solaris_9

      The following small program throws an assertion error when asserts
      are enabled. I don't see anything wrong with the program and it clearly
      finds the file properly so I think the bug is in NIO

      import java.io.*;
      import java.nio.*;
      import java.nio.channels.*;

      public class Map {

         public static void main(String [] args) {
             try {
      RandomAccessFile raf = new RandomAccessFile("/etc/passwd", "r");
      FileChannel fc = raf.getChannel();
      long fileSize = fc.size();
      System.out.println("filesize = " + fileSize);
      MappedByteBuffer mapBuf =
      fc.map(FileChannel.MapMode.READ_ONLY, 0l, fileSize);
             } catch (Throwable t) {
      t.printStackTrace();
             }
         }
      }

      % /import/java/jdk1.5/solaris-sparc/bin/java -esa Map
      filesize = 467
      java.lang.AssertionError
      at sun.nio.ch.FileChannelImpl.map(FileChannelImpl.java:745)
      at Map.main(Map.java:13)

            mmcclosksunw Michael Mccloskey (Inactive)
            prr Philip Race
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: