ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 7901] New: - [SUBMIT] SerialVer tasks
Date Wed, 10 Apr 2002 00:34:57 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7901>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=7901

[SUBMIT] SerialVer tasks

           Summary: [SUBMIT] SerialVer tasks
           Product: Ant
           Version: 1.5 alpha (nightly)
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Optional Tasks
        AssignedTo: ant-dev@jakarta.apache.org
        ReportedBy: stchauvin@yahoo.com


According the “Developing JAVA Beans (O’Reilly)” book: 
http://safari.oreilly.com/main.asp?bookname=javabeans, I think it is useful to 
have a task that help us to insert the serialVersionUID in the source code.

Serialization of objects to persistent storage presents a potential problem 
with class version mismatches. This is because the class itself is not 
serialized with the object. Instead, an instance of java.io.ObjectStreamClass 
that describes the class of the object is serialized. The 
java.io.ObjectStreamClass contains the class name and a version identifier for 
the serialized object. This allows the local version of the class to evolve 
independently of the serialized data.

The compatible class modifications, such as to add a method, modify the 
signature of the class. If we try to read a serialized object with a class that 
changed like this, the JVM returns a java.io.InvalidClassException (Local class 
not compatible) exception. 

To tell to the JVM that nothing significant changed since the last compatible 
class, we have to mark the class with the same stream identification, named 
SUID. The JDK provides the serialver program that gives the SUID for all 
serializable class.

The static member variable called serialVersionUID can be included in the code 
of the new class version that implements a compatible modification. So, all 
objects serialized by the original class are compatible with the new class.

I propose a first ANT task that echoes this SUID, and a second that insert in 
the source code the serialVersionUID declaration. When the developer wants to 
break the compatibility, he can insert in the code a special tag that will be 
replaced by the SUID. All next compatible compilations will integrate this 
value.

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message