RFR (XS): 8148044: Remove Enum constants from EnumSet and EnumMap
claes.redestad at oracle.com
Fri Jan 22 15:44:16 UTC 2016
On 2016-01-22 15:22, Chris Hegarty wrote:
> On 22/01/16 12:07, Claes Redestad wrote:
>> On 2016-01-22 12:56, Claes Redestad wrote:
>>> On 2016-01-22 12:53, Alan Bateman wrote:
>>>> On 22/01/2016 11:34, Claes Redestad wrote:
>>>>> During testing I discovered that EnumSet was missing a
>>>>> serialVersionUID, which needs to be added.
>>>> I assume this is not needed, it already has:
>>>> @SuppressWarnings("serial") // No serialVersionUID due to usage of
>>>> serial proxy pattern
>>> That's odd.. there's a jtreg test that fails if I don't explicitly add
>>> the serialVersionUID (that's where I got the actual UID from). I'll
>> Right... java/util/EnumSet/BogusEnumSet.java fails, which is an
>> explicit test to verify a corrupt EnumSet doesn't deserialize properly:
> Hmmm... this would indicate that the changes you have made has
> affected the serial version UID automatically generated. I'm not
> sure why removing a 'private static' field would do this. Is it
> possible that you ran into this during development, but it is
> not actually necessary with the final changes?
> This test is a little fragile, but should be ok.
>> It would seem the assessment that serialVersionUID is not needed when
>> using the serial proxy pattern might be misguided (or is this a bug in
> It is debate-able whether this is a test bug or not. But I think
> we should not change the serialVersionUID for this class, whether
> truly Serializable or not. Even though in practice it is not all
> that useful.
> Can you please revert the serialization parts of the change, and
> rerun the test? To see if still passes or fails.
I backed out the serial version UID change and reran the test, same thing.
I dug deeper, as this is a bit vexxing...
While a static field does not in and of itself cause the generated UID
the private ZERO_LENGTH_ENUM_ARRAY is being accessed from SerializationProxy
class, thus javac generates a package-private synthetic method
will be accounted for when generating serialVersionUID. That's unfortunate.
I ran a few experiments to confirm this:
- Adding a package-private static method to EnumSet makes the test fail
- Adding any static field and the test keep passing
So it seems our options here are limited.
More information about the core-libs-dev