blob: ad05fe84e336ada100408d3ce5e8d1360110d88f [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" />
6 <meta name="copyright"
7 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" />
8 <link rel="stylesheet" type="text/css" href="../css/ot.css" />
9 <link rel="stylesheet" type="text/css" href="../css/otjld.css" />
10 <title>OT/J Language Definition v1.3</title>
11 </head>
12 <body class="otdt">
13 <div id="content">
14 <table class="nav">
15 <tr>
16 <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>
17 <td class="top"><a href="index.html" rel="contents">&uarr;&nbsp;Table of Contents&nbsp;&uarr;</a></td>
18 <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>
19 </tr>
20 </table>
21 <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>
22 <div class="subsect depth4" id="s1.3.1.c">
23 <h4 class="subsect">&sect;1.3.1.(c)&nbsp;<span class="title">Overriding and implicit inheritance</span></h4>
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">&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">
63 <hr />
64 <address>&copy; Stephan Herrmann, Christine Hundt, Marco Mosconi</address>
65 OT/J version 1.3 &mdash; last modified: 2010-02-20
66 </div>
67 </body>
68</html>