Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] InterType: introducing serialVersionUID into @Persistable

#: Tomasz Nazar changed the world a bit at a time by saying on  9/19/2005 12:04 PM :#

Hi there!

I have slight problem with introducing 'static final long serialVersionUID = 17L' into any class
that is marked with @Persistable interface.

'final' and 'static' are the keywords here.

Error message is of course: "static inter-type field on interface not
supported".

The question is why isn't this supported, or better how to achieve
introduction of 'static final long' into a _class_ (if possible).


MyAspect.aj:
    declare parents @Persistable * implements java.io.Serializable;
    //static final @Persistable.serialVersionUID = 17L; <- won't work

    //static final ConcretePojo.serialVersionUID = 17L; <- will work,
    //but not what I need


I know it's a rare case where one needs to introduce that field, but ..
it's my case. Thanks for any feedback.

Tomasz



According to www.eclipse.org/aspectj/doc/next/adk15notebook/annotations-itds.html an annotation type cannot be the target of an inter-type declaration. What you need is to push your ITD on an type annotated with @Persistable.

So you probably need a marker interface and than do the ITD:

interface PersistenceAware {};

declare parents @Persistable * implements java.io.Serializable;
declare parents @Persistable * implements PersistenceAware;

static final PersistenceAware.serialVersionUID = 17L;

hth,
./alex
--
.the_mindstorm.


ps: the aboves have not been tested, but at least they represent my expectations :-)




Back to the top