Hi,

Am 15.04.2014 10:05, schrieb Richard Warburton:
Hi,

I'd like to have a discussion about tidying up a few core library method
signatures in a way that (I think) is backwards compatible.

I've been using ByteBuffer quite a lot recently which is designed to be a
fluent API. Unfortunately its quite inconvenient to use because there's a
hierarchy of classes at play (MappedByteBuffer, ByteBuffer and Buffer) and
methods which are inherited from parent classes aren't overridden with
covariant return types. For example the following code doesn't compile
because clear is defined on Buffer and putInt is defined on ByteBuffer.

ByteBuffer buffer = ByteBuffer.allocate(256);

ByteBuffer other = buffer.duplicate()
                          .clear()
                          .putInt(0, 4);

If clear was overridden in ByteBuffer with ByteBuffer as its return type
then this would compile.

See also:

http://mail.openjdk.java.net/pipermail/core-libs-dev/2009-April/001512.html
http://mail.openjdk.java.net/pipermail/core-libs-dev/2009-April/001365.html
http://mail.openjdk.java.net/pipermail/coin-dev/2009-March/001180.html

https://bugs.openjdk.java.net/browse/JDK-6472931
https://bugs.openjdk.java.net/browse/JDK-6373386
https://bugs.openjdk.java.net/browse/JDK-6479372
https://bugs.openjdk.java.net/browse/JDK-4774077
https://bugs.openjdk.java.net/browse/JDK-6451131
https://bugs.openjdk.java.net/browse/JDK-5082736

-Ulf

Reply via email to