Java Reflection Field Value Set setFieldValue(Object obj, Field field, Object value)

Here you can find the source of setFieldValue(Object obj, Field field, Object value)

Description

set Field Value

License

Open Source License

Declaration

public static void setFieldValue(Object obj, Field field, Object value) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.lang.reflect.Field;

public class Main {
    public static void setFieldValue(Object obj, Field field, Object value) {
        field.setAccessible(true);/*  w w  w .  j  a va  2  s  .  com*/
        try {
            field.set(obj, value);
        } catch (IllegalArgumentException e) {
            throw new RuntimeException("IllegalArgumentException", e);
        } catch (IllegalAccessException e) {
            throw new RuntimeException("IllegalAccessExceptione", e);
        }
    }
}

Related

  1. setFieldValue(Object instanceContainingField, String fieldName, Object fieldValue)
  2. setFieldValue(Object o, Class baseClass, Class fieldType, T value)
  3. SetFieldValue(Object o, String field, Object object)
  4. setFieldValue(Object obj, Field f, Object value)
  5. setFieldValue(Object obj, Field field, Object value)
  6. setFieldValue(Object obj, String field, Object value)
  7. setFieldValue(Object obj, String fieldName, Object value)
  8. setFieldValue(Object obj, String fieldname, Object value)
  9. setFieldValue(Object obj, String fieldName, Object value)