You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@harmony.apache.org by "Mikhail Markov (JIRA)" <ji...@apache.org> on 2007/01/11 07:50:27 UTC

[jira] Commented: (HARMONY-2464) [classlib][nio] Compatibility: reset() method called on Buffer without mark() previously called should cause InvalidMarkException

    [ https://issues.apache.org/jira/browse/HARMONY-2464?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12463817 ] 

Mikhail Markov commented on HARMONY-2464:
-----------------------------------------

I've also checked this testcase on RI - it does not throw InvalidMarkexception on JDK6 and Harmony and throws the exception on JDK5.

So, +1 for moving it to "non-bug difference" category and closing it as "won't fix".

> [classlib][nio] Compatibility: reset() method called on Buffer without mark() previously called should cause InvalidMarkException
> ---------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: HARMONY-2464
>                 URL: https://issues.apache.org/jira/browse/HARMONY-2464
>             Project: Harmony
>          Issue Type: Bug
>          Components: Classlib
>            Reporter: Anton Ivanov
>         Assigned To: Tim Ellison
>            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: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira