code: public boolean upgradeLock(TransactionImpl tx, Object obj)
      {
          LockEntry writer = getWriter(obj);
          if (writer == null)
          {
              Collection readers = this.getReaders(obj);
              if (readers.size() == 1)
              {
                  LockEntry reader = (LockEntry) readers.iterator().next();
                  if (reader.isOwnedBy(tx))
                  {
                      if (upgradeLock(reader))
                          return true;
                      else
                          return upgradeLock(tx, obj);
                  }
              }
              else if (readers.size() == 0)
              {
                  if (setWriter(tx, obj))
                      return true;
                  else
                      return upgradeLock(tx, obj);
              }
  
  
          }
          else if (writer.isOwnedBy(tx))
          {
              return true;    // If I already have Write, then I've upgraded.
          }
  
          return false;
      }
docs: acquire a lock upgrade (from read to write) lock on Object obj for Transaction tx.
  @param tx the transaction requesting the lock
  @param obj the Object to be locked
  @return true if successful, else false