package lawOfDemeter.classform; import org.aspectj.lang.JoinPoint; import lawOfDemeter.Any; /** * @authors David H. Lorenz and Pengcheng Wu * @version 0.4, 12/19/02 */ aspect Check { private pointcut IgnoreCalls(): call(* java..*.*(..)); after(): Any.MethodCallSite() && !IgnoreCalls() { Class targetType = thisJoinPointStaticPart. getSignature().getDeclaringType(); Class thisType = thisEnclosingJoinPointStaticPart. getSignature().getDeclaringType(); if(!Pertype.contains(thisType,targetType) && !targetType.isAssignableFrom(thisType)) System.out.println( " !! LoD Class Violation !! " + thisJoinPointStaticPart/*[*/ + at(thisJoinPointStaticPart)/*]*/); } /*[*/ private String at(JoinPoint.StaticPart jp) { return " at " + jp.getSourceLocation().getFileName() + ":" + jp.getSourceLocation().getLine() + ":" + jp.getSourceLocation().getColumn(); } /*[*/ }