Stephan Herrmann | db8aca5 | 2014-06-09 20:37:09 +0200 | [diff] [blame] | 1 | <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 Herrmann | 410656d | 2015-06-09 22:54:41 +0200 | [diff] [blame] | 12 | Since version 2.3, the OTDT ships with two distinct weavers with |
Stephan Herrmann | db8aca5 | 2014-06-09 20:37:09 +0200 | [diff] [blame] | 13 | 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 Herrmann | 88be4aa | 2016-05-28 22:53:02 +0200 | [diff] [blame] | 31 | a Java-8-enabled version already exists.</dd> |
Stephan Herrmann | db8aca5 | 2014-06-09 20:37:09 +0200 | [diff] [blame] | 32 | </dl> |
Stephan Herrmann | 88be4aa | 2016-05-28 22:53:02 +0200 | [diff] [blame] | 33 | <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 Herrmann | db8aca5 | 2014-06-09 20:37:09 +0200 | [diff] [blame] | 35 | |
| 36 | <h2>Configuration</h2> |
Stephan Herrmann | 88be4aa | 2016-05-28 22:53:02 +0200 | [diff] [blame] | 37 | <h3>Project creation</h3> |
Stephan Herrmann | db8aca5 | 2014-06-09 20:37:09 +0200 | [diff] [blame] | 38 | <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 Herrmann | db8aca5 | 2014-06-09 20:37:09 +0200 | [diff] [blame] | 41 | </p> |
Stephan Herrmann | 88be4aa | 2016-05-28 22:53:02 +0200 | [diff] [blame] | 42 | <h3>Configuring an existing project</h3> |
Stephan Herrmann | db8aca5 | 2014-06-09 20:37:09 +0200 | [diff] [blame] | 43 | <p> |
Stephan Herrmann | 88be4aa | 2016-05-28 22:53:02 +0200 | [diff] [blame] | 44 | For existing projects, this option can be found in the project's properties |
| 45 | concerning the OT/J compiler: |
Stephan Herrmann | db8aca5 | 2014-06-09 20:37:09 +0200 | [diff] [blame] | 46 | </p> |
Stephan Herrmann | 88be4aa | 2016-05-28 22:53:02 +0200 | [diff] [blame] | 47 | <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 Herrmann | db8aca5 | 2014-06-09 20:37:09 +0200 | [diff] [blame] | 49 | <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 Herrmann | 88be4aa | 2016-05-28 22:53:02 +0200 | [diff] [blame] | 57 | <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 Herrmann | db8aca5 | 2014-06-09 20:37:09 +0200 | [diff] [blame] | 61 | </body> |
| 62 | </html> |