[xwiki-devs] serialVersionUID (was Re: [xwiki-notifications] r21863 - platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/xwiki/plugin/wikimanager)
On Jul 9, 2009, at 12:15 PM, tmortagne (SVN) wrote:
Author: tmortagne Date: 2009-07-09 12:15:53 +0200 (Thu, 09 Jul 2009) New Revision: 21863
Modified: platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/ xwiki/plugin/wikimanager/WikiManagerException.java Log: [misc] Add serialize id
Modified: platform/xwiki-plugins/trunk/wiki-manager/src/main/java/ com/xpn/xwiki/plugin/wikimanager/WikiManagerException.java =================================================================== --- platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/ xwiki/plugin/wikimanager/WikiManagerException.java 2009-07-09 09:56:02 UTC (rev 21862) +++ platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/ xwiki/plugin/wikimanager/WikiManagerException.java 2009-07-09 10:15:53 UTC (rev 21863) @@ -30,11 +30,6 @@ public class WikiManagerException extends PluginException { /** - * Serialize id. - */ - private static final long serialVersionUID = -6451750749104331619L; - - /** * Error when trying to use provided user that does not exists. * <p> * TODO : move in XWikiException @@ -98,6 +93,11 @@ // //////
/** + * Serialize id. + */ + private static final long serialVersionUID = -6451750749104331619L; +
I've asked myself several times how to document this. I've used different versions: - "Unique ID for Class Serialization." - "Class id for Serialization." and the more descriptive: /** * Needed to identify the version of this code when serializing/ deserializing (since Exception is Serializable). * Note that the value needs to be modified whenever a non transient field is added or removed in this class. */ The last one is the one I prefer (I think) since not everyone knows about this and it makes it clear that the id needs to be modified whenever a new field is added/removed. We could also add a link to some URL describing class serialization. WDYT? Thanks -Vincent
On Fri, Jul 10, 2009 at 21:51, Vincent Massol<vincent@massol.net> wrote:
On Jul 9, 2009, at 12:15 PM, tmortagne (SVN) wrote:
Author: tmortagne Date: 2009-07-09 12:15:53 +0200 (Thu, 09 Jul 2009) New Revision: 21863
Modified: platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/ xwiki/plugin/wikimanager/WikiManagerException.java Log: [misc] Add serialize id
Modified: platform/xwiki-plugins/trunk/wiki-manager/src/main/java/ com/xpn/xwiki/plugin/wikimanager/WikiManagerException.java =================================================================== --- platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/ xwiki/plugin/wikimanager/WikiManagerException.java 2009-07-09 09:56:02 UTC (rev 21862) +++ platform/xwiki-plugins/trunk/wiki-manager/src/main/java/com/xpn/ xwiki/plugin/wikimanager/WikiManagerException.java 2009-07-09 10:15:53 UTC (rev 21863) @@ -30,11 +30,6 @@ public class WikiManagerException extends PluginException { /** - * Serialize id. - */ - private static final long serialVersionUID = -6451750749104331619L; - - /** * Error when trying to use provided user that does not exists. * <p> * TODO : move in XWikiException @@ -98,6 +93,11 @@ // //////
/** + * Serialize id. + */ + private static final long serialVersionUID = -6451750749104331619L; +
I've asked myself several times how to document this. I've used different versions:
- "Unique ID for Class Serialization." - "Class id for Serialization."
and the more descriptive:
/** * Needed to identify the version of this code when serializing/ deserializing (since Exception is Serializable). * Note that the value needs to be modified whenever a non transient field is added or removed in this class. */
The last one is the one I prefer (I think) since not everyone knows about this and it makes it clear that the id needs to be modified whenever a new field is added/removed.
We could also add a link to some URL describing class serialization.
WDYT?
I added this to get rid of warning but i did not tought much about it (I doubt this class would ever be used serialized anytime). Your last descriptive comment is the best I think (we should put this in http://dev.xwiki.org/xwiki/bin/view/Community/CodeStyle).
Thanks -Vincent _______________________________________________ devs mailing list devs@xwiki.org http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
participants (2)
-
Thomas Mortagne -
Vincent Massol