| <!DOCTYPE html |
| PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "../xhtml1-strict.dtd"> |
| <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
| <meta name="copyright" |
| content="Copyright Technical University Berlin and others 2004, 2010. This page is made available under the Eclipse Public License v1.0. For full details see http://www.eclipse.org/legal/epl-v10.html" /> |
| <link rel="stylesheet" type="text/css" href="../css/ot.css" /> |
| <link rel="stylesheet" type="text/css" href="../css/otjld.css" /> |
| <title>OT/J Language Definition v1.3</title> |
| </head> |
| <body class="otdt"> |
| <div id="content"> |
| <table class="nav"> |
| <tr> |
| <td class="back"><a id="top"></a><a href="s1.3.1.b.html" rel="prev"><< §1.3.1.(b) Direct role acquisition</a></td> |
| <td class="top"><a href="index.html" rel="contents">↑ Table of Contents ↑</a></td> |
| <td class="next"><a href="s1.3.1.d.html" rel="next">§1.3.1.(d) Lack of subtyping >></a></td> |
| </tr> |
| </table> |
| <div class="breadcrumb"><a class="nav" href="s1.html" rel="section">§1 Teams and Roles</a> > <a class="nav" href="s1.3.html" rel="section">§1.3 Acquisition and implicit inheritance of role classes</a> > <a class="nav" href="s1.3.1.html" rel="section">§1.3.1 Acquisition and implicit inheritance of role classes</a></div> |
| <div class="subsect depth4" id="s1.3.1.c"> |
| <h4 class="subsect">§1.3.1.(c) <span class="title">Overriding and implicit inheritance</span></h4> |
| <p>If a team contains a role class definition by the same name as |
| a role defined in its super-team, |
| the new role class overrides the corresponding role from the super-team |
| and <strong>implicitly inherits</strong> all of its features. |
| Such relation is established only by name correspondence. |
| |
| </p> |
| <p>A role that overrides an inherited role should be marked with an <code>@Override</code> annotation. |
| A compiler should optionally flag a missing <code>@Override</code> annotation with a warning. |
| Conversely, it is an error if a role is marked with an <code>@Override</code> annotation but does not actually |
| override an inherited role. |
| |
| </p> |
| <p>It is an error to override a role class with an interface or vice versa. A final role cannot be overridden.<br /> |
| Unlike regular inheritance, <strong>constructors</strong> are also inherited |
| along implicit inheritance, and can be overridden just like normal methods. |
| |
| </p> |
| <div class="codecomment"> |
| In <a href="s1.html#l1.3.1-1" class="listing">Listing 1.3.1-1</a><code> R1</code> in <code>T</code> implicitly inherits all features of |
| <code>R1</code> in <code>S</code>. This is, because its enclosing team |
| <code>T</code> extends the team <code>S</code> (line 10) and the role |
| definition uses the same name <code>R1</code> (line 11). |
| Hence the attribute <code><strong>ok</strong></code> is available in the method |
| <code>m()</code> in <code>T.R1</code> (line 13). <code>T.R1</code> also overrides <code>S.R1</code> |
| which is marked by the <code>@Override</code> annotation in line 11. |
| |
| </div> |
| </div> |
| <table class="nav"> |
| <tr> |
| <td class="back"><a href="s1.3.1.b.html" rel="prev"><< §1.3.1.(b) Direct role acquisition</a></td> |
| <td class="top"><a href="index.html" rel="contents">↑ Table of Contents ↑</a></td> |
| <td class="next"><a href="s1.3.1.d.html" rel="next">§1.3.1.(d) Lack of subtyping >></a></td> |
| </tr> |
| </table> |
| <div class="breadcrumb"><a class="nav" href="s1.html" rel="section">§1 Teams and Roles</a> > <a class="nav" href="s1.3.html" rel="section">§1.3 Acquisition and implicit inheritance of role classes</a> > <a class="nav" href="s1.3.1.html" rel="section">§1.3.1 Acquisition and implicit inheritance of role classes</a></div> |
| </div> |
| <div id="footer"> |
| <hr /> |
| <address>© Stephan Herrmann, Christine Hundt, Marco Mosconi</address> |
| OT/J version 1.3 — last modified: 2010-02-20 |
| </div> |
| </body> |
| </html> |