Bug 54843 - java.io.InvalidClassException: org.apache.tools.ant.Location
Summary: java.io.InvalidClassException: org.apache.tools.ant.Location
Status: RESOLVED WONTFIX
Alias: None
Product: Ant
Classification: Unclassified
Component: Core (show other bugs)
Version: 1.9.1
Hardware: All All
: P2 trivial (vote)
Target Milestone: ---
Assignee: Ant Notifications List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-04-13 23:19 UTC by Christian Schulte
Modified: 2013-12-31 14:57 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Schulte 2013-04-13 23:19:41 UTC
Upgrading from 1.8.4 to 1.9.0, I am getting:

java.io.InvalidClassException: org.apache.tools.ant.Location; local class incompatible: stream classdesc serialVersionUID = -2242957035428169563, local class serialVersionUID = 1
        at java.io.ObjectStreamClass.initNonProxy(ObjectStreamClass.java:604)
        at java.io.ObjectInputStream.readNonProxyDesc(ObjectInputStream.java:1601)
        at java.io.ObjectInputStream.readClassDesc(ObjectInputStream.java:1514)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1750)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
        at java.io.ObjectInputStream.defaultReadFields(ObjectInputStream.java:1970)
        at java.io.ObjectInputStream.readSerialData(ObjectInputStream.java:1894)
        at java.io.ObjectInputStream.readOrdinaryObject(ObjectInputStream.java:1777)
        at java.io.ObjectInputStream.readObject0(ObjectInputStream.java:1347)
        at java.io.ObjectInputStream.readObject(ObjectInputStream.java:369)

during deserialization of custom exception classes extending 'org.apache.tools.ant.BuildException'.

This is happening due to the addition of 

private static final long serialVersionUID = 1L;

to class org.apache.tools.ant.Location.

The serial version UID of that class should be corrected.
Comment 1 Antoine Levy-Lambert 2013-04-28 20:52:37 UTC
The private static final long  serialVersionUID = 1L was added between Ant 1.8.4 and Ant 1.9.0 in Revision 1375137 as part of a series of Java 5 updates.

It looks like this is a change which has broken some degree of compatibility between Ant 1.8.4 and Ant 1.9.0 but this is a one time change.

This change should have been documented in WHATSNEW and ReleaseNotes as a change that could break older environment.

I will revert to the dev at ant.apache.org list to see whether we should close this bug report as WONTFIX - my personal inclination.
Comment 2 Antoine Levy-Lambert 2013-05-03 02:24:34 UTC
Quoting Conor MacNeill

>Yes, I think WONTFIX is the correct approach.

>I don't think we want to give any guarantees about compatibility of
>object serializations across Ant versions. I think object
>serialization is not really intended for long term object storage,
>more just for object transmission.

>Do we know why Ant objects are being serialized at all?

Closing as WONTFIX.
Comment 3 Christian Schulte 2013-05-08 09:24:27 UTC
> but this is a one time change.

It is a bug. There is no reason to use 1L as the serial version UID instead of the implicit serial version UID corresponding to this class for years.

Seems like someone got rid of some warning about a missing serial version UID without understanding what that warning is about.
Comment 4 Antoine Levy-Lambert 2013-05-08 09:51:20 UTC
Can you bring up this discussion to the Ant developer's list.
I would be afraid of hurting people who are using Ant 1.9.0 by removing this serial version uid.
Comment 5 Stefan Bodewig 2013-12-31 14:57:47 UTC
I'm afraid it is too late to go back now after we had four (point-)releases using 1 as serialVersionUid - if we restore compatibility with 1.8.4 we break compatibility with 1.9.[0-3].