ReflectionUtil { public static Field getDeclaredField(Class<?> clazz, String name) throws Exception { Field field = clazz.getDeclaredField(name); field.setAccessible(true); return unfinalField(field); }  static Object arrayClone(Object array); static Field getDeclaredField(Class<?> clazz, String name); static Field[] getDeclaredFields(Class<?> clazz); static Method getDeclaredMethod(
			Class<?> clazz, String name, Class<?>... parameterTypes); static Class<?>[] getInterfaces(Object object); static Class<?>[] getInterfaces(
		Object object, ClassLoader classLoader); static Class<?>[] getInterfaces(
		Object object, ClassLoader classLoader,
		Consumer<ClassNotFoundException> classNotFoundHandler); static T throwException(Throwable throwable); static Field unfinalField(Field field);  }
@Test public void testGetDeclaredField() throws Exception { Field staticField = ReflectionUtil.getDeclaredField( TestClass.class, "_privateStaticFinalObject"); Assert.assertTrue(staticField.isAccessible()); Assert.assertFalse(Modifier.isFinal(staticField.getModifiers())); Assert.assertSame( TestClass._privateStaticFinalObject, staticField.get(null)); Object object = new Object(); staticField.set(null, object); Assert.assertSame(object, TestClass._privateStaticFinalObject); TestClass testClass = new TestClass(); Field field = ReflectionUtil.getDeclaredField( TestClass.class, "_privateFinalObject"); Assert.assertTrue(field.isAccessible()); Assert.assertTrue(Modifier.isFinal(field.getModifiers())); Assert.assertSame(testClass._privateFinalObject, field.get(testClass)); field.set(testClass, object); Assert.assertSame(object, testClass._privateFinalObject); }