| <!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="s6.2.d.html" rel="prev"><< §6.2.(d) Exceptions</a></td> |
| <td class="top"><a href="index.html" rel="contents">↑ Table of Contents ↑</a></td> |
| <td class="next"></td> |
| </tr> |
| </table> |
| <div class="breadcrumb"><a class="nav" href="s6.html" rel="section">§6 Object Teams API</a> > <a class="nav" href="s6.2.html" rel="section">§6.2 Other API Elements</a></div> |
| <div class="subsect depth3" id="s6.2.e"> |
| <h4 class="subsect">§6.2.(e) <span class="title">Role migration</span><a class="img" href="s6.2.e.html" title="PermaLink to (e) Role migration"><img style="vertical-align:text-top;margin-left:5px;" src="../images/permalink.png" |
| alt="" /></a></h4> |
| <p>The following interfaces can be used to enable role migration:</p> |
| <dl> |
| <dt><code>IBaseMigratable</code></dt> |
| <dd>This interface declares a method |
| <div class="listing plain"><pre> |
| <code><B> <b>void</b> migrateToBase(B otherBase)</code> </pre></div> |
| and instructs the compiler to generate an implementation of this method |
| for any bound role declaring <code>IBaseMigratable</code> as its super-interface.<br /> |
| The effect of calling <code>migrateToBase</code> on a role instance is to re-bind this role to a new base instance. |
| The base instance must be compatible to the role's base class (in order to avoid problems during lifting the |
| compiler may require the base to be of the exact type of the role's base class). |
| Passing <code>null</code> to this method causes an <code>NullPointerException</code> to be thrown. |
| </dd> |
| <dt><code>ITeamMigratable</code></dt> |
| <dd>This interface declares a method |
| <div class="listing plain"><pre> |
| <code><R> R<@otherTeam> migrateToTeam(<b>final</b> ITeam otherTeam)</code></pre></div> |
| and instructs the compiler to |
| generate an implementation of this method for any role declaring <code>ITeamMigratable</code> as its super-interface.<br /> |
| The effect of calling <code>migrateToTeam</code> on a role instance is to re-bind this role to become a contained part of a new team instance. |
| The team instance must be of the exact type of the role's enclosing team. |
| Passing <code>null</code> to this method causes a <code>NullPointerException</code> to be thrown.<br /><div class="note"> |
| <h5>Caveat:</h5> |
| This method intentionally breaks the rules of family polymorphism: any reference <code>R<@previousTeam> r</code> |
| which was established before migration will incorrectly imply that the role's enclosing team still is <code>previousTeam</code>, |
| which is no longer true after migration. |
| While this does not effect any method lookup (which is still safe), further assumptions based on a role's dependent type |
| are invalidated by team migration. The same holds for references from the migrating role to any sibling role instances.<br /> |
| If the rules of family polymorphism should be maintained one should just refrain from declaring <code>ITeamMigratable</code> |
| as a role's super-interface. |
| </div> |
| </dd> |
| </dl> |
| <p>For both methods the signature declared in the interface is over-generalized, yet the compiler performs the necessary checks |
| to |
| ensure that role, base and team instances are indeed compatible and additionally the return type of <code>migrateToTeam</code> |
| is checked as a self-type, i.e., it reflects the exact type of the call target. |
| </p> |
| </div> |
| <table class="nav"> |
| <tr> |
| <td class="back"><a href="s6.2.d.html" rel="prev"><< §6.2.(d) Exceptions</a></td> |
| <td class="top"><a href="index.html" rel="contents">↑ Table of Contents ↑</a></td> |
| <td class="next"></td> |
| </tr> |
| </table> |
| <div class="breadcrumb"><a class="nav" href="s6.html" rel="section">§6 Object Teams API</a> > <a class="nav" href="s6.2.html" rel="section">§6.2 Other API Elements</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 — last modified: 2010-06-08 |
| </div> |
| </body> |
| </html> |