]> source.dussan.org Git - aspectj.git/commitdiff
Fix for Bugzilla Bug 61538
authoraclement <aclement>
Wed, 12 May 2004 12:52:55 +0000 (12:52 +0000)
committeraclement <aclement>
Wed, 12 May 2004 12:52:55 +0000 (12:52 +0000)
   nested uses of this() inside constructors not handled properly for initialization and preinitialization pointcuts

weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java

index 1c3b93be015521b0537ac177e9ddf2498bdcc96f..2a487d008f7e0bf501ccea99aaf70c802c8e7db9 100644 (file)
@@ -360,7 +360,10 @@ class BcelClassWeaver implements IClassWeaver {
         
         // if we matched any initialization shadows, we inline and weave
                if (! initializationShadows.isEmpty()) {
-                       inlineSelfConstructors(methodGens);
+                       // Repeat next step until nothing left to inline...cant go on 
+                       // infinetly as compiler will have detected and reported 
+                       // "Recursive constructor invocation"
+                       while (inlineSelfConstructors(methodGens));
                        positionAndImplement(initializationShadows);
                }
                
@@ -402,7 +405,8 @@ class BcelClassWeaver implements IClassWeaver {
        }
 
 
-       private void inlineSelfConstructors(List methodGens) {
+       private boolean inlineSelfConstructors(List methodGens) {
+               boolean inlinedSomething = false;
                for (Iterator i = methodGens.iterator(); i.hasNext();) {
                        LazyMethodGen mg = (LazyMethodGen) i.next();
                        if (! mg.getName().equals("<init>")) continue;
@@ -410,8 +414,10 @@ class BcelClassWeaver implements IClassWeaver {
                        if (ih != null && isThisCall(ih)) {
                                LazyMethodGen donor = getCalledMethod(ih);
                                inlineMethod(donor, mg, ih);
+                               inlinedSomething = true;
                        }
                }
+               return inlinedSomething;
        }
 
        private void positionAndImplement(List initializationShadows) {