-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Description
From limpbizkit on September 11, 2008 02:41:36
Setting final fields directly using reflection has unpredictable results and shouldn't be supported.
From the Field.set() Javadoc:
If the underlying field is final, the method throws an IllegalAccessException unless
setAccessible(true) has succeeded for this field and this field is non-static. Setting a final field in
this way is meaningful only during deserialization or reconstruction of instances of classes with
blank final fields, before they are made available for access by other parts of a program. Use in any
other context may have unpredictable effects, including cases in which other parts of a program
continue to use the original value of this field.
I believe we still need setAccessible(true) so we can update modify private non-final fields.
Original issue: http://code.google.com/p/google-guice/issues/detail?id=245