public static void setSize(List<?> list, int size) {
		if (size < list.size()) {
			list.subList(size, list.size()).clear();
		}
		else {
			while (size > list.size()) {
				list.add(null);
			}
		}
	}
Find exact object type or subclass of cl in list
tool/src/org/antlr/v4/misc/Utils.java