Here you can find the source of setFieldValue(Field field, Object instance, T value)
public static <T> T setFieldValue(Field field, Object instance, T value) throws IllegalAccessException
//package com.java2s; //License from project: Apache License import java.lang.reflect.Field; public class Main { /**/*from w w w .j av a 2 s .c o m*/ * Sets the value for the field of the instance */ public static <T> T setFieldValue(Field field, Object instance, T value) throws IllegalAccessException { if (instance != null) { boolean oldAccessible = field.isAccessible(); field.setAccessible(true); field.set(instance, value); field.setAccessible(oldAccessible); return value; } return null; } }