bug-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug classpath/22934] ByteBuffer.asReadOnlyBuffer fails when not marked


From: gcc-bugzilla at gcc dot gnu dot org
Subject: [Bug classpath/22934] ByteBuffer.asReadOnlyBuffer fails when not marked
Date: 16 Oct 2005 01:27:43 -0000

A ByteBuffer that is not marked, fails on the asReadOnlyBuffer method.

The reset method (that is called from duplicate(boolean), that is called from
asReadOnlyBuffer) throws an exception.

Ewout


------- Comment #1 from from-classpath at savannah dot gnu dot org  2005-05-02 
18:33 -------
This is true for DirectByteBufferImpl.

Not for wrapped / allocated ByteBuffers.


------- Comment #2 from from-classpath at savannah dot gnu dot org  2005-05-02 
19:13 -------
This implementation of duplicate(boolean) solves it.

  private ByteBuffer duplicate(boolean readOnly)
  {
    int pos = position();
    // @classpath-bugfix Changed mark detection
//    reset();
//    int mark = position();
//    position(pos);
    int mark = this.mark;
    DirectByteBufferImpl result;
    if (readOnly)
        result = new DirectByteBufferImpl.ReadOnly(owner, address, capacity(),
                                                   limit(), pos);
    else
        result = new DirectByteBufferImpl.ReadWrite(owner, address, capacity(),
                                                    limit(), pos);

    // @classpath-bugfix Added mark >= 0
    if ((mark != pos) && (mark >= 0))
      {
        result.position(mark);
        result.mark();
        result.position(pos);
      }
    return result;
  }


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22934





reply via email to

[Prev in Thread] Current Thread [Next in Thread]