/** * A declare declaration exists in a classfile only as an attibute on the class. Unlike advice and * inter-type declarations, it has no corresponding method. **AMC** changed the above policy in * the case of declare annotation, which uses a corresponding method as the anchor for the * declared annotation */ public void generateCode(ClassScope classScope, ClassFile classFile) { if (shouldBeSynthetic()) { this.binding.modifiers |= Flags.AccSynthetic; } classFile.extraAttributes.add( new EclipseAttributeAdapter(new AjAttribute.DeclareAttribute(declareDecl))); if (shouldDelegateCodeGeneration()) { super.generateCode(classScope, classFile); } return; }
public void postParse(TypeDeclaration typeDec) { super.postParse(typeDec); int declareSequenceNumberInType = ((AspectDeclaration) typeDec).declareCounter++; // FIXME asc the name should perhaps include the hashcode of the pattern (type/sig) for binary // compatibility reasons! StringBuffer sb = new StringBuffer(); sb.append("ajc$declare"); // Declares can choose to provide a piece of the name - to enable // them to be easily distinguised at weave time (e.g. see declare annotation) if (declareDecl != null) { String suffix = declareDecl.getNameSuffix(); if (suffix.length() != 0) { sb.append("_"); sb.append(suffix); } } sb.append("_"); sb.append(declareSequenceNumberInType); this.selector = sb.toString().toCharArray(); }