Chapter 5. Covariance

Table of Contents

Covariance in Java 5
Covariant methods and Join Point matching

Covariance in Java 5

Java 5 (and hence AspectJ 5) allows you to narrow the return type in an overriding method. For example:

		class A {
		  public A whoAreYou() {...}
		}
		
		class B extends A {
		  // override A.whoAreYou *and* narrow the return type.
		  public B whoAreYou() {...}
		}