Here you can find the source of setFieldValue(Object target, Field field, Object value)
public static void setFieldValue(Object target, Field field, Object value) throws IllegalArgumentException, IllegalAccessException
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Field; public class Main { public static void setFieldValue(Object target, Field field, Object value) throws IllegalArgumentException, IllegalAccessException { if (field.isAccessible()) { field.set(target, value);//from www. j a v a 2 s. c o m } else { field.setAccessible(true); field.set(target, value); field.setAccessible(false); } } }