blob: 528048c343a2b69e077f95e502f880ab177a5894 [file] [log] [blame]
<!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</title>
</head>
<body class="otdt">
<div id="content">
<table class="nav">
<tr>
<td class="back"><a id="top"></a><a href="s1.3.1.html" rel="prev">&lt;&lt;&nbsp;&sect;1.3.1&nbsp;Acquisition and implicit inheritance of role classes</a></td>
<td class="top"><a href="index.html" rel="contents">&uarr;&nbsp;Table of Contents&nbsp;&uarr;</a></td>
<td class="next"></td>
</tr>
</table>
<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></div>
<div class="sect depth3" id="s1.3.2">
<h3 class="sect">&sect;1.3.2&nbsp;Regular role inheritance<a class="img" href="s1.3.2.html"
title="PermaLink to &sect;1.3.2&nbsp;Regular role inheritance"><img style="vertical-align:text-top;margin-left:5px;" src="../images/permalink.png"
alt="" /></a></h3>
<p>In addition to implicit inheritance, roles may also inherit using
the standard Java keyword <code>extends</code>. These restrictions apply:
</p>
<div class="subsect depth4" id="s1.3.2.a">
<h4 class="subsect">(a)&nbsp;<span class="title">Super-class restrictions</span><a class="img" href="s1.3.2.a.html"
title="PermaLink to (a)&nbsp;Super-class restrictions"><img style="vertical-align:text-top;margin-left:5px;" src="../images/permalink.png"
alt="" /></a></h4>
<p>If the super-class of a role is again a role it must be a direct role of
an enclosing team
This rule is simply enforced by disallowing type anchors in the
<code>extends</code> clause
(see <a href="s1.2.2.g.html" title="&sect;1.2.2.(g)&nbsp;Legal contexts"
class="sect">&sect;1.2.2.(g)</a>).
As an effect, the super-class may never be more deeply nested than the sub-class.
</p>
</div>
<div class="subsect depth4" id="s1.3.2.b">
<h4 class="subsect">(b)&nbsp;<span class="title">Inheriting and overriding the extends clause</span><a class="img" href="s1.3.2.b.html"
title="PermaLink to (b)&nbsp;Inheriting and overriding the extends clause"><img style="vertical-align:text-top;margin-left:5px;" src="../images/permalink.png"
alt="" /></a></h4>
<p>If a role overrides another role by implicit inheritance, it may
change the inherited <code>extends</code> clause
(see <a href="s1.3.1.g.html"
title="&sect;1.3.1.(g)&nbsp;Implicitly inheriting super-types"
class="sect">&sect;1.3.1.(g)</a> above) only if the new super-class
is a sub-class of the class in the overridden extends clause.
I.e., an implicit sub-role may <em>specialize</em> the extends clause of its
implicit super-role.
</p>
</div>
<div class="subsect depth4" id="s1.3.2.c">
<h4 class="subsect">(c)&nbsp;<span class="title">Constructors and overridden 'extends' </span><a class="img" href="s1.3.2.c.html"
title="PermaLink to (c)&nbsp;Constructors and overridden 'extends' "><img style="vertical-align:text-top;margin-left:5px;" src="../images/permalink.png"
alt="" /></a></h4>
<p>Each constructor of a role class that overrides the extends clause of its
implicit super-role must invoke a constructor of this newly introduced
explicit super-class. Thus it may not use a <code>tsuper</code> constructor
(see <a href="s2.4.2.html"
title="&sect;2.4.2&nbsp;Role creation via a regular constructor"
class="sect">&sect;2.4.2</a>).
</p>
</div>
<div class="subsect depth4" id="s1.3.2.d">
<h4 class="subsect">(d)&nbsp;<span class="title">Adding implemented interfaces</span><a class="img" href="s1.3.2.d.html"
title="PermaLink to (d)&nbsp;Adding implemented interfaces"><img style="vertical-align:text-top;margin-left:5px;" src="../images/permalink.png"
alt="" /></a></h4>
<p><code>implements</code> declarations are additive, i.e., an implicit
sub-role may add more interfaces but has to implement all interfaces of
its implicit super-role, too.
</p>
</div>
<div class="subsect depth4" id="s1.3.2.e">
<h4 class="subsect">(e)&nbsp;<span class="title">Visibility of inherited methods</span><a class="img" href="s1.3.2.e.html"
title="PermaLink to (e)&nbsp;Visibility of inherited methods"><img style="vertical-align:text-top;margin-left:5px;" src="../images/permalink.png"
alt="" /></a></h4>
<p>
When a role inherits non-public methods from a regular class (as its super class),
these methods are considered as private for the role, i.e., they can only be
accessed in an unqualified method call <code>m()</code> using the implicit receiver <code>this</code>.
</p>
</div>
</div>
<table class="nav">
<tr>
<td class="back"><a href="s1.3.1.html" rel="prev">&lt;&lt;&nbsp;&sect;1.3.1&nbsp;Acquisition and implicit inheritance of role classes</a></td>
<td class="top"><a href="index.html" rel="contents">&uarr;&nbsp;Table of Contents&nbsp;&uarr;</a></td>
<td class="next"></td>
</tr>
</table>
<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></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>&copy; Stephan Herrmann, Christine Hundt, Marco Mosconi</address>
OT/J version 1.3 &mdash; last modified: 2011-05-12
</div>
</body>
</html>