diff options
author | avasseur <avasseur> | 2005-10-25 10:00:58 +0000 |
---|---|---|
committer | avasseur <avasseur> | 2005-10-25 10:00:58 +0000 |
commit | 76ebbc76add2abd815b3a8b5ea0beb11c94c8c49 (patch) | |
tree | 08ac38010d43c13554209b03653af744edec4722 /weaver | |
parent | bd951ed3eaf19b17ac1b1541d6072246a21a2ca8 (diff) | |
download | aspectj-76ebbc76add2abd815b3a8b5ea0beb11c94c8c49.tar.gz aspectj-76ebbc76add2abd815b3a8b5ea0beb11c94c8c49.zip |
concrete-aspect impl and doc for LTW - see #95529
pbly some issue on abstract @Pointcut() in ajdt core - fix coming
Diffstat (limited to 'weaver')
3 files changed, 71 insertions, 49 deletions
diff --git a/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java b/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java index 1160ac791..f3846c53a 100644 --- a/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java +++ b/weaver/src/org/aspectj/weaver/bcel/AtAjAttributes.java @@ -1051,57 +1051,73 @@ public class AtAjAttributes { Annotation pointcut = getAnnotation(runtimeAnnotations, AjcMemberMaker.POINTCUT_ANNOTATION); if (pointcut != null) { ElementNameValuePair pointcutExpr = getAnnotationElement(pointcut, VALUE); - if (pointcutExpr != null) { - // 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 - } - - // this/target/args binding - final IScope binding; - try { - binding = new BindingScope( - struct.enclosingType, - struct.context, - extractBindings(struct) - ); - } catch (UnreadableDebugInfoException e) { - return; - } + // 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 + } - 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()); - } + // 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 + } - // 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 - Pointcut pc = parsePointcut(pointcutExpr.getValue().stringifyValue(), struct, true); - if (pc == null) return;//parse error - // do not resolve binding now but lazily - pc.setLocation(struct.context, -1, -1);//FIXME AVASM !! bMethod is null here.. - struct.ajAttributes.add( - new AjAttribute.PointcutDeclarationAttribute( - new LazyResolvedPointcutDefinition( - struct.enclosingType, - struct.method.getModifiers(), - struct.method.getName(), - argumentTypes, - UnresolvedType.forSignature(struct.method.getReturnType().getSignature()), - pc, - binding - ) - ) + // this/target/args binding + final IScope binding; + try { + binding = new BindingScope( + struct.enclosingType, + struct.context, + extractBindings(struct) ); + } catch (UnreadableDebugInfoException e) { + return; + } + + 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;//stop + } + } 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;//parse error + pc.setLocation(struct.context, -1, -1);//FIXME AVASM !! bMethod is null here.. + } else { + reportError("Found undefined @Pointcut on a non-abstract method", struct); + return; + } } + // do not resolve binding now but lazily + struct.ajAttributes.add( + new AjAttribute.PointcutDeclarationAttribute( + new LazyResolvedPointcutDefinition( + struct.enclosingType, + struct.method.getModifiers(), + struct.method.getName(), + argumentTypes, + UnresolvedType.forSignature(struct.method.getReturnType().getSignature()), + pc,//can be null for abstract pointcut + binding + ) + ) + ); } } diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelPerClauseAspectAdder.java b/weaver/src/org/aspectj/weaver/bcel/BcelPerClauseAspectAdder.java index 242e8b76d..79427eb4c 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelPerClauseAspectAdder.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelPerClauseAspectAdder.java @@ -85,6 +85,10 @@ public class BcelPerClauseAspectAdder extends BcelTypeMunger { return false; } + return forceMunge(gen); + } + + public boolean forceMunge(LazyClassGen gen) { generatePerClauseMembers(gen); if (kind == PerClause.SINGLETON) { diff --git a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java index cf4c29927..6ab999ec3 100644 --- a/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java +++ b/weaver/src/org/aspectj/weaver/bcel/BcelWeaver.java @@ -141,8 +141,9 @@ public class BcelWeaver implements IWeaver { * The type is resolved to support DOT for static inner classes as well as DOLLAR * * @param aspectName + * @return aspect */ - public void addLibraryAspect(String aspectName) { + public ResolvedType addLibraryAspect(String aspectName) { // 1 - resolve as is ResolvedType type = world.resolve(UnresolvedType.forName(aspectName), true); if (type.equals(ResolvedType.MISSING)) { @@ -167,8 +168,9 @@ public class BcelWeaver implements IWeaver { //TODO AV - happens to reach that a lot of time: for each type flagged reweavable X for each aspect in the weaverstate //=> mainly for nothing for LTW - pbly for something in incremental build... xcutSet.addOrReplaceAspect(type); - } else { - // FIXME : Alex: better warning upon no such aspect from aop.xml + return type; + } else { + // FIXME AV - better warning upon no such aspect from aop.xml throw new RuntimeException("Cannot register non aspect: " + type.getName() + " , " + aspectName); } } |