JDK-4416536 : (bf) CharBuffer.subSequence() does not represent specified subsequence
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 1.4.0
  • Priority: P3
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,solaris_7
  • CPU: generic,sparc
  • Submitted: 2001-02-17
  • Updated: 2001-10-04
  • Resolved: 2001-10-02
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.4.0 beta3Fixed
Related Reports
Duplicate :  
Duplicate :  
Description
StringCharBuffer.subSequence(int start,int end) does not represent specified subsequence of buffer, relative to the current position. 


String source = "This is the string used to test subSequence() method";
StringCharBuffer c = (StringCharBuffer)(CharBuffer.wrap(source));
// Set the position of c to some value.
int position = 5;
c.position(position);
int start = 5;
int end = 10;
CharBuffer cNew = (CharBuffer)(c.subSequence(start,end));
if(!source.substring(position+start,position+end).equals(cNew.toString())) {
 System.out.println("error");
 System.out.println("New buffer contains: "+cNew.toString());   
 System.out.println("Expected: "+source.substring(position+start,position+end));
} 

results in  :
error
New buffer contains: is th
Expected: e str


###@###.### 2001-10-04
Since StringCharBuffer is no longer public class, this bug cannot be verified.
Bug 4511104 has been created that addresses CharBuffer's issues. (see 4415483)

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: merlin-beta2 merlin-beta3 FIXED IN: merlin-beta3 INTEGRATED IN: merlin-beta3 VERIFIED IN: merlin-beta3
14-06-2004

EVALUATION Implementation bug. (Note that java.nio.StringCharBuffer is not supposed to be a public class, but that's a different bug.) -- mr@eng 2001/4/16 StringCharBuffer.subSequence() fails to determine the new CharBuffer relative to the position(). Modified the call to the StringCharBuffer constructor accordingly. -- iag@eng 2001-08-09
09-08-2001