ActiveJ Codegen is an efficient Java code generator with streamlined and simple API. It is built on top of ObjectWeb ASM and has zero-overhead performance. ActiveJ Codegen is widely utilised at ActiveJ Serializer, making it the fastest JVM-based serializer in the world. ActiveJ Codegen is one of the ActiveJ technologies, but it has minimal third-party dependencies and can be used as a stand-alone component.
- Utilizes powerful ASM library for code generation and manipulation
- Provides concise Expressions API that provides Lisp-like DSL for describing new classes
- Supports caching of generated classes
- Suitable for dynamic class generation based on runtime parameters (e.g. query processing)
- Supports relational algebra operations for individual items: aggregate functions, predicates, ordering, group-by, etc.
- Features automatic type inference
- Zero-overhead performance
- Support for Records (heterogeneous data containers)
Let's say that we want to create a class that implements
A generated class should simply print "Hello World" when
sayHello() method is called.
To generate such class programmatically we should use a
call(staticField(System.class, "out"), "println", value("Hello world")) expression.
This is how Expressions DSL looks like.
First, we access static field
System class. Then we call
println() method on it, passing value
"Hello world" as an argument.
This is equivalent to a
When a new instance of this class is created and
sayHello() method is called, the output is "Hello world" as expected.
This is merely a hint of what ActiveJ Codegen is capable of. For more information, please refer to examples or internal documentation.