// body starts here
codeStream.getstatic(world.makeFieldBinding(AjcMemberMaker.perSingletonField(
typeX)));
+ Label isNull = new Label(codeStream);
+ codeStream.dup();
+ codeStream.ifnull(isNull);
codeStream.areturn();
+ isNull.place();
+ codeStream.new_(world.makeTypeBinding(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION));
+ codeStream.dup();
+ codeStream.invokespecial(world.makeMethodBindingForCall(
+ AjcMemberMaker.noAspectBoundExceptionInit()
+ ));
+ codeStream.athrow();
// body ends here
}});
}
// assert method.isStatic()
Expr[] args = call.getArgs();
//System.out.println("args: " + Arrays.asList(args));
- InstructionList callIl = renderExprs(fact, world, args);
+ InstructionList callIl = new InstructionList();
+ for (int i=0, len=args.length; i < len; i++) {
+ //XXX only correct for static method calls
+ Type desiredType = BcelWorld.makeBcelType(method.getParameterTypes()[i]);
+ callIl.append(renderExpr(fact, world, args[i], desiredType));
+ }
//System.out.println("rendered args: " + callIl);
callIl.append(Utility.createInvoke(fact, world, method));
callIl.append(createJumpBasedOnBooleanOnStack());
try {
ExposedState myState = new ExposedState(baseArgsCount);
//System.out.println(residueSource);
- residueSource.findResidue(shadow, myState); // don't care about Test
+ //??? some of these tests are preconditions for the if to run correctly
+ // this implementation will duplicate those tests, we should be more careful
+ Test preTest = residueSource.findResidue(shadow, myState); // might need this
//System.out.println(myState);
if ((extraParameterFlags & Advice.ThisEnclosingJoinPointStaticPart) != 0) {
args.add(shadow.getThisEnclosingJoinPointStaticPartVar());
}
-
- return Test.makeCall(testMethod, (Expr[])args.toArray(new Expr[args.size()]));
+ Test myTest = Test.makeCall(testMethod, (Expr[])args.toArray(new Expr[args.size()]));
+ return Test.makeAnd(preTest, myTest);
+
} finally {
findingResidue = false;
}
}
public Test findResidue(Shadow shadow, ExposedState state) {
- state.setAspectInstance(
- Expr.makeFieldGet(AjcMemberMaker.perSingletonField(inAspect), inAspect));
- // XXX we need to think about whether it's null...
+ Expr myInstance =
+ Expr.makeCallExpr(AjcMemberMaker.perSingletonAspectOfMethod(inAspect),
+ Expr.NONE, inAspect);
+
+ state.setAspectInstance(myInstance);
+
+ // we have no test
+ // a NoAspectBoundException will be thrown if we need an instance of this
+ // aspect before we are bound
return Literal.TRUE;
}