Skip to main content
Jump to: navigation, search

Object Teams Quick-Start

Revision as of 12:28, 26 February 2010 by (Talk | contribs) (Part one of this page)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This step-by-step Quick-Start guide should get you started with Object Teams in less than 15 minutes.

Installation of the OTDT (development environment)

Note that existing releases are still served from until we have clearance to upload to

  1. Prerequisites: Eclipse running on a JRE 1.5 or greater
    1. Tip: set -Xmx512m in eclipse.ini
  2. Fire up Eclipse and add our update site
  3. Select "Object Teams Development Tooling", install it and restart
    1. Ensure that Java compiler compliance level is set to 1.5 or greater
    2. Tip: Enable "Java Type Indicator" under Preferences->General->Appearance->Label Decorations

OT/J Hello World Example

Note: throughout this site links like OTJLD §0 refer to matching paragraphs in the OT/J Language Definition.

This most simple example of an OT/J Application demonstrates how easy it is to intercept a (private!) base method and adapt its behavior in a separate role class. The example makes use of role binding (OTJLD §2, replace callin (OTJLD §4), decapsulation (OTJLD §4.6) and unanticipated team activation (OTJLD §5.5).

  1. Start the New Project Wizard, select "Object Teams Project" and proceed as usual
  2. Create a new class base.Main with the following content:
    package base;
    public class Main {
        public static void main(String[] args) {
        private static void sayHello() {
            System.out.println("Hello World!");
  3. Create a run configuration of type "Java Application"
    1. Select base.Main as the main class
  4. Run this configuration. The console output should look like:
    Hello World!
  5. Create a new Team class aspect.MyTeam (e.g., using the New Team wizard) with the following content:
    package aspect;
    import base base.Main;
    public team class MyTeam {
        protected class MyRole playedBy Main {
            callin static void sayMore() {
                System.out.println("callin begins ...");
                System.out.println("callin ends ...");
            sayMore <- replace sayHello;
  6. Open the previously created run configuration
    1. On the JRE tab, make sure that "Enable OTRE" is checked (is default for an Object Teams Project)
    2. On the Team Activation tab, add aspect.MyTeam
  7. Run the configuration again. The console output should now look like:
    callin begins ...
    Hello World!
    callin ends ...

Back to the top