> you can declare fields on multiple classes at once. You need to declare
> an interface, then declare the field/methods/whatever on that
> interface, then inject the interface on the target types.

That's what I tried and what worked:

public @interface MakeLoggable {}

public interface Loggable{
  Logger getLogger();
}

public aspect AutoLogging {
 declare parents: (@MakeLoggable *) implements Loggable;

 public Logger Loggable.mLogger;

 public Logger Loggable.getLogger()
{
  return mLogger; // okay, lazy initialization here
}
}

> It should work with static fields as well, but I've never used static
> ITDs so try playing with it a bit. Obviously, where i wrote

However, if I switch the mLogger injection to 

public static Logger Loggable.mLogger;

I get an error that I cannot introduce a static member into an interface.

So, can I get this done at all? If so, how?

Martin


_______________________________________________
aspectj-users mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/aspectj-users

Reply via email to