Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] New intertype syntax ...new meaning?

Hi Matthew,

thanks for the feedback.  What you have said, and what you want, does
make sense, but it is a few steps down the road from what I am
initially proposing :)  Let me show from where we are to where you
are:

Your first case:

> @Entity @Coded public class Thing { /* ... */ }
> ================
> public interface Coded { String getCode(); }
> ================
> public aspect CodedMixin {
>  public interface IntroducedCoded extends Coded {}
>  declare parents: ((@Entity *) && (@Coded *)) implements IntroducedCoded;
>
>  @Column(name="code") private String IntroducedCoded.code;
>
>  public String IntroducedCoded.getCode() { return code; }
>  public void IntroducedCoded.setCode(String code) { this.code = code; }
> }

- perhaps a typo, but I'm not sure why the private string field 'code'
would become protected in the same generated output you would like?
- I presume that should say 'public @interface Coded' and the
restriction that you can't ITD on annotations forces the use of a
marker interface (could perhaps address this restriction too...)

Anyway, step (1) - refactor to the new syntax:

aspect CodedMixin {
  interface IntroducedCoded extends Coded {}
  declare parents: ((@Entity *) && (@Coded *)) implements IntroducedCoded;

  intertype IntroducedCoded {
    @Column(name="code") private String code;
    public String getCode() { return code; }
    public void setCode(String code) { this.code = code; }
 }
}

All the ITDs that targeted the type are now grouped in an intertype
block which names the target.  What changes at weave time?  The new
members do not have mangled names.

Step (2) implicitly create the named marker interface:

aspect CodedMixin {
  declare parents: ((@Entity *) && (@Coded *)) implements IntroducedCoded;

  intertype IntroducedCoded { // don't need to declare IntroducedCoded
    @Column(name="code") private String code;
    public String getCode() { return code; }
    public void setCode(String code) { this.code = code; }
 }
}


Step (3) from there, I think you would like to write:

aspect CodedMixin {
  intertype ((@Entity *) && (@Coded *)) {
    @Column(name="code") private String code;
    public String getCode() { return code; }
    public void setCode(String code) { this.code = code; }
 }
}

For me, right now, that is a step too far - as it is not 100% clear
how the type checking for the members within the intertype block will
work. I would need to think about it.

I'm thinking about step (1) in the near term, then exploring the steps
once the syntax has had a bit of use.

> I'm not sure I understand the @Inline annotation.  Can you elaborate
> on that one?

That is simply a switch that would enable you to say you wanted the
new inlining behaviour for your old ITDs ( if you didn't want to move
them to the new syntax)

Andy.


Back to the top