Bug 36293 - class constructor cannot be called when implementing self made interfaces
Summary: class constructor cannot be called when implementing self made interfaces
Status: RESOLVED WONTFIX
Alias: None
Product: AspectJ
Classification: Tools
Component: Compiler (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Jim Hugunin CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-04-09 10:53 EDT by halo CLA
Modified: 2003-04-10 14:11 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description halo CLA 2003-04-09 10:53:50 EDT
Hi


I found following strange error:


When implementing an own interface in a class, every call to the class' 
constructors are mapped only to a no-args constructor of the interface, while 
logging all initializations with initialization(*.new (..)) with an after 
returning advice! Without the after returning advice or with after() returning : 
trace() && !initialization(*.new (..)) also the class constructor will be 
invoked (so the normal way).




Example:


public interface Ifc{}




public class test1 implements Ifc {


  public test1() {


  	super();


    System.out.println("test1");


  }


}




public class Test {


  public static void main(String[] args) {


	test1 t=new test1();


	System.out.println("xz");


  }


}




public aspect Logging {


  pointcut trace() : (execution(* * (..)) || initialization(*.new (..)))


    && !cflow(this(Logging))


    && !(cflow(this(TracingConfiguration)));




  private String arguments(Object[] args) {


    String ret = new String();


    if (args.length == 0) {


      ret = " without parameters ";


      return ret;


    }


    ret = " with parameters: ";


    for (int i = 0; i < args.length; i++) {


      ret += args[i].toString() + " ";


    }


    return ret;


  }




  before() : trace() {


    String method = thisJoinPoint.getSignature().toLongString();


    System.out.println(


      "before " + method + arguments(thisJoinPoint.getArgs()));


  }




  after() returning(Object ret) : trace() /* && !initialization(*.new (..)) */{


    String method = thisJoinPoint.getSignature().toLongString();


    if (ret != null) {


      System.out.println(


        "after "


          + method


          + arguments(thisJoinPoint.getArgs())


          + "returns "


          + ret.toString());


    } else {


      System.out.println(


        "after "


          + method


          + arguments(thisJoinPoint.getArgs())


          + "without return value");


    }


  }


}
Comment 1 halo CLA 2003-04-09 10:58:15 EDT
Sorry, I forgot to mention the AspectJ version:




Eclipse AJDE plug-in v1.0.6
Comment 2 Jim Hugunin CLA 2003-04-10 14:11:10 EDT
This is a known and unfortunate bug in AspectJ-1.0.6.  It has been fixed in 
the AspectJ-1.1rc1 release.  We don't have the resources to do any more work 
on the 1.0.x branch, so I doubt that this bug will be fixed there.  I 
recommend upgrading the 1.1rc1.