[concurrency-interest] ReentrantReadWriteLock backport non-matching signature

David Holmes dcholmes at optusnet.com.au
Fri Jul 14 00:06:24 EDT 2006

Hmm that was a weird three-day lag in the emails getting through :)

No covariant return types don't support any coercion of the return type, the
overriding method's return type must be a subtype of the overridden method.

  -----Original Message-----
  From: Dhanji R. Prasanna [mailto:dhanji at gmail.com]
  Sent: Friday, 14 July 2006 9:03 AM
  To: dholmes at ieee.org
  Cc: Holger Hoffstatte; concurrency-interest at cs.oswego.edu
  Subject: Re: [concurrency-interest] ReentrantReadWriteLock backport
non-matching signature

  Somewhat off topic--does anyone know if covariant return types support
boxing for primitives?
  For instance can I return Serializable on an overriden int method?
  (eclipse complains, but I know eclipse has plenty of bugs with its
"intelligent" sensing features)

  On 7/11/06, David Holmes <dcholmes at optusnet.com.au> wrote:
    Holger Hoffstatte writes:
    > Maybe it was just an oversight. Still, the whole point of having
    > interfaces is to decouple from the concrete class. I remember when I
    > to make the backport run (at least partly) on native j.u.c. this was
    > of the primary showstoppers, at least for me.

    co-variant return types means we can get the best of both worlds. The
    can declare that it returns a more specific type that the client may
    to use, if there is something more specific that the client wants to
    But the client is free to declare their variables as the less specific
    interface, type.

    This is no different to doing:

    ReentrantLock l = new ReentrantLock();

    rather than:

    Lock l = new ReentrantLock();

    You get to choose the type of your variables.

    > Regarding the incompatibility it seems Moran has found a good solution
    > just referring to the interface in client code. (phew!)

    That's good.


    Concurrency-interest mailing list
    Concurrency-interest at altair.cs.oswego.edu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/attachments/20060714/e6da23bb/attachment.html 

More information about the Concurrency-interest mailing list