On 18/10/2011 11:15, Steve Poole wrote:
On Tue, 2011-10-18 at 15:53 +0800, Sean Chou wrote:

Hi Sean,   I wonder if the inclusion of AIX in the enum is at the wrong
point?    You've added it before UNKNOWN which makes logical sense - but
you have changed UNKNOWN's ordinal value so if the enum is
serialised/deserialised  then you could in theory break  something
relying on UNKNOWN being the 4th entry

Its a small point and unlikely to happen I expect but I thought I'd
point it out.

It does change the ordinal but it's not a technically binary compatibility change as defined by the JLS (3rd Ed. 13.4.26). The behavioural change by insertion is less significant as the results from compareTo select the same sort order.

http://java.sun.com/docs/books/jls/third_edition/html/binaryComp.html#13.4.26

"13.4.26 Evolution of Enums

"Adding or reordering constants from an enum type will not break compatibility with pre-existing binaries. If a precompiled binary attempts to access an enum constant that no longer exists, the client will fail at runtime with a NoSuchFieldError. Therefore such a change is not recommended for widely distributed enums.

"In all other respects, the binary compatibility rules for enums are identical to those for classes."


Java Serialisation serialises enums by name rather than just ordinal.

Tom

Reply via email to