Selecting the target weaving scheme

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:

OTRE:
This is the traditional load-time weaver. This weaver has matured over many years, but unfortunately, the underlying library BCEL 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.
OTDRE:
The newer Object Teams Dynamic Runtime Environment has been developed to enable even runtime weaving. 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).
This weaver is also interesting for weaving into Java 8 class files, as it is based on the library ASM, 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).

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.

Configuration

Initial configuration of the target weaving scheme happens in the New Object Teams Project Wizard. The corresponding compiler option is intentionally not 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 .settings/org.eclipse.jdt.core.prefs in your project and edit/add the following line:

    org.eclipse.objectteams.otdt.compiler.option.weaving_scheme=OTDRE

The above line enables the new OTDRE, whereas a value of "OTRE" switches back to the traditional OTRE.

This configuration is evaluated by the compiler and when launching an OT/J application. Since the OT/J compiler 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 UnsupportedClassVersionError.