1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?xml version="1.0" encoding="UTF-8" standalone="no"?>
- <!DOCTYPE html><html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xmlns:m="http://www.w3.org/1998/Math/MathML" xmlns:pls="http://www.w3.org/2005/01/pronunciation-lexicon" xmlns:ssml="http://www.w3.org/2001/10/synthesis" xmlns:svg="http://www.w3.org/2000/svg">
- <head>
- <title>Other Java features</title>
- <link rel="stylesheet" type="text/css" href="docbook-epub.css"/>
- <link rel="stylesheet" type="text/css" href="kawa.css"/>
- <script src="kawa-ebook.js" type="text/javascript"/>
- <meta name="generator" content="DocBook XSL-NS Stylesheets V1.79.1"/>
- <link rel="prev" href="tutorial-Classes.xhtml" title="Classes"/>
- <link rel="next" href="pt01.xhtml" title="Part . Reference Documentation"/>
- </head>
- <body>
- <header/>
- <section class="sect1" title="Other Java features" epub:type="subchapter" id="Tutorial---Other-Java-features">
- <div class="titlepage">
- <div>
- <div>
- <h2 class="title" style="clear: both">Other Java features</h2>
- </div>
- </div>
- </div>
- <h3 id="idm139667880338016">Import</h3>
- <p>The <code class="literal">import</code> form can be used to avoid having to write
- fully-qualified class names. For example:
- </p>
- <pre class="screen">(import (class java.util
- Map
- (HashMap HMap)))
- </pre>
- <p>This defines aliases for two classes in the <code class="literal">java.util</code> package,
- one with renaming:
- <code class="literal">Map</code> is an alias for <code class="literal">java.util.Map</code>,
- and <code class="literal">HMap</code> is an alias for <code class="literal">java.util.HashMap</code>.
- </p>
- <p>The <code class="literal">class</code> keyword is needed because the <code class="literal">import</code>
- form is also used for Kawa’s module system.
- See <a class="link" href="FAQs.xhtml#importing-class-names">importing-class-names</a> and <a class="link" href="Importing.xhtml" title="Importing from a library">Importing</a> for details.
- </p>
- <h3 id="idm139667880330784">Synchronized blocks</h3>
- <p>You can use a <code class="literal">synchronized</code> expression:
- </p>
- <pre class="screen">(synchronized obj form1 ... formn)
- </pre>
- <p>This waits until it can get an exclusive lock on <em class="replaceable"><code>obj</code></em>
- and then evaluates <em class="replaceable"><code>form1</code></em> through <em class="replaceable"><code>formn</code></em>.
- Unlike Java, this is an expression and returns the value of <em class="replaceable"><code>formn</code></em>.
- </p>
- <h3 id="idm139667880326704">Annotations</h3>
- <p>You can write annotation declarations - see <a class="link" href="Annotations.xhtml" title="Annotations of declarations">Annotations</a> for details.
- </p>
- <p>Kawa does not yet support annotations on types,
- or declaring new annotation classes.
- </p>
- </section>
- <footer>
- <div class="navfooter">
- <p>
- Up: <a accesskey="u" href="tutorial-index.xhtml">Kawa Scheme Tutorial</a></p>
- <p>
- Previous: <a accesskey="p" href="tutorial-Classes.xhtml">Classes</a></p>
- </div>
- </footer>
- </body>
- </html>
|