aboutsummaryrefslogtreecommitdiffstats
path: root/loadtime/src
diff options
context:
space:
mode:
authoraclement <aclement>2010-01-29 20:30:35 +0000
committeraclement <aclement>2010-01-29 20:30:35 +0000
commitb21cd2fcde00255aef5de268c66350c6fb1d8441 (patch)
tree4e14405aaf168882f4b8388643874aadb175fec0 /loadtime/src
parent9e935c0777e5780c8e4ce89dfaf32f2a7f34faa7 (diff)
downloadaspectj-b21cd2fcde00255aef5de268c66350c6fb1d8441.tar.gz
aspectj-b21cd2fcde00255aef5de268c66350c6fb1d8441.zip
extended definition and code gen to allow for deows
Diffstat (limited to 'loadtime/src')
-rw-r--r--loadtime/src/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java35
1 files changed, 31 insertions, 4 deletions
diff --git a/loadtime/src/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java b/loadtime/src/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java
index 41b9b4ca3..32293bee1 100644
--- a/loadtime/src/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java
+++ b/loadtime/src/org/aspectj/weaver/loadtime/ConcreteAspectCodeGen.java
@@ -26,6 +26,7 @@ import org.aspectj.apache.bcel.classfile.annotation.AnnotationGen;
import org.aspectj.apache.bcel.classfile.annotation.ElementValue;
import org.aspectj.apache.bcel.classfile.annotation.NameValuePair;
import org.aspectj.apache.bcel.classfile.annotation.SimpleElementValue;
+import org.aspectj.apache.bcel.generic.FieldGen;
import org.aspectj.apache.bcel.generic.InstructionConstants;
import org.aspectj.apache.bcel.generic.InstructionList;
import org.aspectj.apache.bcel.generic.ObjectType;
@@ -48,6 +49,7 @@ import org.aspectj.weaver.loadtime.definition.Definition;
import org.aspectj.weaver.patterns.PerClause;
import org.aspectj.weaver.patterns.PerSingleton;
+
/**
* Generates bytecode for concrete-aspect.
* <p>
@@ -176,14 +178,14 @@ public class ConcreteAspectCodeGen {
return false;
}
- // extends must be abstract
- if (!parent.isAbstract()) {
+ // extends must be abstract (allow for special case of Object where just using aspect for deows)
+ if (!(parent.isAbstract() || parent.equals(ResolvedType.OBJECT))) {
reportError("Attempt to concretize a non-abstract aspect: " + stringify());
return false;
}
- // m_parent must be aspect
- if (!parent.isAspect()) {
+ // m_parent must be aspect (allow for special case of Object where just using aspect for deows)
+ if (!(parent.isAspect() || parent.equals(ResolvedType.OBJECT))) {
reportError("Attempt to concretize a non aspect: " + stringify());
return false;
}
@@ -430,6 +432,31 @@ public class ConcreteAspectCodeGen {
cg.addMethodGen(mg);
}
+ if (concreteAspect.deows.size() > 0) {
+
+ int counter = 1;
+ for (Definition.DeclareErrorOrWarning deow : concreteAspect.deows) {
+
+ // Building this:
+
+ // @DeclareWarning("call(* javax.sql..*(..)) && !within(org.xyz.daos..*)")
+ // static final String aMessage = "Only DAOs should be calling JDBC.";
+
+ FieldGen field = new FieldGen(Modifier.FINAL, ObjectType.STRING, "rule" + (counter++), cg.getConstantPool());
+ SimpleElementValue svg = new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), deow.pointcut);
+ List elems = new ArrayList();
+ elems.add(new NameValuePair("value", svg, cg.getConstantPool()));
+ AnnotationGen mag = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/Declare"
+ + (deow.isError ? "Error" : "Warning")), elems, true, cg.getConstantPool());
+ field.addAnnotation(mag);
+
+ field.setValue(deow.message);
+ cg.addField(field, null);
+
+
+ }
+ }
+
// handle the perClause
ReferenceType rt = new ReferenceType(ResolvedType.forName(concreteAspect.name).getSignature(), world);
GeneratedReferenceTypeDelegate grtd = new GeneratedReferenceTypeDelegate(rt);