]> source.dussan.org Git - aspectj.git/commitdiff
354022
authoraclement <aclement>
Fri, 5 Aug 2011 16:17:39 +0000 (16:17 +0000)
committeraclement <aclement>
Fri, 5 Aug 2011 16:17:39 +0000 (16:17 +0000)
weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java

index eb8597925f6405b3cd248c1b0a599b8289bb373d..8b0ec5ecf55a4234ccaaa5712b5161fff7deca9c 100644 (file)
@@ -495,7 +495,8 @@ class BcelClassWeaver implements IClassWeaver {
                        // 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)) {
+                       List<LazyMethodGen> recursiveCtors = new ArrayList<LazyMethodGen>();
+                       while (inlineSelfConstructors(methodGens, recursiveCtors)) {
                        }
                        positionAndImplement(initializationShadows);
                }
@@ -1526,8 +1527,9 @@ class BcelClassWeaver implements IClassWeaver {
                return aspectsAffectingType;
        }
 
-       private boolean inlineSelfConstructors(List<LazyMethodGen> methodGens) {
+       private boolean inlineSelfConstructors(List<LazyMethodGen> methodGens, List<LazyMethodGen> recursiveCtors) {
                boolean inlinedSomething = false;
+               List<LazyMethodGen> newRecursiveCtors = new ArrayList<LazyMethodGen>();
                for (LazyMethodGen methodGen : methodGens) {
                        if (!methodGen.getName().equals("<init>")) {
                                continue;
@@ -1535,10 +1537,17 @@ class BcelClassWeaver implements IClassWeaver {
                        InstructionHandle ih = findSuperOrThisCall(methodGen);
                        if (ih != null && isThisCall(ih)) {
                                LazyMethodGen donor = getCalledMethod(ih);
-                               inlineMethod(donor, methodGen, ih);
-                               inlinedSomething = true;
+                               if (donor.equals(methodGen)) {
+                                       newRecursiveCtors.add(donor);
+                               } else {
+                                       if (!recursiveCtors.contains(donor)) {
+                                               inlineMethod(donor, methodGen, ih);
+                                               inlinedSomething = true;
+                                       }
+                               }
                        }
                }
+               recursiveCtors.addAll(newRecursiveCtors);
                return inlinedSomething;
        }
 
@@ -3094,7 +3103,7 @@ class BcelClassWeaver implements IClassWeaver {
                                                        && s.charAt(4) == 'a'
                                                        && (s.equals("org.aspectj.runtime.internal.CFlowCounter")
                                                                        || s.equals("org.aspectj.runtime.internal.CFlowStack") || s
-                                                                       .equals("org.aspectj.runtime.reflect.Factory"))) {
+                                                                               .equals("org.aspectj.runtime.reflect.Factory"))) {
                                                proceed = false;
                                        } else {
                                                if (methodName.equals("aspectOf")) {