Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Is it possible to modify the subject type based on the presence of a certain annotation on a type's method?

For the original description of your problem, depending on whether I'm
interpreting it correctly, you could use declare @type:

declare @type: hasmethod(@LogMe * (!@LogMe *).*(..)) : @LogMe;

this means 'give the annotation @LogMe to a type if it has a method
marked @LogMe'

For the interface you might use:

declare parents: hasmethod(@LogMe * (!Intface+).*(..)) implements ILoggable;

I've only written these bits of syntax in a hurry in the email client,
they may need tweaking...

hasmethod is an experimental feature and you'll have to use
-XhasMember for the compiler to let it though.

> Is this the best way to enforce the desired semantics?

Yep, that can enforce it if you don't want to use the constructs above
to perform type changes.

cheers
Andy


Back to the top