Here you can find the source of setFieldValue(Object obj, Field field, Object value)
public static void setFieldValue(Object obj, Field field, Object value)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Field; public class Main { public static void setFieldValue(Object obj, Field field, Object value) { field.setAccessible(true);/* w w w . j a va 2 s . com*/ try { field.set(obj, value); } catch (IllegalArgumentException e) { throw new RuntimeException("IllegalArgumentException", e); } catch (IllegalAccessException e) { throw new RuntimeException("IllegalAccessExceptione", e); } } }