From b9ec4df1259123c4cccc09f5a8b0549b412ee071 Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 12 May 2004 12:52:55 +0000 Subject: [PATCH] Fix for Bugzilla Bug 61538 nested uses of this() inside constructors not handled properly for initialization and preinitialization pointcuts --- .../src/org/aspectj/weaver/bcel/BcelClassWeaver.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java index 1c3b93be0..2a487d008 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelClassWeaver.java @@ -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("")) 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) { -- 2.39.5