Duplicate :
|
|
Relates :
|
Name: jl125535 Date: 08/04/2004 A DESCRIPTION OF THE REQUEST : java.nio.Buffer subclasses should support covariant return types for methods mark(), limit(int), position(int)... JUSTIFICATION : These methods return 'this', so multiple statements can be put in one line. Therefore the reference returned should be a subclass of Buffer so that methods specific to the subclass can be called on the same line. EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - ByteBuffer should return a ByteBuffer when calling methods mark(), clear(), flip()... ACTUAL - ByteBuffer.mark() returns a Buffer reference. ---------- BEGIN SOURCE ---------- import java.nio.*; public class BufferRFE { public static void main(String[] args) { ByteBuffer buffer = ByteBuffer.allocate(1024); buffer.mark().put(new byte[1024]).rewind();// compile-time error Method put() not found in class Buffer } } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : buffer.mark(); buffer.put(new byte[1024]); buffer.rewind(); (Incident Review ID: 295628) ======================================================================