2006/12/5, Tony Wu <[EMAIL PROTECTED]>:
And AFAIK, the value is generated according to the field of the class.
So is it correct that the generated SID will be 1L if no field
present?
No - the value is a hash calculated on a sequence of complete class
name, descriptors of it's fields, etc; you may find comprehensive
description in the setialization framework specification.
So suid == 1L is basically a bogus and indeed may hint it is a no-op default.
But still it needs to be commented just for certainty. OTOH
@SupressWarnings("serial") is self-documenting.
--
Alexey
On 12/5/06, Nathan Beyer <[EMAIL PROTECTED]> wrote:
> That's not a magic value. A serial version UID of 1 is considered, by
> some, a default value. I know that within a Eclipse, you can either
> generate a value (ala serialver tool) or insert the default value
> (1L).
>
> The serial version UID is an arbitrary value that's meant to be a
> marker for a given class if two serialized objects are compatible.
> Using small iterative values (1, 2, etc) is really no different than
> using a complex weighted calculation that changes when the class
> changes. As long as the number changes or doesn't change for a given
> class, then the compatability or incompatibility, respectively, is
> deterministic.
>
> -Nathan
>
> On 12/4/06, Geir Magnusson Jr. <[EMAIL PROTECTED]> wrote:
> >
> >
> > Alexey Varlamov wrote:
> > > 2006/12/4, Tony Wu <[EMAIL PROTECTED]>:
> > >> This class will never be serialized. I think the meanless variable
> > >> here is created to avoid compiler warining.
> > >
> > > How about using @SupressWarnings("serial")? It is more readable IMO.
> >
> > Thank you. I didn't know what to suggest, but a magic value was
> > misleading w/o a comment...
> >
> > geir
> >
> > >
> > >>
> > >> On 12/1/06, Geir Magnusson Jr. <[EMAIL PROTECTED]> wrote:
> > >> >
> > >> >
> > >> > [EMAIL PROTECTED] wrote:
> > >> > > Author: liangyx
> > >> > > Date: Thu Nov 30 00:19:55 2006
> > >> > > New Revision: 480871
> > >> > >
> > >> > > URL: http://svn.apache.org/viewvc?view=rev&rev=480871
> > >> > > Log:
> > >> > > Apply patch for HARMONY-2356 ([classlib][luni]The Map from
> > >> System.getEnv should throw NullPointerException while get(null) and is
> > >> not modifiable.)
> > >> > >
> > >> > > Modified:
> > >> > >
> > >>
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/java/lang/ProcessBuilder.java
> > >>
> > >> > >
> > >>
harmony/enhanced/classlib/trunk/modules/luni/src/main/java/org/apache/harmony/luni/platform/Environment.java
> > >>
> > >> > >
> > >>
harmony/enhanced/classlib/trunk/modules/luni/src/test/java/org/apache/harmony/luni/tests/java/lang/SystemTest.java
> > >>
> > >> > >
> > >> >
> > >> > > +
> > >> > > + public static class EnvironmentMap extends HashMap<String,
> > >> String> {
> > >> > > +
> > >> > > + private static final long serialVersionUID = 1L;
> > >> > > +
> > >> > > + public EnvironmentMap() {
> > >> > > + super();
> > >> > > + }
> > >> > > +
> > >> > > + public EnvironmentMap(Map<String, String> map) {
> > >> > > + super(map);
> > >> > > + }
> > >> > > +
> > >> > > + public boolean containsKey(Object key) {
> > >> > > + checkParam(key);
> > >> > > + return super.containsKey(key);
> > >> > > + }
> > >> >
> > >> >
> > >> >
> > >> > I'm curious - why set the ServialVersionUID to 1?
> > >> >
> > >> > geir
> > >> >
> > >>
> > >>
> > >> --
> > >> Tony Wu
> > >> China Software Development Lab, IBM
> > >>
> >
>
--
Tony Wu
China Software Development Lab, IBM