日本語

DominoJ: An extension to Java for supporting method slots

The DominoJ language

Introduction

We extend methods to a new language construct: method slots, which supporting methods, events, and advices. A method slot is a closure array and is an object's property like a field. When a method slot is called, all closures in it are executed in order.

DominoJ replaces a method in plain Java with a method slot while is fully compatible with plain Java.

Syntax

The only syntax added by DominoJ:

<expr>.<methodslot> <operator> <expr>.<methodslot>;

where <expr> is any Java expression returning an object or class name if the following <methodslot> is static. <operator> can be one of =, ^=, +=, -=.

The operator += creates a closure calling the method slot on the righ-hand side and appends the closure to the end of the array of the method slot on the left-hand side. For example:

s.setX += o.update;

When the method slot s.setX is called, the body (default closure) of s.setX is executed and then the method slot o.update is called.

The operator ^= means that inserting the closure at the beginning, the operator = means that clearing all and then adding the closure, and the operator -= means that removing all closures containing the call to the method slot at the right-hand side.

The declaration of method slots is the same as methods except the body is optional. In other words, the following declaration is accepted:

public void setX(int nx);

For details, please refer to the publications.

Publications

  1. Method Slots: Supporting Methods, Events, and Advices by a Single Language Construct
    YungYu Zhuang and Shigeru Chiba
    In proceedings of the 12th annual international conference on Aspect-Oriented Software Development (AOSD'13), pp.197-208, March 2013.
    Research Results track
    Get Copy Slides
  2. Supporting Methods and Events by An Integrated Abstraction
    YungYu Zhuang and Shigeru Chiba
    9th Workshop on Reflection, AOP and Meta-Data for Software Evolution (RAM-SE'12)
    co-located with ECOOP'12, Beijing, China, 2012 June 13
    Get Copy
  3. Applying DominoJ to GoF Design Patterns
    YungYu Zhuang and Shigeru Chiba
    Dept. of Math. and Comp. Sciences Research Reports C-277,
    Tokyo Institute of Technology, December, 2011.
    Get Copy

The DominoJ compiler

Download

Usage

To compile a source file written in DominoJ:

java -jar DominoJCompiler.jar MyClass.java

The execution is the same as other Java programs.

java -cp dominoj.jar:. MyClass

By default all method-like declarations except the main method will be regarded as method slots and transformed by the compiler. The annotation @MethodSlot(boolean) can be used to specify a method-like declaration should be transformed or not.

Known issues

Extensions

The reactive extension: ReactiveDominoJ