Inter-type method declarations and method dispatch

Autoboxing, unboxing, and also varargs all affect the method dispatch algorithm used in Java 5. In AspectJ 5, the target method of a call is selected according to the following algorithm:

  1. Attempt to locate a matching method or inter-type declared method without considering autoboxing, unboxing, or vararg invocations.
  2. If no match is found, try again considering autoboxing and unboxing.
  3. Finally try again considering both autoboxing, unboxing, and varargs.

One consequence is that a directly matching inter-type declared method will take precedence over a method declared locally in the target class but that only matches via autoboxing.