Here you can find the source of setField(final Field field, final Object object, final Object value)
Parameter | Description |
---|---|
field | of the object to set |
object | that has the field |
value | to set |
Parameter | Description |
---|---|
IllegalArgumentException | if the field cannot be set |
public static void setField(final Field field, final Object object, final Object value)
//package com.java2s; /* See LICENSE for licensing and NOTICE for copyright. */ import java.lang.reflect.Field; public class Main { /**//from w w w .j a v a 2s.co m * Sets the supplied value of the supplied field on the supplied object. * * @param field of the object to set * @param object that has the field * @param value to set * * @throws IllegalArgumentException if the field cannot be set */ public static void setField(final Field field, final Object object, final Object value) { try { field.set(object, value); } catch (IllegalAccessException e) { throw new IllegalArgumentException(e); } } }