DelphJ is a Java-based OO language (MorphJ with delegation features) that
eschews inheritance completely, in favor of a combination of class morphing and
(deep) delegation. DelphJ runs on top of the JVM and is based on the MorphJ
compiler. delphjc
is implemented via AST rewriting using JastAddJ. In a
nutshell the implementation of the compiler is based on two things:
- A runtime system that is implemented in a core class named
Reference
that implements the dynamic semantics described in the paper. - A rewrite system on-top the MorphJ compiler.
You can see differences between the original MorphJ implementation and DelphJ with the following git command:
git diff -w morphj..master
- Field declaration.
- New instance expression.
- Method declaration, adding one parameter with changed reference types.
- Dot accesses.
- Method invocation to a reflective invocation with self as first parameter.
- Exposing subobject field for path merging.
- Adding getData() method access when invoking method on subobject fields.
- Disambiguate package access to variable access.
- Variable declaration.
To build the compiler run ant with DelphJ's backend build.xml
ant -f ~/DelphJ/MJBackend/src/build.xml
The compiler runs via the delphjc
executable script (which must be part of the
PATH envirnment variable) and requires one more to be set which points to the
DelphJ root directory:
export mj=<path-to>/DelphJ
And one for the java classpath:
export CLASSPATH=$mj/MJBackend/src:$mj/MJBackend/thirdparty/asm-all-3.1.jar:/usr/share/java/junit4.jar
The compiler can be run via command prompt with the delphjc
command:
usage: delphjc [[-r | --rewritings ] | [-h] | [--whatif]] files
Description, examples and formal discussion of DelphJ:
MorphJ papers:
- Morphing: Structurally Shaping a Class by Reflecting on Others (TOPLAS)
- Expressive and Safe Static Reflection with MorphJ
- Morphing: Safely Shaping a Class in the Image of Others
- Morphing Software for Easier Evolution
This project is a work in progress and is based on our OOPSLA'13 paper. It is for demonstration purposes only.