Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Inlining code in aspectJ??


This is really a question for aspectj-dev ... The kind of inlining you
will see for privileged aspects is accessor method inlining - not advice
inlining.

You're example aspect doesn't access any private state in
class A2 so you don't see any of these generated accessors.

Changing your programs to this:

public class A2 {
  private static int compte;
  public static void main(String[] args) {
    setCompte(1000);
    System.out.println(compte);
  }
  public static void setCompte(int l){
    compte=l;
  }
}

privileged aspect AS2 {
  pointcut p(): call(* *.setCompte(..)) &&! within(AS2);

  before():p(){
    System.out.println("hello"+A2.compte);
  }
}

Now the advice accesses the private field compte, after building
and decompiling A2 you see this:

public class A2 {
    public A2() {}
    public static void main(String args[]) {
        AS2.aspectOf().ajc$before$AS2$1$1a971();
        setCompte(1000);
        System.out.println(compte);
    }
    public static void setCompte(int l) {
        compte = l;
    }
    public static int ajc$privFieldGet$AS2$A2$compte() {
        return compte;
    }
    public static void ajc$privFieldSet$AS2$A2$compte(int i) {
        compte = i;
    }
    private static int compte;
}

Andy
---
Andy Clement
AspectJ




"Nadia Guerroumi" <n_guerro@xxxxxxxxxxxxxxxx>
Sent by: aspectj-users-bounces@xxxxxxxxxxx

18/04/2005 19:10

Please respond to
aspectj-users@xxxxxxxxxxx

To
<aspectj-users@xxxxxxxxxxx>
cc
Subject
[aspectj-users] Inlining code in aspectJ??





I was trying to see the inlining strategy described in the paper "Advice Weaving in AspectJ" of Eric HiIsdale and Jim Hugunin.
 
In the paper it is said that the inlining is used in the implementation of privileged aspects and around (default).
 
For the privileged aspect I didn't see this inlining in the bytecode. Is it because I am using the ajc 1.2 ?
 
Example:
 
public class A2 {
public static int compte;
public static void main(String[] args) {

setCompte(1000);
System.out.println(compte);
}
public static void setCompte(int l){
compte=l;
}}

privileged aspect AS2 {
pointcut p(): call(* *.setCompte(..)) &&! within(AS2);
before():p(){
System.out.println("hello");
}}

 
Byte Code of A2!:
 
Compiled from A2.java
public class A2 extends java.lang.Object {
   public static int compte;
   public A2();
   public static void main(java.lang.String[]);
   public static void setCompte(int);
}

 
Method A2()
  0 aload_0
  1 invokespecial #11 <Method java.lang.Object()>
  4 return

 
Method void main(java.lang.String[])
  0 sipush 1000
  3 invokestatic #46 <Method AS2 aspectOf()>
  6 invokevirtual #49 <Method void ajc$before$AS2$1$1a971()>   ===> NO INLINING!!

  9 invokestatic #22 <Method void setCompte(int)>
 12 getstatic #28 <Field java.io.PrintStream out>
 15 getstatic #30 <Field int compte>
 18 invokevirtual #35 <Method void println(int)>
 21 return

 
Method void setCompte(int)
  0 iload_0
  1 putstatic #30 <Field int compte>
  4 return

 
============================================================
Nadia Belblidia-Guerroumi,
Ph.D Candidate, ECE Department,
Concordia University, 1425 Rene Levesque
Room 420-16
email:n_guerro@xxxxxxxxxxxxxxxx
==============================================================
_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users


Back to the top