code: @SuppressWarnings("unchecked")
    private T readReference(Class<T> type, BufferInput<?> buffer, Serializer serializer) {
      ReferencePool<?> pool = pools.get(type);
      if (pool == null) {
        Constructor<?> constructor = constructorMap.get(type);
        if (constructor == null) {
          try {
            constructor = type.getDeclaredConstructor(ReferenceManager.class);
            constructor.setAccessible(true);
            constructorMap.put(type, constructor);
          } catch (NoSuchMethodException e) {
            throw new SerializationException("failed to instantiate reference: must provide a single argument constructor", e);
          }
        }
  
        pool = new ReferencePool<>(createFactory(constructor));
        pools.put(type, pool);
      }
      T object = (T) pool.acquire();
      object.readObject(buffer, serializer);
      return object;
    }
docs: Reads an object reference.
  
  @param type The reference type.
  @param buffer The reference buffer.
  @param serializer The serializer with which the object is being read.
  @return The reference to read.