RFR (XS): 8148044: Remove Enum[0] constants from EnumSet and EnumMap

Claes Redestad claes.redestad at oracle.com
Fri Jan 22 12:07:29 UTC 2016

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 
> investigate.

Right...  java/util/EnumSet/BogusEnumSet.java fails, which is an 
explicit test to verify a corrupt EnumSet doesn't deserialize properly:

java.io.InvalidClassException: java.util.EnumSet; local class incompatible: stream classdesc serialVersionUID = 1009687484059888093, local class serialVersionUID = 4168005130090799668
	at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:618)
	at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1626)
	at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1521)
	at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1626)
	at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1521)
	at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1777)
	at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1354)
	at java.io.ObjectInputStream.readObject(ObjectInputStream.java:368)
	at BogusEnumSet.deserialize(BogusEnumSet.java:91)
	at BogusEnumSet.main(BogusEnumSet.java:78)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:520)
	at com.sun.javatest.regtest.agent.MainActionHelper$SameVMRunnable.run(MainActionHelper.java:218)
	at java.lang.Thread.run(Thread.java:804)

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 



More information about the core-libs-dev mailing list