jCLOS is a small object system with a metaobject protocol (MOP), similar to the Common Lisp Object System (CLOS). Written by Gregor Kiczales at Xerox PARC, the original implementation is in Scheme. This project is a port of Tiny-CLOS to Java. Comments of the Scheme implementation have been kept if they still applied.


This package is available via git:

    git clone http://www.foldr.org/~michaelw/projects/jclos.git

The original Scheme code is available from <ftp://ftp.parc.xerox.com/pub/mops/tiny/>.

A Common Lisp implementation of Tiny-CLOS (by Kiczales) can be found at <ftp://ftp.parc.xerox.com:/pub/openimplementations/oopsla93-tutorial/>

Another port to Common Lisp is MW-TINY-CLOS.

Additional information can also be found at <http://community.schemewiki.org/?Tiny-CLOS>.


Package jclos contains all jCLOS functionality. The main method contains some example code, which creates an object with two slots, an instance, and a method on the print generic function.

// Main
public static void main(String[] args) {
    System.out.println("JCLOS booted.");

    CLOSInstance POS = defineClass(null, null, 
            Arrays.asList(new DirectSlotDefn[]{
                    new DirectSlotDefn(Symbol.intern("x")),
                    new DirectSlotDefn(Symbol.intern("y"))

    CLOSInstance pos = make(POS);
    pos.setSlot(Symbol.intern("x"), 42);

    CLOSInstance print = makeGeneric();
              new StdCallable() {
                  public Object apply(Object[] args) {
                      System.out.println("'" + args[1] + "' is an OBJECT!");
                      return null;
    /* ... */

(It is probably evident that Java is sorely missing some kind of facility for syntactic abstraction.)

Tiny-CLOS is meant as tool to study the implementation of MOPs, so the "code is the documentation." User documentation is sparse, potential users are expected to be familiar with CLOS and its MOP. Other sources of information are:


Michael Weber <michaelw@foldr.org>, 2008