true, cg.getConstantPool());
cg.addAnnotation(ag);
} else {
// List elems = new ArrayList();
List elems = new ArrayList();
elems.add(new NameValuePair("value",
new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), perclauseString), cg.getConstantPool()));
AnnotationGen ag = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/Aspect"), elems, true, cg
.getConstantPool());
cg.addAnnotation(ag);
}
if (concreteAspect.precedence != null) {
SimpleElementValue svg = new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), concreteAspect.precedence);
List elems = new ArrayList();
elems.add(new NameValuePair("value", svg, cg.getConstantPool()));
AnnotationGen agprec = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/DeclarePrecedence"), elems, true,
cg.getConstantPool());
cg.addAnnotation(agprec);
}
// default constructor
LazyMethodGen init = new LazyMethodGen(Modifier.PUBLIC, Type.VOID, "<init>", EMPTY_TYPES, EMPTY_STRINGS, cg);
InstructionList cbody = init.getBody();
cbody.append(InstructionConstants.ALOAD_0);
cbody.append(cg.getFactory().createInvoke(parentName, "<init>", Type.VOID, EMPTY_TYPES, Constants.INVOKESPECIAL));
cbody.append(InstructionConstants.RETURN);
cg.addMethodGen(init);
for (Iterator it = concreteAspect.pointcuts.iterator(); it.hasNext();) {
Definition.Pointcut abstractPc = (Definition.Pointcut) it.next();
// TODO AV - respect visibility instead of opening up as public?
LazyMethodGen mg = new LazyMethodGen(Modifier.PUBLIC, Type.VOID, abstractPc.name, EMPTY_TYPES, EMPTY_STRINGS, cg);
SimpleElementValue svg = new SimpleElementValue(ElementValue.STRING, cg.getConstantPool(), abstractPc.expression);
List elems = new ArrayList();
elems.add(new NameValuePair("value", svg, cg.getConstantPool()));
AnnotationGen mag = new AnnotationGen(new ObjectType("org/aspectj/lang/annotation/Pointcut"), elems, true, cg
.getConstantPool());
AnnotationAJ max = new BcelAnnotation(mag, world);
mg.addAnnotation(max);
InstructionList body = mg.getBody();
body.append(InstructionConstants.RETURN);
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);