### Question:
ClassUtil { public static <T> void setField(String fieldName, Object o, T value) { Class<?> klass = o.getClass(); while (klass != null) { try { Field f = klass.getDeclaredField(fieldName); f.setAccessible(true); f.set(o, value); return; } catch (Exception e) { klass = klass.getSuperclass(); } } } ClassUtil(); static boolean isPresent(String className); static boolean isPresent(String className, ClassLoader classLoader); static String getClassNameForObject(Object object); static String getClassName(Class clazz); static String getClassName(String className); static String getShortClassNameForObject(Object object); static String getShortClassName(Class clazz); static String getShortClassName(String className); static String getPackageNameForObject(Object object); static String getPackageName(Class clazz); static String getPackageName(String className); static String getClassNameForObjectAsResource(Object object); static String getClassNameAsResource(Class clazz); static String getClassNameAsResource(String className); static String getPackageNameForObjectAsResource(Object object); static String getPackageNameAsResource(Class clazz); static String getPackageNameAsResource(String className); static Class getArrayClass(Class componentType, int dimension); static Class getArrayComponentType(Class type); static int getArrayDimension(Class clazz); static List getSuperclasses(Class clazz); static List getInterfaces(Class clazz); static boolean isInnerClass(Class clazz); static boolean isAssignable(Class[] classes, Class[] fromClasses); static boolean isAssignable(Class clazz, Class fromClass); static Class getPrimitiveType(Class clazz); static Class getNonPrimitiveType(Class clazz); @SuppressWarnings("unchecked") static T getField(String fieldName, Object o); static void setField(String fieldName, Object o, T value);  }### Answer:
@Test public void setFieldTest() { ThreadPoolTaskExecutor threadPool = new ThreadPoolTaskExecutor(); ClassUtil.setField("queueCapacity", threadPool, 10); Integer capacity = ClassUtil.getField("queueCapacity", threadPool); if (capacity != null) { Assert.assertEquals(10, (long) capacity); } }