public synchronized int add(Object obj, int iref) {
		// Make sure the object reference is not null
		if (obj == null) {
			throw new NullPointerException();
		}

		// check whether object is already in the hashtable...
		HashedRefsEntry tab[] = table;
		int hash = java.lang.System.identityHashCode(obj);
		int index = (hash & 0x7FFFFFFF) % tab.length;
		for (HashedRefsEntry e = tab[index]; e != null; e = e.next) {
			if ((e.hash == hash) && (e.obj == obj)) {
				return e.iref; // existing global reference to this object
			}
		}

		if (count >= threshold) {
			// Rehash the table if the threshold is exceeded
			rehash();
			return add(obj, iref);
		}

		// create a new entry...
		HashedRefsEntry e = new HashedRefsEntry();
		e.hash = hash;
		e.obj = obj;
		e.iref = iref;
		e.next = tab[index];
		tab[index] = e;
		count++;
		return 0; // indicates this reference has been added
	}