Community
Participate
Working Groups
Allow defining type names that can be used anywhere a type pattern can be used in AspectJ (e.g., in ). This will allow reuse and composition of patterns, which is going to be especially important when resolving https://bugs.eclipse.org/bugs/show_bug.cgi?id=44365 and adding support for JSR- 175 annotations to AspectJ. It would be *very* beneficial if these type names could be used for inter-type declarations and declare forms like declare soft, instead of requiring these to be restricted to a single type. Example syntax (proposed by Jim): declare typename: PublicFinalType: public final *; It would be conceptually nice if these type names could be used throughout a code base wherever a type is allowed (basically providing a typedef facility for Java), although that would represent a significant non-AOP extension to Java.
Why limit such an addition to just type patterns? How about method, constructor, and field patterns as well? Looking at the AspectJ 1.1 quick reference I'm not seeing a mechanism to use OR-operators ( || ) for these patterns, but, why not? For example, if I need to define call() and execution() pointcuts across the same set of methods, its bad from a maintenance standpoint to have to copy the signatures multiple times. For example: pointcut fooCalls() : call(... method signature 1 ...) || call ( ... method signature 2 ... ) || etc.; pointcut fooExecutions() : call(... method signature 1 ...) || call ( .. method signature 2 ... ) || etc.; Why not support a way to define a set of method signatures, attach a name to it, and then do: pointcut fooCalls() : call(fooMethods); pointcut fooExecutions() : execution(fooMethods); Thanks for your consideration of this opinion.
We're not going to get to this in AJ 1.5.0. Marking as "LATER" for consideration in 1.5.1 and future release planning. Something like this *should* make it into AJ sooner rather than later though I hope.
LATER/REMIND bugs are being automatically reopened as P5 because the LATER and REMIND resolutions are deprecated.
Any change in status for this? I'd still like to be able to prevent inheritance within certain packages or types, especially as I use traits more & more: public abstract aspect AbstractExtend { public static class Nothing {} /** * Type expression provided by subaspects to identify types that are not * allowed to use inheritance. */ public abstract type restrictedTypes; public type requiredInheritance: Enum+ && Annotation+; declare parents: (restrictedTypes && !requiredInheritance) extends Nothing; }
no change I'm afraid, I'm heads down in JDT Core Java 8 right now.