| <!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.1.b.html" rel="prev"><< §6.1.(b) Behavioral reflection</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.1.html" rel="section">§6.1 Reflection</a></div> |
| <div class="subsect depth3" id="s6.1.c"> |
| <h4 class="subsect">§6.1.(c) <span class="title">Class literals for roles</span><a class="img" href="s6.1.c.html" |
| title="PermaLink to (c) Class literals for roles"><img style="vertical-align:text-top;margin-left:5px;" src="../images/permalink.png" |
| alt="" /></a></h4> |
| <p>The Java syntax for so-called class literals, <code>MyClass<strong>.class</strong></code> |
| (see <a href="http://java.sun.com/docs/books/jls/second_edition/html/expressions.doc.html#251530" |
| class="ext">JLS §15.8.2</a>) |
| can be used for role types with slightly changed semantics: Role types are virtual types (<a href="s1.3.1.html" |
| title="§1.3.1 Acquisition and implicit inheritance of role classes" |
| class="sect">§1.3.1</a>) |
| that are bound dynamically (<a href="s1.3.1.e.html" title="§1.3.1.(e) Dynamic binding of types" |
| class="sect">§1.3.1.(e)</a>). This applies to role class literals, too. |
| From this follows the constraint that a role class literal can only be used within the non-static context of a team, |
| ie., for evaluating a role class literal an enclosing team instance must be in scope. |
| <br /> |
| Unlike regular type checking for role types, the class literal itself does not have a dependent type. |
| Thus type checking of calls to methods like <code>hasRole(Object, Class)</code> cannot detect, whether the <code>Class</code> instance |
| has actually been obtained from the correct team instance. Any attempt to pass a class that is not known |
| as a bound role within the given team results in an <code>IllegalArgumentException</code> at run-time. |
| |
| </p> |
| </div> |
| <table class="nav"> |
| <tr> |
| <td class="back"><a href="s6.1.b.html" rel="prev"><< §6.1.(b) Behavioral reflection</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.1.html" rel="section">§6.1 Reflection</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-05-18 |
| </div> |
| </body> |
| </html> |