<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Reason to serialVersionUID your serializable classes</title>
	<atom:link href="http://ahtik.com/blog/2006/08/23/reason-to-serialversionuid-your-serializable-classes/feed/" rel="self" type="application/rss+xml" />
	<link>http://ahtik.com/blog/2006/08/23/reason-to-serialversionuid-your-serializable-classes/</link>
	<description>Beyond Being Backwards-Compatible</description>
	<lastBuildDate>Fri, 20 Aug 2010 06:54:11 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: Ahti</title>
		<link>http://ahtik.com/blog/2006/08/23/reason-to-serialversionuid-your-serializable-classes/comment-page-1/#comment-66</link>
		<dc:creator>Ahti</dc:creator>
		<pubDate>Wed, 03 Dec 2008 18:39:31 +0000</pubDate>
		<guid isPermaLink="false">http://ahtik.com/blog/2006/08/23/reason-to-serialversionuid-your-serializable-classes/#comment-66</guid>
		<description>hmm, this is an idea.. thanks, David!</description>
		<content:encoded><![CDATA[<p>hmm, this is an idea.. thanks, David!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David Wright</title>
		<link>http://ahtik.com/blog/2006/08/23/reason-to-serialversionuid-your-serializable-classes/comment-page-1/#comment-67</link>
		<dc:creator>David Wright</dc:creator>
		<pubDate>Wed, 03 Dec 2008 15:16:56 +0000</pubDate>
		<guid isPermaLink="false">http://ahtik.com/blog/2006/08/23/reason-to-serialversionuid-your-serializable-classes/#comment-67</guid>
		<description>Here is an idea for detecting this through an unit test. I haven&#039;t worked out the details of calling serialver from within the unit test, though.

&lt;code&gt;
private void assertSuidUpToDate(Class clazz) {
	long actualSUID;
	try {
		Field field = clazz.getDeclaredField(&quot;serialVersionUID&quot;);
		field.setAccessible(true);
		actualSUID = (Long) field.get(null);
	} catch (NoSuchFieldException e) {
		throw new AssertionError(clazz.getName() + &quot; does not have a serialVersionUID field&quot;);
	} catch (IllegalAccessException e) {
		throw new AssertionError(&quot;Got an IllegalAccessException trying to read the serialVersionUID field from class &quot; + clazz.getName());
	}

	// TODO Call serialver command line utility
	long generatedSUID = 0;

	Assert.assertEquals(generatedSUID, actualSUID);
}
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Here is an idea for detecting this through an unit test. I haven&#8217;t worked out the details of calling serialver from within the unit test, though.</p>
<p><code><br />
private void assertSuidUpToDate(Class clazz) {<br />
	long actualSUID;<br />
	try {<br />
		Field field = clazz.getDeclaredField("serialVersionUID");<br />
		field.setAccessible(true);<br />
		actualSUID = (Long) field.get(null);<br />
	} catch (NoSuchFieldException e) {<br />
		throw new AssertionError(clazz.getName() + " does not have a serialVersionUID field");<br />
	} catch (IllegalAccessException e) {<br />
		throw new AssertionError("Got an IllegalAccessException trying to read the serialVersionUID field from class " + clazz.getName());<br />
	}</p>
<p>	// TODO Call serialver command line utility<br />
	long generatedSUID = 0;</p>
<p>	Assert.assertEquals(generatedSUID, actualSUID);<br />
}<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ahti.kitsik</title>
		<link>http://ahtik.com/blog/2006/08/23/reason-to-serialversionuid-your-serializable-classes/comment-page-1/#comment-65</link>
		<dc:creator>ahti.kitsik</dc:creator>
		<pubDate>Fri, 25 Aug 2006 08:50:45 +0000</pubDate>
		<guid isPermaLink="false">http://ahtik.com/blog/2006/08/23/reason-to-serialversionuid-your-serializable-classes/#comment-65</guid>
		<description>Yes, you are totally right.
So my idea would become to detect if a change in class structure would break serialization that was specified by the generated serialVersionUID.
For example changing a field to static would break serialized object but adding a new field does no harm.

For the reference &quot;Type Changes Affecting Serialization&quot;:
http://java.sun.com/j2se/1.5.0/docs/guide/serialization/spec/version.html#6678

Not sure how this could be done or how useful this might be :)</description>
		<content:encoded><![CDATA[<p>Yes, you are totally right.<br />
So my idea would become to detect if a change in class structure would break serialization that was specified by the generated serialVersionUID.<br />
For example changing a field to static would break serialized object but adding a new field does no harm.</p>
<p>For the reference &#8220;Type Changes Affecting Serialization&#8221;:<br />
<a href="http://java.sun.com/j2se/1.5.0/docs/guide/serialization/spec/version.html#6678" rel="nofollow">http://java.sun.com/j2se/1.5.0/docs/guide/serialization/spec/version.html#6678</a></p>
<p>Not sure how this could be done or how useful this might be <img src='http://ahtik.com/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: risto</title>
		<link>http://ahtik.com/blog/2006/08/23/reason-to-serialversionuid-your-serializable-classes/comment-page-1/#comment-64</link>
		<dc:creator>risto</dc:creator>
		<pubDate>Thu, 24 Aug 2006 14:48:22 +0000</pubDate>
		<guid isPermaLink="false">http://ahtik.com/blog/2006/08/23/reason-to-serialversionuid-your-serializable-classes/#comment-64</guid>
		<description>Good to know.

However, I was thinking about this question: &quot;can there be an audit to automatically detect source files where you explicitly defined serialVersionUID that is out of date?&quot;. I&#039;m not sure if this would be useful, because I think it is the only point of serialVersionUID that it can get &quot;out of date&quot; with class, and yet the number would stay the same, thus allowing serialization anyway.

For one example, what if you create a serialVersionUID with another compiler, and then you open up the code in Eclipse and Eclipse finds that the serialVersionUID is wrong; if you &quot;fix&quot; it to the linking of Eclipse&#039;s compiler, you break serialization compatibility (unless you always tend to run binaries that have been compiled with Eclipse).

That said, I can imagine other cases where it could be useful to check if serialVersionUID is out of date -- for example, if you really want to know whether you have changed the signature since you create that number.</description>
		<content:encoded><![CDATA[<p>Good to know.</p>
<p>However, I was thinking about this question: &#8220;can there be an audit to automatically detect source files where you explicitly defined serialVersionUID that is out of date?&#8221;. I&#8217;m not sure if this would be useful, because I think it is the only point of serialVersionUID that it can get &#8220;out of date&#8221; with class, and yet the number would stay the same, thus allowing serialization anyway.</p>
<p>For one example, what if you create a serialVersionUID with another compiler, and then you open up the code in Eclipse and Eclipse finds that the serialVersionUID is wrong; if you &#8220;fix&#8221; it to the linking of Eclipse&#8217;s compiler, you break serialization compatibility (unless you always tend to run binaries that have been compiled with Eclipse).</p>
<p>That said, I can imagine other cases where it could be useful to check if serialVersionUID is out of date &#8212; for example, if you really want to know whether you have changed the signature since you create that number.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
