Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » AspectJ » don't understand serialVersionUID related warning
don't understand serialVersionUID related warning [message #54679] Sat, 09 July 2005 17:11 Go to next message
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
Hi, I am using an aspect to make a class implement an additional
interface i.e.

public aspect XYZ {
declare parent: <foo> implements <bar>.
(... adding the additionally required methods here...)
}

Compiling my project I am getting the following warning:

Severity Description Resource In Folder Location Creation Time
1 serialVersionUID of type <foo> needs to be set because of added
interface <bar> [Xlint:needsSerialVersionUIDField] XYZ.aj <package-here>
line 13 July 9, 2005 6:51:51 PM

I have troubles understanding this warning: what exactly does that mean
and what am I supposed to do or fix here?

I already tried the following:

1.) I tried to define a new, different serialVersionUID, i..e. I added:
...
private static final long <foo>.serialVersionUID = ... ;

...
to the aspect, but apparently static inter-type fields are not supported
(why?).


2.) I tried adding a non-static field, i.e.:
...
private final long <foo>.serialVersionUID = ... ;
...
but then the warning re-appeared (and IMHO this wouldn't satisfy the
serializiation requirement anyway).


3.) I also tried the above two without the <foo>-prefix (i.e. making the
serialVersionUID a member of the aspect rather than of the advised
class):

private static final long serialVersionUID = ... ;
and
private final long serialVersionUID = ... ;

But in both cases the warning remained (which also seems to make sense
to me, because in my understanding the aspect here is like an additional
superclass of the class <foo> and thus the already existing
<foo>.serialVersionUID in the normal class <foo> would override the
field I define here).

But thus my puzzled question: what am I supposed to do here or how can I
fix this and get rid of the warning?

Michael
Re: don't understand serialVersionUID related warning [message #54711 is a reply to message #54679] Sun, 10 July 2005 19:15 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: newsserver_mails.bodden.de

Hi.

On Sat, 9 Jul 2005 19:11:30 +0200, Michael Moser wrote:

> Hi, I am using an aspect to make a class implement an additional
> interface i.e.
>
> public aspect XYZ {
> declare parent: <foo> implements <bar>.
> (... adding the additionally required methods here...)
> }
>
> Compiling my project I am getting the following warning:
>
> Severity Description Resource In Folder Location Creation Time
> 1 serialVersionUID of type <foo> needs to be set because of added
> interface <bar> [Xlint:needsSerialVersionUIDField] XYZ.aj <package-here>
> line 13 July 9, 2005 6:51:51 PM
>
> I have troubles understanding this warning: what exactly does that mean
> and what am I supposed to do or fix here?

For each class, if no explicit SUID is given, it is calculated
automatically from the members. You add members via your aspect. This
changes the SUID of <foo>, which the "base concern" might not be aware of.
You might have serialized versions of <foo> stored somewhere, which cannot
be loaded any more, when adding a member.

Setting the SUID explicitly tells Java, that the new and old versions *are*
compatible. New members are initializes to 0/null as you go.

> I already tried the following:
>
> 1.) I tried to define a new, different serialVersionUID, i..e. I added:
> ...
> private static final long <foo>.serialVersionUID = ... ;
>
> ...
> to the aspect, but apparently static inter-type fields are not supported
> (why?).

This cannot work, since actually there are no final static fields. They are
always inlined by the compiler.

> 2.) I tried adding a non-static field, i.e.:
> ...
> private final long <foo>.serialVersionUID = ... ;
> ...
> but then the warning re-appeared (and IMHO this wouldn't satisfy the
> serializiation requirement anyway).

This is wrong, since it is not static.

> 3.) I also tried the above two without the <foo>-prefix (i.e. making the
> serialVersionUID a member of the aspect rather than of the advised
> class):
>
> private static final long serialVersionUID = ... ;
> and
> private final long serialVersionUID = ... ;
>

You *must* declare the SUID in the class <foo> itself! There's no other
way. Or simply ignore/suppress the warning. (see @SuppressWarnings)

Eric

--
Eric Bodden, ICQ: 12656220, http://www.bodden.de, PGP: BB465582
There’s no obfuscated Perl contest because it’s pointless.
- Jeff Polk
Think I now understand serialVersionUID related warning - but another question popped up [message #54735 is a reply to message #54711] Sun, 10 July 2005 21:49 Go to previous messageGo to next message
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
Hi Eric,

"Eric Bodden" <newsserver_mails@bodden.de> wrote in message
news:g4j0a8cm4diz.2p69esk1moye.dlg@40tude.net...
> ...
> On Sat, 9 Jul 2005 19:11:30 +0200, Michael Moser wrote:
>
>> ...
>> public aspect XYZ {
>> declare parent: <foo> implements <bar>.
>> (... adding the additionally required methods here...)
>> }
>> ...
> ...
>
> You *must* declare the SUID in the class <foo> itself! There's no
> other
> way. Or simply ignore/suppress the warning. (see @SuppressWarnings)

OK - I think I now understood the issue here. In the general case this
represents indeed an issue and hence the warning is perfectly valid!

In my case I have a problem implementing your suggestion, because <foo>
is actually an interface that I am extending, so I can't really define
an SUID here - can I? But then I went and made all of the fields of the
aspect transient, which function-wise is possible in my case, since the
aspect is system-specific, i.e. the data it holds are only valid on the
system they were created anyway. But even then I get this warning!

If one has an aspect that only adds transient fields, I would argue,
that these shouldn't interfere with serialization and hence one could
use the same SUID on both sides. In such cases that warning should NOT
appear, should it?

Or am I still missing something here?

Michael
Re: don't understand serialVersionUID related warning [message #54816 is a reply to message #54711] Mon, 11 July 2005 07:42 Go to previous message
Eclipse UserFriend
Originally posted by: Rafal.Krzewski.caltha.pl

Eric Bodden wrote:

> Or simply ignore/suppress the warning. (see @SuppressWarnings)

ajc does not support @SuppressWarnings at this point. Last JDT update in
AJ happened just before this feature landed in JDT core trunk.
I'm looknig forward to JDC core v570 (ie 3.1 final) update in AJ,
because several hundred bugs were fixed since v522 ;-)

have a good week everyone
Rafał
Re: don't understand serialVersionUID related warning [message #589302 is a reply to message #54679] Sun, 10 July 2005 19:15 Go to previous message
Eric Bodden is currently offline Eric BoddenFriend
Messages: 32
Registered: July 2009
Member
Hi.

On Sat, 9 Jul 2005 19:11:30 +0200, Michael Moser wrote:

> Hi, I am using an aspect to make a class implement an additional
> interface i.e.
>
> public aspect XYZ {
> declare parent: <foo> implements <bar>.
> (... adding the additionally required methods here...)
> }
>
> Compiling my project I am getting the following warning:
>
> Severity Description Resource In Folder Location Creation Time
> 1 serialVersionUID of type <foo> needs to be set because of added
> interface <bar> [Xlint:needsSerialVersionUIDField] XYZ.aj <package-here>
> line 13 July 9, 2005 6:51:51 PM
>
> I have troubles understanding this warning: what exactly does that mean
> and what am I supposed to do or fix here?

For each class, if no explicit SUID is given, it is calculated
automatically from the members. You add members via your aspect. This
changes the SUID of <foo>, which the "base concern" might not be aware of.
You might have serialized versions of <foo> stored somewhere, which cannot
be loaded any more, when adding a member.

Setting the SUID explicitly tells Java, that the new and old versions *are*
compatible. New members are initializes to 0/null as you go.

> I already tried the following:
>
> 1.) I tried to define a new, different serialVersionUID, i..e. I added:
> ...
> private static final long <foo>.serialVersionUID = ... ;
>
> ...
> to the aspect, but apparently static inter-type fields are not supported
> (why?).

This cannot work, since actually there are no final static fields. They are
always inlined by the compiler.

> 2.) I tried adding a non-static field, i.e.:
> ...
> private final long <foo>.serialVersionUID = ... ;
> ...
> but then the warning re-appeared (and IMHO this wouldn't satisfy the
> serializiation requirement anyway).

This is wrong, since it is not static.

> 3.) I also tried the above two without the <foo>-prefix (i.e. making the
> serialVersionUID a member of the aspect rather than of the advised
> class):
>
> private static final long serialVersionUID = ... ;
> and
> private final long serialVersionUID = ... ;
>

You *must* declare the SUID in the class <foo> itself! There's no other
way. Or simply ignore/suppress the warning. (see @SuppressWarnings)

Eric

--
Eric Bodden, ICQ: 12656220, http://www.bodden.de, PGP: BB465582
There’s no obfuscated Perl contest because it’s pointless.
- Jeff Polk
Think I now understand serialVersionUID related warning - but another question popped up [message #589318 is a reply to message #54711] Sun, 10 July 2005 21:49 Go to previous message
Michael Moser is currently offline Michael MoserFriend
Messages: 914
Registered: July 2009
Senior Member
Hi Eric,

"Eric Bodden" <newsserver_mails@bodden.de> wrote in message
news:g4j0a8cm4diz.2p69esk1moye.dlg@40tude.net...
> ...
> On Sat, 9 Jul 2005 19:11:30 +0200, Michael Moser wrote:
>
>> ...
>> public aspect XYZ {
>> declare parent: <foo> implements <bar>.
>> (... adding the additionally required methods here...)
>> }
>> ...
> ...
>
> You *must* declare the SUID in the class <foo> itself! There's no
> other
> way. Or simply ignore/suppress the warning. (see @SuppressWarnings)

OK - I think I now understood the issue here. In the general case this
represents indeed an issue and hence the warning is perfectly valid!

In my case I have a problem implementing your suggestion, because <foo>
is actually an interface that I am extending, so I can't really define
an SUID here - can I? But then I went and made all of the fields of the
aspect transient, which function-wise is possible in my case, since the
aspect is system-specific, i.e. the data it holds are only valid on the
system they were created anyway. But even then I get this warning!

If one has an aspect that only adds transient fields, I would argue,
that these shouldn't interfere with serialization and hence one could
use the same SUID on both sides. In such cases that warning should NOT
appear, should it?

Or am I still missing something here?

Michael
Re: don't understand serialVersionUID related warning [message #589355 is a reply to message #54711] Mon, 11 July 2005 07:42 Go to previous message
Eclipse UserFriend
Originally posted by: Rafal.Krzewski.caltha.pl

Eric Bodden wrote:

> Or simply ignore/suppress the warning. (see @SuppressWarnings)

ajc does not support @SuppressWarnings at this point. Last JDT update in
AJ happened just before this feature landed in JDT core trunk.
I'm looknig forward to JDC core v570 (ie 3.1 final) update in AJ,
because several hundred bugs were fixed since v522 ;-)

have a good week everyone
Rafał
Previous Topic:Another problem with static crosscutting...
Next Topic:create
Goto Forum:
  


Current Time: Fri Apr 26 21:06:55 GMT 2024

Powered by FUDForum. Page generated in 0.03293 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top