static Class<?> getGenericType(java.lang.reflect.Field f, int index)
    {
        try
        {
            Type type = ((ParameterizedType) f.getGenericType())
                    .getActualTypeArguments()[index];
            if (type instanceof GenericArrayType)
            {
                int dimensions = 1;
                Type componentType = ((GenericArrayType) type)
                        .getGenericComponentType();
                while (componentType instanceof GenericArrayType)
                {
                    dimensions++;
                    componentType = ((GenericArrayType) componentType)
                            .getGenericComponentType();
                }

                // TODO is there a more efficient way (reflection) to obtain an
                // array class?

                if (dimensions == 1)
                    return Array.newInstance((Class<?>) componentType, 0)
                            .getClass();

                final int[] arg = new int[dimensions];
                arg[0] = 0;
                return Array.newInstance((Class<?>) componentType, arg)
                        .getClass();
            }

            if (type instanceof ParameterizedType)
            {
                // TODO in the future, we can opt to do recursive type
                // inspection which can avoid including type metadata even with
                // very complex nested generic types (E.g a
                // List<List<List<String>>>).

                // special handling when generic type is either Class<?> or
                // Enum<?>
                Object rawType = ((ParameterizedType) type).getRawType();
                if (Class.class == rawType)
                    return Class.class;

                if (Enum.class == rawType)
                    return Enum.class;

                return null;
            }

            return (Class<?>) type;
        }
        catch (Exception e)
        {
            return null;
        }
    }
Gets the runtime field factory of the given {@code clazz}.
protostuff-runtime/src/main/java/io/protostuff/runtime/RuntimeFieldFactory.java