private Type resolveJavaType(Class<?> clazz, List<String> classParameterTypes, java.lang.reflect.Type javaType)
	{
		if (javaType instanceof Class)
		{
			// The base case. A plain normal class type.
			String rawClass = ((Class) javaType).getCanonicalName();
			Type type = Type.getType(rawClass);

			if (!type.equals(TYPE_VOID) && !whitelistedClasses.containsKey(rawClass))	// Void is always OK (since it's basically a placeholder for "nothing")
			{
				throw new NonWhitelistedTypeException(rawClass);
			}

			return Type.getType(rawClass);
		}
		// [ListingStart][L9]
		else if (javaType instanceof ParameterizedType)
		{
			// This type has at least one named parameter, like ArrayList<Integer>.
			ParameterizedType paraTypes = (ParameterizedType) javaType;
			String rawClass = ((Class) paraTypes.getRawType()).getCanonicalName();

			// Ensure that the parameterized class is whitelisted
			if (!whitelistedClasses.containsKey(rawClass))
			{
				throw new NonWhitelistedTypeException(rawClass);
			}

			List<String> paraStrings = new LinkedList<String>();

			for (java.lang.reflect.Type paraType : paraTypes.getActualTypeArguments())
			{
				// We do not (yet) support nesting, so this will work for ArrayList<Integer>
				// but not for ArrayList<ArrayList<Integer>> for example
				String paraTypeName = ((Class) paraType).getCanonicalName();

				// Ensure that the parameter class is whitelisted
				if (!whitelistedClasses.containsKey(paraTypeName))
				{
					throw new NonWhitelistedTypeException(paraTypeName);
				}

				paraStrings.add(paraTypeName);
			}

			// Compile final type string
			return Type.getType(rawClass + "<" + Tools.implode(paraStrings, ",") + ">");
		}
		// [ListingEnd][L9]
		else if (javaType instanceof TypeVariable)
		{
			// This is a type variable, like in "boolean add(E e)". Look it up in our lookup list. Should already be whitelisted by now
			return Type.getType(classParameterTypes.get(Arrays.asList(clazz.getTypeParameters()).indexOf(javaType)));
		}
		else
		{
			throw new UnsupportedTypeException(javaType);
		}
	}