JDK-6338881 : Javadoc should provide a way to include a non-constant serialVersionUID in the Serialized Form page
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javadoc(tool)
  • Affected Version: 6
  • Priority: P3
  • Status: Closed
  • Resolution: Won't Fix
  • OS: generic
  • CPU: generic
  • Submitted: 2005-10-19
  • Updated: 2014-05-05
  • Resolved: 2006-07-27
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Description
The Javadoc tool outputs a page entitled Serialized Form that summarizes the serial form of all serializable classes in the output.  This is vital for independent implementations of an API, which need to ensure serial compatibility with the reference implementation and each other.

A key part of the serial form is the serialVersionUID value.  However, this value is only included in the output when it is a compile-time constant.

In the JMX API we have a certain number of classes that have two serial forms depending on whether a certain system property is set for compatibility with very old versions.  This means that the serialVersionUID is not a compile-time constant but is evaluated at runtime to a value that depends on whether this system property is set.  Therefore it does not appear in the Javadoc.

Nevertheless independent implementors need to know the serialVersionUID for these classes.  They are only interested in the standard value, not the compatibility value.  We are looking for a way to include this value in the Serialized Form page.  We do not expect the Javadoc tool to be able to figure this value out itself, the way it does when serialVersionUID is a compile-time constant.  We do not mind having to put an explicit doc comment somewhere, something like this:

/**
 * <p>This class blah blah blah...
 * @serial The {@code serialVersionUID} of this class is 123456789123456789L.
 */
public class ObjectName {...}

However there is no obvious way to do this consistently and we are afraid we will end up having to hack this information arbitrarily into tags spliced into writeObject methods and the like.

Comments
WORK AROUND Currently if you need to know the serialVersionUID from the Reference Implementation, you have to fire up serialver against the classes of that implementation.
19-10-2005