Here you can find the source of setField(final Field field, final Object instance, final Object value)
public static void setField(final Field field, final Object instance, final Object value)
//package com.java2s; //License from project: Open Source License import java.lang.reflect.Field; public class Main { public static void setField(final Field field, final Object instance, final Object value) { if (field == null) { throw new RuntimeException("No such field"); }//from w w w.ja v a2s. c om field.setAccessible(true); try { field.set(instance, value); } catch (final Exception ex) { throw new RuntimeException(ex); } } }