Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] InterType: introducing serialVersionUIDinto@Persistable

> > > The actual aspect's code:
> > > public privileged aspect MyAspect 
> > > {
> > >     declare parents: @Persistable * implements PersistenceAware;
> > >     public long PersistenceAware.XXX = 17;
> > > }   
> > 
> >   Have you tried
> > 
> > public aspect MyAspect {
> >   interface PersistenceAware { 
> >     long serialVersionUID = 17; // this is static final
> >   }
> >   declare parents: @Persistable * implements PersistenceAware;
> > }   
> 
> 
> Thanks for an idea.
> Just tried. Not working at all. No fields introduced to @Persistable+.

  The above is not supposed to do that. It declares a public static
final field in a normal Java interface (only aj thing here is that this
interface is declared within an aspect) and makes your classes implement
that interface. A class implementing an interface gets all the constants
(i.e. static finals) declared in the implemented interface to its
namespace. The thing I'm not sure about is whether the serialization
mechanism is happy w/ a public static final field that is in the class'
namespace due to implementing an interface that has the field or whether
it requires that the field must be declared in the class itself, and not
inherited from a superclass / implemented interface.

  That is, after doing the above, this should work:

public @Persistable class MyClass {
  // ...
}

long foo = MyClass.serialVersionUID;


  But I'm not sure whether that is good enough for the serialization
mechanism.




     -Antti-




Back to the top