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