blob: 40bfecf4e1e15b8b1d671fc1bf8addb2fde8f715 [file] [log] [blame]
Stephan Herrmanndb8aca52014-06-09 20:37:09 +02001<html>
2 <head>
3 <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" />
4 <link rel=stylesheet type="text/css" href="../css/book.css">
5 <link rel=stylesheet type="text/css" href="otguide.css">
6 <title>Running Object Teams programs</title>
7 <META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
8 </head>
9 <body>
10 <h1>Selecting the target weaving scheme</h1>
11 <p>Running an OT/J application requires a byte code weaver for binding roles into their bases.
Stephan Herrmann410656d2015-06-09 22:54:41 +020012 Since version 2.3, the OTDT ships with two distinct weavers with
Stephan Herrmanndb8aca52014-06-09 20:37:09 +020013 the following properties:
14 </p>
15 <dl>
16 <dt><strong>OTRE</strong>:</dt>
17 <dd>This is the traditional <strong>load-time</strong>
18 weaver. This weaver has <strong>matured</strong> over many years, but
19 unfortunately, the underlying library <strong>BCEL</strong> is no
20 longer maintained and thus cannot handle class files from recent Java
21 versions. Up-to Java 7 this could be worked around, but Java 8 class
22 files contain several elements that this BCEL-based weaver cannot
23 handle.</dd>
24 <dt><strong>OTDRE</strong>:<dt>
25 <dd>The newer Object Teams Dynamic Runtime Environment has been developed
26 to enable even <strong>runtime weaving</strong>.
27 To make this work despite the fact that the JVM doesn't allow runtime-addition of new
28 fields or methods, this weaver inserts a few general hooks into every weavable class (at load-time).<br/>
29 This weaver is also interesting for weaving into <strong>Java 8</strong> class
30 files, as it is based on the library <strong>ASM</strong>, for which
Stephan Herrmann88be4aa2016-05-28 22:53:02 +020031 a Java-8-enabled version already exists.</dd>
Stephan Herrmanndb8aca52014-06-09 20:37:09 +020032 </dl>
Stephan Herrmann88be4aa2016-05-28 22:53:02 +020033 <p>In short: For applications using Java 8, OTDRE is the only option.
34 At Java 7 or below, OTRE is still a good option, perhaps with better performance, still.</p>
Stephan Herrmanndb8aca52014-06-09 20:37:09 +020035
36 <h2>Configuration</h2>
Stephan Herrmann88be4aa2016-05-28 22:53:02 +020037 <h3>Project creation</h3>
Stephan Herrmanndb8aca52014-06-09 20:37:09 +020038 <p>
39 Initial configuration of the target weaving scheme happens in the
40 <a href="project.html#settings">New Object Teams Project Wizard</a>.
Stephan Herrmanndb8aca52014-06-09 20:37:09 +020041 </p>
Stephan Herrmann88be4aa2016-05-28 22:53:02 +020042 <h3>Configuring an existing project</h3>
Stephan Herrmanndb8aca52014-06-09 20:37:09 +020043 <p>
Stephan Herrmann88be4aa2016-05-28 22:53:02 +020044 For existing projects, this option can be found in the project's properties
45 concerning the OT/J compiler:
Stephan Herrmanndb8aca52014-06-09 20:37:09 +020046 </p>
Stephan Herrmann88be4aa2016-05-28 22:53:02 +020047 <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>
48
Stephan Herrmanndb8aca52014-06-09 20:37:09 +020049 <p>This configuration is evaluated by the compiler and when launching an OT/J application.
50 Since the <strong>OT/J compiler</strong> performs some preparation for the respective weaver,
51 it has to generate different byte code formats, depending on the targeted weaving scheme.
52 As a consequence, switching from one weaving scheme to the other requires a full
53 recompilation of all OT/J code involved. The runtime will detect if it encounters
54 any class files compiled for an incompatible weaving scheme, signaled by throwing
55 <code>UnsupportedClassVersionError</code>.
56 </p>
Stephan Herrmann88be4aa2016-05-28 22:53:02 +020057 <h3>Running</h3>
58 <p>When launching an OT/J-enabled application the suitable weaving scheme will automatically
59 be selected based on the configuration of projects involved in the launch.
60 </p>
Stephan Herrmanndb8aca52014-06-09 20:37:09 +020061</body>
62</html>