- /**
- * Sets the value of the named field. If fieldName denotes a static field, provide a class, otherwise provide an instance. If the
- * fieldName denotes a final field, this method could fail with an IllegalAccessException, since setting the value of final fields
- * at other times than instantiation can have unpredictable effects.<br/>
- * <br/>
- * Example:<br/>
- * <br/>
- * <code>
- * String myString = "Test"; <br/>
- * <br/>
- * //setting the private field value<br/>
- * PrivilegedAccessor.setValue(myString, "value", new char[] {'T', 'e', 's', 't'});<br/>
- * <br/>
- * //setting the static final field serialVersionUID - MIGHT FAIL<br/>
- * PrivilegedAccessor.setValue(myString.getClass(), "serialVersionUID", 1);<br/>
- * <br/>
- * </code>
- *
- * @param instanceOrClass the instance or class to set the field
- * @param fieldName the name of the field
- * @param value the new value of the field
- * @throws IllegalArgumentException if the value could not be set. This could be the case if no field with the given
- * <code>fieldName</code> can be found; or if the field was final
- *
- * @see PrivilegedAccessor.setValue(Object,String,Object)
- */
- public static PA setValue(final Object instanceOrClass, final String fieldName, final Object value) {
- try {
- PrivilegedAccessor.setValue(instanceOrClass, fieldName, value);
- } catch (Exception e) {
- throw new IllegalArgumentException("Can't set value " + value + " at " + fieldName + " in " + instanceOrClass, e);
- }
- return new PA(instanceOrClass);
- }
+ /**
+ * Sets the value of the named field. If fieldName denotes a static field,
+ * provide a class, otherwise provide an instance. If the fieldName denotes a
+ * final field, this method could fail with an IllegalAccessException, since
+ * setting the value of final fields at other times than instantiation can
+ * have unpredictable effects.<br/>
+ * <br/>
+ * Example:<br/>
+ * <br/>
+ * <code>
+ * String myString = "Test"; <br/>
+ * <br/>
+ * //setting the private field value<br/>
+ * PrivilegedAccessor.setValue(myString, "value", new char[] {'T', 'e', 's', 't'});<br/>
+ * <br/>
+ * //setting the static final field serialVersionUID - MIGHT FAIL<br/>
+ * PrivilegedAccessor.setValue(myString.getClass(), "serialVersionUID", 1);<br/>
+ * <br/>
+ * </code>
+ *
+ * @param instanceOrClass
+ * the instance or class to set the field
+ * @param fieldName
+ * the name of the field
+ * @param value
+ * the new value of the field
+ * @throws IllegalArgumentException
+ * if the value could not be set. This could be the case if no field
+ * with the given <code>fieldName</code> can be found; or if the
+ * field was final
+ *
+ * @see PrivilegedAccessor.setValue(Object,String,Object)
+ */
+ public static PA setValue(final Object instanceOrClass,
+ final String fieldName, final Object value)
+ {
+ try
+ {
+ PrivilegedAccessor.setValue(instanceOrClass, fieldName, value);
+ } catch (Exception e)
+ {
+ throw new IllegalArgumentException("Can't set value " + value + " at "
+ + fieldName + " in " + instanceOrClass, e);
+ }
+ return new PA(instanceOrClass);
+ }