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

Merlin:java.nio.MappedByteBuffer.isReadOnly() wrong

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.4.0
    • core-libs
    • beta2
    • x86
    • windows_2000
    • Verified


      ingrid.yao@Eng 2001-05-23

      J2SE Version (please include all output from java -version flag):

         java version "1.4.0-beta"
         Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b64)
         Java HotSpot(TM) Client VM (build 1.4.0-beta-b64, mixed mode)

      Does this problem occur on J2SE 1.3? Yes / No (pick one)

         Feature Not exists

      Operating System Configuration Information (be specific):

           Win 2000 5.00.2195 Service pack 1

      Hardware Configuration Information (be specific):

          x86 Family 6 Model 7 Stepping 3

      Bug Description:

          java.nio.MappedByteBuffer.isReadOnly() returns false, should be true

      Test program
      ================

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


      public class readNIOSmap {

         public static void main(String[] args) throws Exception {
      readNIOSmap();
         }

         private static void readNIOSmap() throws IOException {
           long startTime = System.currentTimeMillis();

           RandomAccessFile raf = new RandomAccessFile("testFile", "r");
           FileChannel channel = raf.getChannel();
           MappedByteBuffer buff = channel.map(FileChannel.MAP_RO, 0, (int) raf.length());
           buff.load();
           System.out.println(" read NIO map: "+ buff.isDirect()+" "+buff.isLoaded()+" "+ buff.isReadOnly());

           raf.close();

           long tookTime = System.currentTimeMillis() - startTime;
           System.out.println("Read NIO Stream mapped takes "+ (tookTime*.001) + " seconds");
         }
      }

            mmcclosksunw Michael Mccloskey (Inactive)
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: