Here you can find the source of setFieldValue(Object target, Field field, Object newValue)
public static void setFieldValue(Object target, Field field, Object newValue) throws NoSuchFieldException
//package com.java2s; import java.lang.reflect.Field; public class Main { public static void setFieldValue(Object target, Field field, Object newValue) throws NoSuchFieldException { boolean accessible = field.isAccessible(); field.setAccessible(true);/*from ww w. j a v a2 s .co m*/ try { field.set(target, newValue); } catch (IllegalAccessException e) { throw new NoSuchFieldException("No such field: " + target.getClass() + '.' + field.getName()); } finally { field.setAccessible(accessible); } } }