Hi Steve. I think we know each other from GitHub issue #299. Welcome to the mailing list channel, too.
First, a few links for you: How to declare an interface and its implementation including fields and accessor methods by means of inter-type declarations (ITD) in native AspectJ syntax: https://eclipse.dev/aspectj/doc/latest/progguide/progguide.html#language-interType The chapter right below that one also showcases some basic AspectJ examples, among them ITD ones. Just search for "declare parents", if scrolling is too tedious. The corresponding chapter explaining ITDs in annotation-style is here: https://eclipse.dev/aspectj/doc/latest/adk15notebook/adk15notebook.html#ataspectj-itds There, you find an example explaining how to achieve a similar result as in native syntax in the less powerful (but still powerful enough) annotation syntax by means of "@DeclareParents" and "@DeclareMixin", respectively. I hope this helps. If you need more support, please share an MCVE (https://stackoverflow.com/help/mcve), ideally a GitHub project or in old-school fashion by attaching a zip or tar.* archive to your next message, and I will do my best to help you sort out the details. Cheers -- Alexander Kriegisch https://scrum-master.de Steve White via aspectj-users schrieb am 29.03.2024 15:47 (GMT +01:00): > Hi, > > I'm just learning about AspectJ. I haven't been able to determine if > I can apply it to my problem. > > The problem is to add an instance member, together with > getters/setters, to certain existing classes. This seems to be an > example of a crosscutting concern. > > So far, I have managed with AspectJ only to produce classes with new > static members. > > Is it possible with AspectJ to create an annotation, say @Labelled, so that > > @Labelled > public class LabelledClass extends PlainClass{ > } > > so that instances of LabelledClass will have their own private String > member "itsLabel", with a getter "getLabel()", and a setter > "setLabel()". That is, so that LabelledClass effectively implements > > interface LabelledInterface{ > String getLabel(); > void setLabel( String label ); > } > > How would one go about this? Is something like this possible? > > If this kind of thing isn't possible, where can I find passages in the > documentation that would clarify the situation? > > Thanks! > _______________________________________________ > aspectj-users mailing list > aspectj-users@eclipse.org > To unsubscribe from this list, visit > https://www.eclipse.org/mailman/listinfo/aspectj-users > > _______________________________________________ aspectj-users mailing list aspectj-users@eclipse.org To unsubscribe from this list, visit https://www.eclipse.org/mailman/listinfo/aspectj-users