[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] Serialization and Annotations question

> First of all, I'm not sure if attaching to ObjectInput.readObject is
> the best way. I'm doing that because during deserialization the
> constructors are not called so I'm not sure what pointcut to define
> otherwise.

I am pretty sure that Java calls the default constructor, actually.
Indeed it's a requirement that any serializable class must have one
(implicitly or explicitly).
 
> Second, I would prefer to get rid of the check to see if the
> @Configurable annotation is present. It would be nicer if I could do
> something like this:
> 
> 	pointcut readObject() : call((@Configurable *)
> java.io.ObjectInput+.readObject());
> 
> So let AspectJ only run this aspect when readObject returns an object
> that is annotated with @Configurable. Is something like that possible,
> or does AspectJ not work at runtime, which would be required I guess.

No this you cannot do. At this point you have no static type
information. You only know it's an Object. So there is no way AspectJ
could make any such decisions statically.

Eric