private static boolean handlePointcutAnnotation(RuntimeAnnos runtimeAnnotations, AjAttributeMethodStruct struct) {
AnnotationGen pointcut = getAnnotation(runtimeAnnotations, AjcMemberMaker.POINTCUT_ANNOTATION);
if (pointcut == null) {
return false;
}
NameValuePair pointcutExpr = getAnnotationElement(pointcut, VALUE);
// semantic check: the method must return void, or be
// "public static boolean" for if() support
if (!(Type.VOID.equals(struct.method.getReturnType()) || (Type.BOOLEAN.equals(struct.method.getReturnType())
&& struct.method.isStatic() && struct.method.isPublic()))) {
reportWarning("Found @Pointcut on a method not returning 'void' or not 'public static boolean'", struct);
// no need to stop
}
// semantic check: the method must not throw anything
if (struct.method.getExceptionTable() != null) {
reportWarning("Found @Pointcut on a method throwing exception", struct);
// no need to stop
}
String argumentNames = getArgNamesValue(pointcut);
if (argumentNames != null) {
struct.unparsedArgumentNames = argumentNames;
}
// this/target/args binding
final IScope binding;
try {
if (struct.method.isAbstract()) {
binding = null;
} else {
binding = new BindingScope(struct.enclosingType, struct.context, extractBindings(struct));
}
} catch (UnreadableDebugInfoException e) {
return false;
}
UnresolvedType[] argumentTypes = new UnresolvedType[struct.method.getArgumentTypes().length];
for (int i = 0; i < argumentTypes.length; i++) {
argumentTypes[i] = UnresolvedType.forSignature(struct.method.getArgumentTypes()[i].getSignature());
}
Pointcut pc = null;
if (struct.method.isAbstract()) {
if ((pointcutExpr != null && isNullOrEmpty(pointcutExpr.getValue().stringifyValue())) || pointcutExpr == null) {
// abstract pointcut
// leave pc = null
} else {
reportError("Found defined @Pointcut on an abstract method", struct);
return false;// stop
}
} else {
if (pointcutExpr == null || isNullOrEmpty(pointcutExpr.getValue().stringifyValue())) {
// the matches nothing pointcut (125475/125480) - perhaps not as
// cleanly supported as it could be.
} else {
// if (pointcutExpr != null) {
// use a LazyResolvedPointcutDefinition so that the pointcut is
// resolved lazily
// since for it to be resolved, we will need other pointcuts to
// be registered as well
pc = parsePointcut(pointcutExpr.getValue().stringifyValue(), struct, true);
if (pc == null) {
return false;// parse error
}
pc.setLocation(struct.context, -1, -1);// FIXME AVASM !! bMethod
// is null here..