Autoboxing and Join Point matching in AspectJ 5
Prev | Chapter 4. Autoboxing and Unboxing | Next

## Autoboxing and Join Point matching in AspectJ 5

Most of the pointcut designators match based on signatures, and hence are unaffected by autoboxing. For example, a call to a method

       		public void foo(Integer i);

is not matched by a pointcut `call(void foo(int))` since the signature declares a single `Integer` parameter, not an `int`.

The `args` pointcut designator is affected by autoboxing since it matches based on the runtime type of the arguments. AspectJ 5 applies autoboxing and unboxing in determining argument matching. In other words, `args(Integer)` will match any join point at which there is a single argument of type `Integer` or of type `int`.

- args(Integer) and args(int) are equivalent
- args(Float) and args(float) are equivalent
- args(Double) and args(double) are equivalent
- args(Short) and args(short) are equivalent
- args(Byte) and args(byte) are equivalent
- args(Long) and args(long) are equivalent
- args(Boolean) and args(boolean) are equivalent

Autoboxing and unboxing are also applied when binding pointcut or advice parameters, for example:

       		pointcut foo(int i) : args(i);

       		before(Integer i) : foo(i) {
       		  ...
       		}

Prev | Up | Next
Chapter 4. Autoboxing and Unboxing | Home | Inter-type method declarations and method dispatch