Java Reflection Field Set setField(Field field, Object objToSet, Object value)

Here you can find the source of setField(Field field, Object objToSet, Object value)

Description

set Field

License

Open Source License

Declaration

public static void setField(Field field, Object objToSet, 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 setField(Field field, Object objToSet, Object value) {
        field.setAccessible(true);//from w  ww  . j  av a  2  s.c om
        try {
            field.set(objToSet, value);
        } catch (IllegalArgumentException | IllegalAccessException e) {
            throw new RuntimeException(e);
        }
    }
}

Related

  1. setField(Field f, Object this_, Object value)
  2. setField(Field field, @Nullable Object instance, Object thing)
  3. setField(Field field, Object classWithField, Object value)
  4. setField(Field field, Object instance, Object value)
  5. setField(Field field, Object obj, String value)
  6. setField(Field field, Object target, Object value)
  7. setField(Field field, Object target, Object value)
  8. setField(Field field, Object target, Object value)
  9. setField(Field field, Object target, Object value)