private static void checkDeclares(AspectManager manager, NewExpr newcall, MethodCall mcall, ClassAdvisor advisor) throws NotFoundException
{
for (Iterator it = manager.getDeclares() ; it.hasNext() ; )
{
DeclareDef declare = (DeclareDef)it.next();
StringBuffer sb = new StringBuffer(" condition\n\t'" + declare.getExpr() + "'\nwas broken for ");
if ((newcall != null && declare.matchesCall(advisor, newcall) || (mcall != null && declare.matchesCall(advisor, mcall))))
{
if (mcall != null)
{
sb.append("method call:");
CtBehavior caller = mcall.where();
if (caller instanceof CtConstructor)
{
CtConstructor con = (CtConstructor)caller;
addConstructor(sb, con);
sb.append(" calls ");
addMethod(sb, mcall.getMethod());
}
else if (caller instanceof CtMethod)
{
CtMethod met = (CtMethod)caller;
addMethod(sb, met);
sb.append(" calls ");
addMethod(sb, mcall.getMethod());
}
}
else if (newcall != null)
{
sb.append("constructor call: ");
CtBehavior caller = newcall.where();
if (caller instanceof CtConstructor)
{
CtConstructor con = (CtConstructor)caller;
addConstructor(sb, con);
sb.append(" calls ");
addConstructor(sb, newcall.getConstructor());
}
else if (caller instanceof CtMethod)
{
CtMethod met = (CtMethod)caller;
addMethod(sb, met);
sb.append(" calls ");
addConstructor(sb, newcall.getConstructor());
}
}
sb.append("\n\t" + declare.getMsg() + "\n");
if (declare.getWarning())
{
sb.insert(0, "WARNING: declare-warning");
//System.out.println is ok here - want to guarantee that it works even if people have screwed up their logging config
System.out.println(sb.toString());
}