Uploaded image for project: 'Harmony'
  1. Harmony
  2. HARMONY-3638

[classlib][nio] JNI function GetDirectBufferCapacity() returns 0 on non-byte views of a direct buffer

    XMLWordPrintableJSON

Details

    Description

      The specification of JNI function GetDirectBufferCapacity() reads:
      "Returns the capacity in bytes of the memory region associated with the buffer. Returns -1 if the given object is not a direct java.nio.Buffer, or if JNI access to direct buffers is not supported by this virtual machine. "
      However it returns 0 for non-byte views of a direct buffer, i.e. buffers obtained like this:
      ByteBuffer.allocateDirect(100).asCharBuffer();

      Surprisingly, RI behaves in the same way; I found related bugreport [1] against Sun's JDK which has really vague evaluation. Briefly, it says that they don't want to spend efforts fixing this bug untill real use case exists and unaligned view buffers aren't supposed to work (at least on some architectures like sparc) anyway. How do you like that?

      I see no problem to fix this in Harmony and suppose we should follow the spec here.

      [1] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4528170

      Attachments

        Issue Links

          Activity

            People

              varlax Alexey Varlamov
              varlax Alexey Varlamov
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: