Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
 package bpiwowar.argparser.handlers;
 
Utility methods for fields

Author(s):
Benjamin Piwowarski
 
public class Fields {
    
Sets a field, even if not accessible

Parameters:
object The object
f The field
value The value to set
Throws:
java.lang.IllegalAccessException If something goes wrong
    public static void set(Object objectField fObject valuethrows IllegalAccessException {
        boolean accessible = f.isAccessible();
        if (!accessiblef.setAccessible(true);
        f.set(objectvalue);
        if (!accessiblef.setAccessible(false);
    }
New to GrepCode? Check out our FAQ X