[concurrency-interest] ReentrantReadWriteLock backport non-matchingsignature

Dawid Kurzyniec dawidk at mathcs.emory.edu
Sun Jul 9 11:17:27 EDT 2006


Moran Avigdor wrote:
> In java.util.concurrent.locks.ReentrantReadWriteLock readLock() and 
> writeLock() return Locks as follows:
>
>     public ReentrantReadWriteLock.WriteLock writeLock() { return 
> writerLock; }
>     public ReentrantReadWriteLock.ReadLock  readLock()  { return 
> readerLock; }
>
> While, in 
> edu.emory.mathcs.backport.java.util.concurrent.locks.ReentrantReadWriteLock 
> these are defined:
>
>     public Lock writeLock() { return writerLock_; }
>     public Lock readLock()  { return readerLock_; }
>
> Although ReentrantReadWriteLock.ReadLock/WriteLock are Lock-s this 
> incompatibility in signatures causes
> problems when using Retrotranslator.
>
> Any comments?
>
>   

ReentrantReadWriteLock implements ReadWriteLock interface, defined like 
this:

public interface ReadWriteLock {
    Lock readLock();
    Lock writeLock();
}

In Java 5.0, it is possible to narrow the return type in the 
implementation class to ReadLock and WriteLock, respectively. 
Unfortunately, the same isn't possible in Java 1.4.

Regards,
Dawid



More information about the Concurrency-interest mailing list