Comparison Benchmark
First Test: the library
BCEL and
Javassist are
involved in this test; javassist has been used in its two different
forms: high level with source compilation, and low level with
instruction manual insertion. Both BCEL and JDasm are used to low
level manipulate the bytecode.
The test has been performed on a
laptop Centrino 1600 Mhz with 512 Mb of ram.
The main purpose was to create an
Hallo World class from scratch
by using the library's api: here's the code of the four Hallo World class
builder:
The class created from scratch will be similiar to
this
and its structure will have:
- an empty constructor with local variable attribute
- a public static main method, which asks for a name and prints it: the asking part is
protected by a try-block. The method has a local variable attribute
- a source file attribute
The result of the creation is an equal class in each case but the low level
implementation of javassist: we were unable to add the local variable attribute to
the code of the main method. Nevertheless such attribute is created and added
to the method.