The sprintabout

Rationnal

The sprintabout is a really fast implementation of the visitor pattern concept.
It's a 100% pure Java library that add multi-dispatch (with a single parameter)
to Java without changing the compiler or the Java Virtual Machine.
The sprintabout makes dispatch code more readable, understandable and
less error prone by avoiding cascade of instanceof on argument type.
The semantics of the sprintabout is greatly inspired of its little cousin of the
runabout.

Performance

The sprintabout is really, really fast.
In server mode (using c2 compiler), the sprintabout is faster
than the visitor pattern and even faster than a simple dispatch using
dedicated method.
In client mode, the sprintabout is 30% to 100% faster than the
runabout depending on the class hierachy.

Comparison table

Little comparison between the runabout and the sprintabout :

Runabout

Sprintabout

License

GPL

LGPL

Inheritance

fixed

free

Creation

free

fixed,need a default constructor

Return type

no

yes

Method: modifiers

public

all modifiers but private

Method: static

no

yes

ThreadSafe

yes

yes

JDK compatibility

1.2

1.5

Share Type states

newly type states are thread specific

all states between all threads

Technique

generic code + dedicated method call

dedicated code(no generic part, avoid some cast)

Download

Current source of the sprintabout implementation :
sprintabout-src.zip
In order to work, the sprintabout relies on version 3.0 of ASM framework.
ASM is tiny an efficient bytecode manipulation framework.
You can download it here.