class CloseableReentrantReadWriteLock extends ReentrantReadWriteLock {

    private static final long serialVersionUID = 95L;

    private transient ResourceLock readUnlocker = newReadUnlocker();

    private transient ResourceLock writeUnlocker = newWriteUnlocker();

    /**
     * @return a defined {@link ResourceLock} once the {@link #readLock()} has
     * been acquired
     */
    public ResourceLock readLockAsResource() {<FILL_FUNCTION_BODY>}

    /**
     * @return a defined {@link ResourceLock} once the {@link #writeLock()}
     * has been acquired
     */
    public ResourceLock writeLockAsResource() {
        /*
         * A subclass of ReentrantReadWriteLock is forced to be serializable, so
         * we would have to handle where serialization can short-circuit field
         * initialization above and leave the instance's fields null.
         * Consequently, the fields cannot be final. They are encapsulating
         * fixed logic, so we can optimize and choose not to even bother
         * serializing by declaring transient and handling below.
         */
        ResourceLock unlocker = writeUnlocker;
        if (unlocker == null) {
            unlocker = newWriteUnlocker();
            // No synchronization necessary since overwrite is of no matter.
            writeUnlocker = unlocker;
        }
        writeLock().lock();
        return unlocker;
    }

    private ResourceLock newReadUnlocker() {
        return () -> this.readLock().unlock();
    }

    private ResourceLock newWriteUnlocker() {
        return () -> this.writeLock().unlock();
    }
}

        /*
         * A subclass of ReentrantReadWriteLock is forced to be serializable, so
         * we would have to handle where serialization can short-circuit field
         * initialization above and leave the instance's fields null.
         * Consequently, the fields cannot be final. They are encapsulating
         * fixed logic, so we can optimize and choose not to even bother
         * serializing by declaring transient and handling below.
         */
        ResourceLock unlocker = readUnlocker;
        if (unlocker == null) {
            unlocker = newReadUnlocker();
            // No synchronization necessary since overwrite is of no matter.
            readUnlocker = unlocker;
        }
        readLock().lock();
        return unlocker;
    
<methods>public void <init>() ,public void <init>(boolean) ,public final int getQueueLength() ,public int getReadHoldCount() ,public int getReadLockCount() ,public int getWaitQueueLength(java.util.concurrent.locks.Condition) ,public int getWriteHoldCount() ,public final boolean hasQueuedThread(java.lang.Thread) ,public final boolean hasQueuedThreads() ,public boolean hasWaiters(java.util.concurrent.locks.Condition) ,public final boolean isFair() ,public boolean isWriteLocked() ,public boolean isWriteLockedByCurrentThread() ,public java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock readLock() ,public java.lang.String toString() ,public java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock writeLock() <variables>private final java.util.concurrent.locks.ReentrantReadWriteLock.ReadLock readerLock,private static final long serialVersionUID,final java.util.concurrent.locks.ReentrantReadWriteLock.Sync sync,private final java.util.concurrent.locks.ReentrantReadWriteLock.WriteLock writerLock