[aosd-discuss] discuss Digest, Vol 33, Issue 6

cao jing jingcao80 at gmail.com
Tue Jun 27 09:52:59 EST 2006


hi, everyone in this zone:)
i have resently research AspectJ intertype declarations weaving in
ajc1.5through inspecting class files.
and i have some questions listed as follows:
1)why ajc weaves each intertype method declaration to three methods,
  for example, ajc weaves aspect program:

  public aspect As{
      public void Example.goo(){
          this.foo();
      }
  }

  to method(1) in Example class as follows:

  public void goo(){
    aload_0;
    invokestatic [As. ajc$interMethod$Ast$Example$goo]
    return;
  }

  to method(2) in As class as follows:

  public static void ajc$interMethod$As$Example$goo(Example r1){
    aload_1;
    invokevirtual [Example.foo];
    return;
  }

  and method(3) in As class as follows:

  public static void ajc$interMethodDispatch1$As$Example$goo(Example r1){
    aload_1;
    invokevirtual [Example.goo];
    return;
  }

  and calling this intertype method everywhere is transformed to calling the
method(3).
  so my question is can we weave intertype method into two mehtods omitting
methd(3) and
  calling this intertype method is transformed to calling method(1) or
method(2) depending
  on where the calling appears.

2)ajc weaves each intertype constructor declaration to three methods also.
  for example, program:

  public aspect As{
        public Example.new(String text){
          System.out.println("Example constructor");
    }
  }

  is weavon to initializing method(1) in Example:

  public void <init>(String r1){
    aload_0;
    aload_1;
    invokestatic [As.ajc$preInterConstructor$As$Example];
    aloda_0;
    invokespecial [Object.<init>]
    push 0;
    aaload;
    checkcast;
    invokestatic [As.ajc$postInterConstructor$As$Example];
    return;
  }

  and method(2), method(3) in As class:

  public static final java.lang.Object[]
ajc$preInterConstructor$As$Example(String r1){
    push 1;
    newarray;
    dup;
    push 0;
    aload_1;
    aastore;
    areturn;
  }

  public static void ajc$postInterConstructor$As$Example(Example r1, String
r2){
    getstatic [java.lang.System.out]
    push "Example constructor";
    invokevirtual [java.io.PrintStream.println];
    return;
  }

  the method(2) do nothing except putting arguments into a Object array, so
i think this
  method is useless.
  then my question is can this method be omitted?

3)ajc weaves each intertype field declaration to three methods. these
methods are
  field initializing method, field reading method, and field writing method.
and
  i find that field writing method can be used in field initializing method,
but
  i can not find where field reading method is used.
  So, my question is where field writing method is used except in field
initializing
  method and where field reading method is used? If field reading method is
not used,
  then it can be omitted.

Thanks a lot:)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: /pipermail/discuss_aosd.net/attachments/20060627/4eb5694e/attachment.html 


More information about the discuss mailing list