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:

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.
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.

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.


Project creation

Initial configuration of the target weaving scheme happens in the New Object Teams Project Wizard.

Configuring an existing project

For existing projects, this option can be found in the project's properties concerning the OT/J compiler:

Selecting the weaving scheme to compile for

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.


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.