private static Class<?> getCollectionArg(Field field) {
    // TODO: this makes many assumptions, e.g. on how generic args are done
    Type genericType = field.getGenericType();
    if (genericType instanceof ParameterizedType) {
      Type type = ((ParameterizedType) genericType).getActualTypeArguments()[0];
      if (type instanceof Class<?>) {
        return (Class<?>) type;
      } else {
        // TODO: we could try to get the declaring object and infer argument... stupid Java.
        LOG.trace("Cannot determine collection type: {}", field);
      }
    } else {
      // TODO: we could try to get superclass or generic interfaces.
      LOG.trace("Non-parametrized collection type: {}", field);
    }
    return null;
  }
Creates size estimators for java objects. The estimators attempt to do most of the reflection
work at initialization time, and also take some shortcuts, to minimize the amount of work done
during the actual estimation.
TODO: clean up
storage-api/src/java/org/apache/hadoop/hive/ql/util/IncrementalObjectSizeEstimator.java