Stephan Herrmann | 0166441 | 2010-04-01 20:28:43 +0000 | [diff] [blame] | 1 | <!DOCTYPE html |
| 2 | PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "../xhtml1-strict.dtd"> |
| 3 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> |
| 4 | <head> |
| 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
Stephan Herrmann | 0166441 | 2010-04-01 20:28:43 +0000 | [diff] [blame] | 6 | <link rel="stylesheet" type="text/css" href="../css/ot.css" /> |
| 7 | <link rel="stylesheet" type="text/css" href="../css/otjld.css" /> |
| 8 | <title>OT/J Language Definition v1.3</title> |
| 9 | </head> |
| 10 | <body class="otdt"> |
| 11 | <div id="content"> |
| 12 | <table class="nav"> |
| 13 | <tr> |
| 14 | <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> |
| 15 | <td class="top"><a href="index.html" rel="contents">↑ Table of Contents ↑</a></td> |
| 16 | <td class="next"><a href="s1.3.1.d.html" rel="next">§1.3.1.(d) Lack of subtyping >></a></td> |
| 17 | </tr> |
| 18 | </table> |
| 19 | <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> |
| 20 | <div class="subsect depth4" id="s1.3.1.c"> |
Stephan Herrmann | 109893e | 2010-05-18 22:02:53 +0000 | [diff] [blame] | 21 | <h4 class="subsect">§1.3.1.(c) <span class="title">Overriding and implicit inheritance</span><a class="img" href="s1.3.1.c.html" |
| 22 | title="PermaLink to (c) Overriding and implicit inheritance"><img style="vertical-align:text-top;margin-left:5px;" src="../images/permalink.png" |
| 23 | alt="" /></a></h4> |
Stephan Herrmann | 0166441 | 2010-04-01 20:28:43 +0000 | [diff] [blame] | 24 | <p>If a team contains a role class definition by the same name as |
| 25 | a role defined in its super-team, |
| 26 | the new role class overrides the corresponding role from the super-team |
| 27 | and <strong>implicitly inherits</strong> all of its features. |
| 28 | Such relation is established only by name correspondence. |
| 29 | |
| 30 | </p> |
| 31 | <p>A role that overrides an inherited role should be marked with an <code>@Override</code> annotation. |
| 32 | A compiler should optionally flag a missing <code>@Override</code> annotation with a warning. |
| 33 | Conversely, it is an error if a role is marked with an <code>@Override</code> annotation but does not actually |
| 34 | override an inherited role. |
| 35 | |
| 36 | </p> |
| 37 | <p>It is an error to override a role class with an interface or vice versa. A final role cannot be overridden.<br /> |
| 38 | Unlike regular inheritance, <strong>constructors</strong> are also inherited |
| 39 | along implicit inheritance, and can be overridden just like normal methods. |
| 40 | |
| 41 | </p> |
| 42 | <div class="codecomment"> |
| 43 | 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 |
| 44 | <code>R1</code> in <code>S</code>. This is, because its enclosing team |
| 45 | <code>T</code> extends the team <code>S</code> (line 10) and the role |
| 46 | definition uses the same name <code>R1</code> (line 11). |
| 47 | Hence the attribute <code><strong>ok</strong></code> is available in the method |
| 48 | <code>m()</code> in <code>T.R1</code> (line 13). <code>T.R1</code> also overrides <code>S.R1</code> |
| 49 | which is marked by the <code>@Override</code> annotation in line 11. |
| 50 | |
| 51 | </div> |
| 52 | </div> |
| 53 | <table class="nav"> |
| 54 | <tr> |
| 55 | <td class="back"><a href="s1.3.1.b.html" rel="prev"><< §1.3.1.(b) Direct role acquisition</a></td> |
| 56 | <td class="top"><a href="index.html" rel="contents">↑ Table of Contents ↑</a></td> |
| 57 | <td class="next"><a href="s1.3.1.d.html" rel="next">§1.3.1.(d) Lack of subtyping >></a></td> |
| 58 | </tr> |
| 59 | </table> |
| 60 | <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> |
| 61 | </div> |
| 62 | <div id="footer"> |
Stephan Herrmann | 109893e | 2010-05-18 22:02:53 +0000 | [diff] [blame] | 63 | <hr /><a class="w3c img" href="http://jigsaw.w3.org/css-validator/check/referer" |
| 64 | 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" |
| 65 | width="88" /></a><address>© Stephan Herrmann, Christine Hundt, Marco Mosconi</address> |
Stephan Herrmann | 8f0fa31 | 2010-06-08 18:24:55 +0000 | [diff] [blame^] | 66 | OT/J version 1.3 — last modified: 2010-06-08 |
Stephan Herrmann | 0166441 | 2010-04-01 20:28:43 +0000 | [diff] [blame] | 67 | </div> |
| 68 | </body> |
| 69 | </html> |