Skip to main content


ActiveJ Specializer is an innovative technology for improving class runtime performance for the JVM. It is one of the ActiveJ technologies that has no third-party dependencies, so it can be used as a stand-alone component.

How it works?

ActiveJ Specializer uses ASM library to automatically convert class instances into specialized static classes, and class instance fields into baked-in static fields. This enables a wide variety of JVM optimizations for static classes that are not possible otherwise: dead code elimination, aggressively inlining methods, and static constants. According to our measures, in some cases speedups can reach 30%-50%.

Why ActiveJ Specializer?

This simple example illustrates the core ActiveJ Specializer concept. Suppose there is an INT_UNARY_OPERATOR that can be simplified. INT_UNARY_OPERATOR_SPECIALIZED specializes the equation similarly to the INT_UNARY_OPERATOR_SPECIALIZED_MANUALLY, but does so automagically.

According to the benchmarks the original equation was processed in 69.938 ns, while manual and automatic specialized took only 26.533 ns and 26.691 ns, respectively.

static IntUnaryOperator INT_UNARY_OPERATOR =
new IntUnaryOperatorProduct(
new IntUnaryOperatorSum(
new IntUnaryOperatorSum(
new IntUnaryOperatorIdentity(),
new IntUnaryOperatorConst(5)),
new IntUnaryOperatorConst(-5)),
new IntUnaryOperatorConst(-1));

new IntUnaryOperator() {
public int applyAsInt(int x) {
return -x;


High flexibility

ActiveJ Specializer goes far beyond arithmetic equations and can be used in complex scenarios. For example, according to benchmarks, ActiveJ Specializer makes the ActiveJ Inject DI library one-third faster. To apply ActiveJ Specializer to ActiveJ Inject, simply add Injector.useSpecializer() before instantiating Injector.

Add ActiveJ Specializer to your project

You can add ActiveJ Specializer to your project by importing its Maven repository. These docs cover the most recent release of ActiveJ Specializer v6.0-beta2 (see on Github or Maven).