harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Anton Ivanov (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-2464) Compatibility: reset() method called on Buffer without mark() previously called should cause InvalidMarkException
Date Tue, 05 Dec 2006 13:44:21 GMT
Compatibility: reset() method called on Buffer without mark() previously called should cause
InvalidMarkException
-----------------------------------------------------------------------------------------------------------------

                 Key: HARMONY-2464
                 URL: http://issues.apache.org/jira/browse/HARMONY-2464
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: Anton Ivanov
            Priority: Minor


There are some obscure things about reset(), duplicate(), asReadOnly() methods in specification.

When we obtain a duplicate of this Buffer (for example IntBuffer) by calling to its duplicate()
method
this duplicate Buffer has identical to original Buffer mark, position, limit and capacity
values (according to specification). 
But the question is: If mark is defined (set) for original Buffer after mark() method was
called on it can we believe
that mark is defined (set) for the duplicate Buffer?
If we believe so, we can call reset() method on duplicate Buffer according to specification.
But RI throws InvalidMarkException here. Is this a RI bug or Harmony bug?

The same problem arises when we use asReadOnly() method instead of duplicate() method.

Test to reproduce the problem:

import junit.framework.TestCase;
import java.nio.CharBuffer;
import java.nio.InvalidMarkException;

public class Test extends TestCase {
    public void test1() {
        char[] cc = {'b', 'u', 'f', 'f', 'e', 'r'};
        CharBuffer cb = CharBuffer.wrap(cc);

        try {
            cb.mark();
            CharBuffer roBuf = cb.asReadOnlyBuffer();
            roBuf.reset();
            fail("InvalidMarkException should be thrown");          
        } catch (InvalidMarkException e) {
            //passed
        }
    }

    public void test2() {
        char[] cc = {'b', 'u', 'f', 'f', 'e', 'r'};
        CharBuffer cb = CharBuffer.wrap(cc);

        try {
            cb.mark();
            CharBuffer dupBuf = cb.duplicate();
            dupBuf.reset();          
            fail("InvalidMarkException should be thrown"); 
        } catch (InvalidMarkException e) {
            //passed
        }
    }
}  


-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message