| <!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" /> |
| <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.1</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><a class="img" href="s1.3.1.c.html" |
| title="PermaLink to (c) Overriding and implicit inheritance"><img style="vertical-align:text-top;margin-left:5px;" src="../images/permalink.png" |
| alt="" /></a></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 /><a class="w3c img" href="http://jigsaw.w3.org/css-validator/check/referer" |
| shape="rect"><img src="../images/valid-css2-blue.png" alt="Valid CSS!" height="31" width="88" /></a><a class="w3c img" href="http://validator.w3.org/check?uri=referer" shape="rect"><img src="../images/valid-xhtml10-blue.png" alt="Valid XHTML 1.0 Strict" height="31" |
| width="88" /></a><address>© Stephan Herrmann, Christine Hundt, Marco Mosconi</address> |
| OT/J version 1.3.1 — last modified: 2013-05-28 |
| </div> |
| </body> |
| </html> |