blob: 40bfecf4e1e15b8b1d671fc1bf8addb2fde8f715 [file] [log] [blame]
<html>
<head>
<meta name="copyright" content="Copyright Stephan Herrmann 2014. This page is made available under the Eclipse Public License v1.0. For full details see http://www.eclipse.org/legal/epl-v10.html" />
<link rel=stylesheet type="text/css" href="../css/book.css">
<link rel=stylesheet type="text/css" href="otguide.css">
<title>Running Object Teams programs</title>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<h1>Selecting the target weaving scheme</h1>
<p>Running an OT/J application requires a byte code weaver for binding roles into their bases.
Since version 2.3, the OTDT ships with two distinct weavers with
the following properties:
</p>
<dl>
<dt><strong>OTRE</strong>:</dt>
<dd>This is the traditional <strong>load-time</strong>
weaver. This weaver has <strong>matured</strong> over many years, but
unfortunately, the underlying library <strong>BCEL</strong> is no
longer maintained and thus cannot handle class files from recent Java
versions. Up-to Java 7 this could be worked around, but Java 8 class
files contain several elements that this BCEL-based weaver cannot
handle.</dd>
<dt><strong>OTDRE</strong>:<dt>
<dd>The newer Object Teams Dynamic Runtime Environment has been developed
to enable even <strong>runtime weaving</strong>.
To make this work despite the fact that the JVM doesn't allow runtime-addition of new
fields or methods, this weaver inserts a few general hooks into every weavable class (at load-time).<br/>
This weaver is also interesting for weaving into <strong>Java 8</strong> class
files, as it is based on the library <strong>ASM</strong>, for which
a Java-8-enabled version already exists.</dd>
</dl>
<p>In short: For applications using Java 8, OTDRE is the only option.
At Java 7 or below, OTRE is still a good option, perhaps with better performance, still.</p>
<h2>Configuration</h2>
<h3>Project creation</h3>
<p>
Initial configuration of the target weaving scheme happens in the
<a href="project.html#settings">New Object Teams Project Wizard</a>.
</p>
<h3>Configuring an existing project</h3>
<p>
For existing projects, this option can be found in the project's properties
concerning the OT/J compiler:
</p>
<a href="images/screenshots/NN25/configure-compiler-weavingScheme.png"><img src="images/screenshots/NN25/configure-compiler-weavingScheme.png" width=519 alt="Selecting the weaving scheme to compile for"/></a>
<p>This configuration is evaluated by the compiler and when launching an OT/J application.
Since the <strong>OT/J compiler</strong> performs some preparation for the respective weaver,
it has to generate different byte code formats, depending on the targeted weaving scheme.
As a consequence, switching from one weaving scheme to the other requires a full
recompilation of all OT/J code involved. The runtime will detect if it encounters
any class files compiled for an incompatible weaving scheme, signaled by throwing
<code>UnsupportedClassVersionError</code>.
</p>
<h3>Running</h3>
<p>When launching an OT/J-enabled application the suitable weaving scheme will automatically
be selected based on the configuration of projects involved in the launch.
</p>
</body>
</html>