Here you can find the source of setFieldValue(Object object, Field field, Object value)
public static void setFieldValue(Object object, Field field, Object value)
//package com.java2s; //License from project: Apache License import java.lang.reflect.Field; public class Main { public static void setFieldValue(Object object, Field field, Object value) {// www. j av a 2 s. com try { setAccessibleIfNeeded(field); field.set(object, value); } catch (final Exception e) { throw new RuntimeException(e); } } public static void setAccessibleIfNeeded(Field field) { if (!field.isAccessible()) { field.setAccessible(true); } } }