[concurrency-interest] ReentrantReadWriteLock backport non-matchingsignature

Moran Avigdor moran at gigaspaces.com
Sun Jul 9 12:31:04 EDT 2006


Dawid,

You can narrow the backport implementation to return ReadLock and 
WriteLock respectively,
instead of returning the Lock interface. This will then have the same 
signature as Java 5.0

Moran



Dawid Kurzyniec wrote:
> 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