[concurrency-interest] ReentrantReadWriteLock backport non-matching signature
dcholmes at optusnet.com.au
Mon Jul 10 22:37:13 EDT 2006
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 tried
> to make the backport run (at least partly) on native j.u.c. this was one
> of the primary showstoppers, at least for me.
co-variant return types means we can get the best of both worlds. The class
can declare that it returns a more specific type that the client may choose
to use, if there is something more specific that the client wants to use.
But the client is free to declare their variables as the less specific ie
This is no different to doing:
ReentrantLock l = new ReentrantLock();
Lock l = new ReentrantLock();
You get to choose the type of your variables.
> Regarding the incompatibility it seems Moran has found a good solution by
> just referring to the interface in client code. (phew!)
More information about the Concurrency-interest