if (! hasDynamicTest) { range.append(advice); } else { InstructionList callback = makeCallToCallback(callbackMethod); InstructionList postCallback = new InstructionList(); if (terminatesWithReturn()) { callback.append(fact.createReturn(callbackMethod.getReturnType())); } else { advice.append(fact.createBranchInstruction(Constants.GOTO, postCallback.append(fact.NOP))); } range.append(munger.getTestInstructions(this, advice.getStart(), callback.getStart(), advice.getStart())); range.append(advice); range.append(callback); range.append(postCallback); }
if (!hasDynamicTest) { range.append(advice); } else { InstructionList callback = makeCallToCallback(callbackMethod); InstructionList postCallback = new InstructionList(); if (terminatesWithReturn()) { callback.append( InstructionFactory.createReturn(callbackMethod.getReturnType())); } else { advice.append( InstructionFactory.createBranchInstruction( Constants.GOTO, postCallback.append(InstructionConstants.NOP))); } range.append( munger.getTestInstructions( this, advice.getStart(), callback.getStart(), advice.getStart())); range.append(advice); range.append(callback); range.append(postCallback); }
    public void weaveAroundClosure(        BcelAdvice munger,         boolean hasDynamicTest)     {    	InstructionFactory fact = getFactory();		enclosingMethod.setCanInline(false);        // MOVE OUT ALL THE INSTRUCTIONS IN MY SHADOW INTO ANOTHER METHOD!        LazyMethodGen callbackMethod =         	extractMethod(        		NameMangler.aroundCallbackMethodName(        			getSignature(),        			getEnclosingClass()));        			        	BcelVar[] adviceVars = munger.getExposedStateAsBcelVars();    	    	String closureClassName =     		NameMangler.makeClosureClassName(    			getEnclosingClass().getType(),    			getEnclosingClass().getNewGeneratedNameTag());    			    	Member constructorSig = new Member(Member.CONSTRUCTOR,     								TypeX.forName(closureClassName), 0, "<init>",     								"([Ljava/lang/Object;)V");    	    	BcelVar closureHolder = null;    	    	// This is not being used currently since getKind() == preinitializaiton    	// cannot happen in around advice    	if (getKind() == PreInitialization) {    		closureHolder = genTempVar(AjcMemberMaker.AROUND_CLOSURE_TYPE);    	}    	        InstructionList closureInstantiation =            makeClosureInstantiation(constructorSig, closureHolder);        LazyMethodGen constructor =             makeClosureClassAndReturnConstructor(            	closureClassName,                callbackMethod,                 makeProceedArgumentMap(adviceVars)                );        InstructionList returnConversionCode;		if (getKind() == PreInitialization) {			returnConversionCode = new InstructionList();						BcelVar stateTempVar = genTempVar(TypeX.OBJECTARRAY);			closureHolder.appendLoad(returnConversionCode, fact);						returnConversionCode.append(				Utility.createInvoke(					fact, 					world, 					AjcMemberMaker.aroundClosurePreInitializationGetter()));			stateTempVar.appendStore(returnConversionCode, fact);						Type[] stateTypes = getSuperConstructorParameterTypes();						returnConversionCode.append(fact.ALOAD_0); // put "this" back on the stack			for (int i = 0, len = stateTypes.length; i < len; i++) {				stateTempVar.appendConvertableArrayLoad(					returnConversionCode, 					fact, 					i, 					world.resolve(BcelWorld.fromBcel(stateTypes[i])));			}		} else {	        returnConversionCode = 	            Utility.createConversion(	                getFactory(), 	                world.makeBcelType(munger.getSignature().getReturnType()), 	                callbackMethod.getReturnType());	        if (! isFallsThrough()) {	            returnConversionCode.append(fact.createReturn(callbackMethod.getReturnType()));	        }		}                InstructionList advice = new InstructionList();        advice.append(munger.getAdviceArgSetup(this, null, closureInstantiation));//        advice.append(closureInstantiation);        advice.append(munger.getNonTestAdviceInstructions(this));        advice.append(returnConversionCode);                         if (! hasDynamicTest) {            range.append(advice);        } else {            InstructionList callback = makeCallToCallback(callbackMethod);            InstructionList postCallback = new InstructionList();            if (terminatesWithReturn()) {                callback.append(fact.createReturn(callbackMethod.getReturnType()));            } else {                advice.append(fact.createBranchInstruction(Constants.GOTO, postCallback.append(fact.NOP)));            }            range.append(munger.getTestInstructions(this, advice.getStart(), callback.getStart(), advice.getStart()));            range.append(advice);            range.append(callback);               range.append(postCallback);                 }    }