At CXF, we have maven scripting to automatically set up all the eclipse preferences, and that turns out to include spiking this warning. I suppose I could set up a patch ... However, it involves setting up a more complex maven project structure that I'm not sure is desired here.
I wrote up a blog on it once: http://dssheep.blogspot.com/2008/12/maven-eclipse-checkstyle-pmd-oy-vey.html On Wed, Jun 17, 2009 at 12:02 PM, Jeff Eastman<[email protected]> wrote: > Thanks Sean I do recall that thread now. I've turned off the warning in > Eclipse (Preferences/Java/Compiler/Errors-Warnings). Kind of moot on an > exception with no state anyway. > > Jeff > > > Sean Owen wrote: >> >> Yeah, Benson noted the same about Eclipse -- we had a thread about >> this a couple weeks ago. I personally think setting serialVersionUID >> is a bad idea, and at least, is exceptional behavior. Unfortunately, >> Eclipse defaults to warning about this. >> >> The logic is this: when the JVM deserializes an object it needs to >> check for compatibility between the serialized representation and its >> current version of the class. It does so once, based on the >> non-transient instance fields in the class. If it finds what it thinks >> is a mismatch, it will throw an exception. >> >> That is, by default, the deserialization is conservative: it will >> never allow deserialization where an incompatibility exists, but will >> sometimes disallow a serialization where, actually, there isn't a >> compatibility problem. >> >> That is, maybe you added a new instance field, but, you still think >> it's valid to deserialize old versions of the object without that >> field (maybe you are fine with leaving the new instance field as >> null). To overcome this, you can keep track of what's compatible >> yourself by setting serialVersionUID. As long as the old/new IDs >> match, Java will try to proceed with the deserialization. >> >> There is a use case for this, but, it's quite rare. If you never use >> incompatbile versions of your classes in one context, it's not an >> issue -- and indeed, that's not exactly a great idea. There is no >> performance implication. >> >> The problem is, by setting this field, you're leaving yourself quite >> open to the opposite problem: adding a change that really isn't >> backwards-compatible, and forgetting to update the ID. This is a big >> issue. >> >> >> Hence, I think it is almost never right to set serialVersionUID, and >> certainly not a default. What do you all think of the logic? I think >> Benson was on board with it. Now as to how to shut up Eclipse... >> >> >> >> >> On Wed, Jun 17, 2009 at 4:20 PM, Jeff Eastman<[email protected]> >> wrote: >> >>> >>> Hi Sean, >>> >>> What's the logic for removing these? They now give me a warning in >>> Eclipse. >>> I'm willing to turn that off but I'd like to understand why. >>> >>> Jeff >>> >>> >>> [email protected] wrote: >>> >>>> >>>> Author: srowen >>>> Date: Wed Jun 17 10:25:43 2009 >>>> New Revision: 785542 >>>> >>>> URL: http://svn.apache.org/viewvc?rev=785542&view=rev >>>> Log: >>>> Remove serialVersionUID per our standards (right?) >>>> >>>> Modified: >>>> >>>> >>>> lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/CardinalityException.java >>>> >>>> >>>> lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/IndexException.java >>>> >>>> >>>> lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/UnboundLabelException.java >>>> >>>> Modified: >>>> >>>> lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/CardinalityException.java >>>> URL: >>>> >>>> http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/CardinalityException.java?rev=785542&r1=785541&r2=785542&view=diff >>>> >>>> >>>> ============================================================================== >>>> --- >>>> >>>> lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/CardinalityException.java >>>> (original) >>>> +++ >>>> >>>> lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/CardinalityException.java >>>> Wed Jun 17 10:25:43 2009 >>>> @@ -22,9 +22,4 @@ >>>> */ >>>> public class CardinalityException extends RuntimeException { >>>> - /** >>>> - * - */ >>>> - private static final long serialVersionUID = 1L; >>>> - >>>> } >>>> >>>> Modified: >>>> >>>> lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/IndexException.java >>>> URL: >>>> >>>> http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/IndexException.java?rev=785542&r1=785541&r2=785542&view=diff >>>> >>>> >>>> ============================================================================== >>>> --- >>>> >>>> lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/IndexException.java >>>> (original) >>>> +++ >>>> >>>> lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/IndexException.java >>>> Wed Jun 17 10:25:43 2009 >>>> @@ -22,9 +22,4 @@ >>>> */ >>>> public class IndexException extends RuntimeException { >>>> - /** >>>> - * - */ >>>> - private static final long serialVersionUID = 1L; >>>> - >>>> } >>>> >>>> Modified: >>>> >>>> lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/UnboundLabelException.java >>>> URL: >>>> >>>> http://svn.apache.org/viewvc/lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/UnboundLabelException.java?rev=785542&r1=785541&r2=785542&view=diff >>>> >>>> >>>> ============================================================================== >>>> --- >>>> >>>> lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/UnboundLabelException.java >>>> (original) >>>> +++ >>>> >>>> lucene/mahout/trunk/core/src/main/java/org/apache/mahout/matrix/UnboundLabelException.java >>>> Wed Jun 17 10:25:43 2009 >>>> @@ -22,9 +22,4 @@ >>>> */ >>>> public class UnboundLabelException extends RuntimeException { >>>> - /** >>>> - * - */ >>>> - private static final long serialVersionUID = 1L; >>>> - >>>> } >>>> >>>> >>>> >>>> >>>> >>>> >>> >>> >> >> >> > >
