blob: 7d0fc24a7cd5ae6c935ea3ea6ced968bc1322b0c [file] [log] [blame]
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Chapter 5. Covariance</title><link rel="stylesheet" href="aspectj-docs.css" type="text/css"><meta name="generator" content="DocBook XSL Stylesheets V1.44"><link rel="home" href="index.html" title="The AspectJTM 5 Development Kit Developer's Notebook"><link rel="up" href="index.html" title="The AspectJTM 5 Development Kit Developer's Notebook"><link rel="previous" href="autoboxing-and-method-dispatch.html" title="Inter-type method declarations and method dispatch"><link rel="next" href="covariance-and-join-point-matching.html" title="Covariant methods and Join Point matching"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 5. Covariance</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="autoboxing-and-method-dispatch.html">Prev</a>&nbsp;</td><th width="60%" align="center">&nbsp;</th><td width="20%" align="right">&nbsp;<a accesskey="n" href="covariance-and-join-point-matching.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><h2 class="title"><a name="covariance"></a>Chapter 5. Covariance</h2></div></div><div class="toc"><p><b>Table of Contents</b></p><dl><dt><a href="covariance.html#covariance-inJava5">Covariance in Java 5</a></dt><dt><a href="covariance-and-join-point-matching.html">Covariant methods and Join Point matching</a></dt></dl></div><div class="sect1"><a name="covariance-inJava5"></a><div class="titlepage"><div><h2 class="title" style="clear: both"><a name="covariance-inJava5"></a>Covariance in Java 5</h2></div></div><p>
Java 5 (and hence AspectJ 5) allows you to narrow the return type
in an overriding method. For example:
</p><pre class="programlisting">
class A {
public A whoAreYou() {...}
}
class B extends A {
// override A.whoAreYou *and* narrow the return type.
public B whoAreYou() {...}
}
</pre></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="autoboxing-and-method-dispatch.html">Prev</a>&nbsp;</td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right">&nbsp;<a accesskey="n" href="covariance-and-join-point-matching.html">Next</a></td></tr><tr><td width="40%" align="left">Inter-type method declarations and method dispatch&nbsp;</td><td width="20%" align="center"><a accesskey="u" href="index.html">Up</a></td><td width="40%" align="right">&nbsp;Covariant methods and Join Point matching</td></tr></table></div></body></html>