blob: d7b0bd70c77f725c3774ffc51af4970d19b3ad26 [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. It should be noted, however,
that the OTDRE is not as mature as the OTRE, both in terms of
complete coverage of all combinations of language features as well as
in terms of performance measurement (we simply have no large-scale
experience with the OTDRE, yet).</dd>
</dl>
<p>In short: for the time being the traditional OTRE is still the default weaver,
recommended for all productive use. For now the new OTDRE is needed only
when working with Java 8. It will be further improved in the near future
and may fully replace the OTRE in a future version.</p>
<h2>Configuration</h2>
<p>
Initial configuration of the target weaving scheme happens in the
<a href="project.html#settings">New Object Teams Project Wizard</a>.
The corresponding compiler option is intentionally <em>not</em> yet
surfaced in the project preferences, because for productive use
it is strongly encouraged to still use the traditional OTRE.
For experiments requiring to switch the target weaving scheme, please
open the file <code>.settings/org.eclipse.jdt.core.prefs</code>
in your project and edit/add the following line:
</p>
<pre> org.eclipse.objectteams.otdt.compiler.option.weaving_scheme=OTDRE</pre>
<p>
The above line enables the new OTDRE, whereas a value of "OTRE" switches back
to the traditional OTRE.
</p>
<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>
</body>
</html>