blob: 6df1b95c5563892a45cd4b8a3410183f500bdf37 [file] [log] [blame]
Stephan Herrmann01664412010-04-01 20:28:43 +00001<!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 Herrmann01664412010-04-01 20:28:43 +00006 <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">&lt;&lt;&nbsp;&sect;1.3.1.(b)&nbsp;Direct role acquisition</a></td>
15 <td class="top"><a href="index.html" rel="contents">&uarr;&nbsp;Table of Contents&nbsp;&uarr;</a></td>
16 <td class="next"><a href="s1.3.1.d.html" rel="next">&sect;1.3.1.(d)&nbsp;Lack of subtyping&nbsp;&gt;&gt;</a></td>
17 </tr>
18 </table>
19 <div class="breadcrumb"><a class="nav" href="s1.html" rel="section">&sect;1&nbsp;Teams and Roles</a>&nbsp;&gt;&nbsp;<a class="nav" href="s1.3.html" rel="section">&sect;1.3&nbsp;Acquisition and implicit inheritance of role classes</a>&nbsp;&gt;&nbsp;<a class="nav" href="s1.3.1.html" rel="section">&sect;1.3.1&nbsp;Acquisition and implicit inheritance of role classes</a></div>
20 <div class="subsect depth4" id="s1.3.1.c">
Stephan Herrmann109893e2010-05-18 22:02:53 +000021 <h4 class="subsect">&sect;1.3.1.(c)&nbsp;<span class="title">Overriding and implicit inheritance</span><a class="img" href="s1.3.1.c.html"
22 title="PermaLink to (c)&nbsp;Overriding and implicit inheritance"><img style="vertical-align:text-top;margin-left:5px;" src="../images/permalink.png"
23 alt="" /></a></h4>
Stephan Herrmann01664412010-04-01 20:28:43 +000024 <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">&lt;&lt;&nbsp;&sect;1.3.1.(b)&nbsp;Direct role acquisition</a></td>
56 <td class="top"><a href="index.html" rel="contents">&uarr;&nbsp;Table of Contents&nbsp;&uarr;</a></td>
57 <td class="next"><a href="s1.3.1.d.html" rel="next">&sect;1.3.1.(d)&nbsp;Lack of subtyping&nbsp;&gt;&gt;</a></td>
58 </tr>
59 </table>
60 <div class="breadcrumb"><a class="nav" href="s1.html" rel="section">&sect;1&nbsp;Teams and Roles</a>&nbsp;&gt;&nbsp;<a class="nav" href="s1.3.html" rel="section">&sect;1.3&nbsp;Acquisition and implicit inheritance of role classes</a>&nbsp;&gt;&nbsp;<a class="nav" href="s1.3.1.html" rel="section">&sect;1.3.1&nbsp;Acquisition and implicit inheritance of role classes</a></div>
61 </div>
62 <div id="footer">
Stephan Herrmann109893e2010-05-18 22:02:53 +000063 <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>&copy; Stephan Herrmann, Christine Hundt, Marco Mosconi</address>
Stephan Herrmann8f0fa312010-06-08 18:24:55 +000066 OT/J version 1.3 &mdash; last modified: 2010-06-08
Stephan Herrmann01664412010-04-01 20:28:43 +000067 </div>
68 </body>
69</html>