JDK 8 code review request for 6226715: (ann) java.lang.annotation.AnnotationTypeMismatchException could not be serialized
Joe Darcy
joe.darcy at oracle.com
Thu Jun 16 15:17:13 UTC 2011
Rémi Forax wrote:
> Le 16/06/2011 02:35, Joe Darcy a écrit :
>> Hello.
>>
>> Please review my JDK 8 fix for
>>
>> 6226715: (ann)
>> java.lang.annotation.AnnotationTypeMismatchException could not be
>> serialized
>> http://cr.openjdk.java.net/~darcy/6226715.0/
>>
>> This fix includes the unusual step of marking a non-transient field
>> transient in a serialiable class, but the class can't meaningfully be
>> serialized today anyway so this change should have no adverse effect
>> in practice.
>>
>> For good code hygiene, the new readObject method explicitly sets the
>> now transient field in question.
>
> Not sure it's good to drop 'final' just for code hygiene.
> A code that relies on the fact that this exception is non-mutable can
> now fail.
There is no setter for the field other than through the constructor (and
now readObject).
I don't really want to dip into sun.misc.Unsafe to set a final transient
field in the readObject method.
-Joe
More information about the core-libs-dev
mailing list