Code example for GenericArrayType

Methods: getGenericComponentType

		} else if (type instanceof ParameterizedType) {
			ParameterizedType pType = (ParameterizedType) type;
			return (Class<?>)pType.getRawType();
		} else if (type instanceof GenericArrayType) {
			GenericArrayType aType = (GenericArrayType) type;
			Class<?> componentType = getClassType(aType.getGenericComponentType());
			return Array.newInstance(componentType, 0).getClass();
		} else { 
			throw new IllegalArgumentException("Only supports Class, ParameterizedType and GenericArrayType. Not " + type.getClass());
	private TypeToken<?> getFieldType(TypeToken<?> forType, String fieldName) {
		return getFieldType(forType.getType(), fieldName);
	 * Marker interface to mark the type of the field f. 
	 * Note: we could use a method instead of a field, so the method could be in the interface, 
	 * enforcing correct usage,  but that would influence the actual test too much.