Here you can find the source of setFieldValue(Object instance, Field field, Object value)
static void setFieldValue(Object instance, Field field, Object value)
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.lang.reflect.Field; public class Main { /** Sets a field value via reflection. */ static void setFieldValue(Object instance, Field field, Object value) { try {/*from ww w .j a v a 2 s . c o m*/ field.set(instance, value); } catch (IllegalAccessException e) { throw new IllegalStateException(e); } } }