A little bit of magic to speed up your code

What is ActiveSpecializer?

ActiveSpecializer is a lightweight library that automagically optimizes your code for JVM and makes it significantly faster. It is one of the ActiveJ technologies with no third-party dependencies, so it can be used as a stand-alone component.

Why ActiveSpecializer?

This simple example illustrates the core ActiveSpecializer 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 this automagically.

According to the benchmarks the original equation was operated in 69.938 ns, while the manually and automatically 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;


Ultimate flexibility

ActiveSpecializer goes far beyond arithmetic equations and can be used in complex use cases. For example, according to the benchmarks ActiveSpecializer makes ActiveInject DI library faster by third. To apply ActiveSpecializer to ActiveInject, simply add Injector.useSpecializer() before Injector instantiation.
ActiveSpecializer OFF
DirectScopebind (1 arg) - 310.3 ns/op
DirectScopebind (10 args) - 2420.3 ns/op
DirectScopebind (1 arg)
310.3 ns/op
DirectScopebind (10 args)
2420.3 ns/op
ActiveSpecializer ON
DirectScopebind (1 arg) - 209.7 ns/op
DirectScopebind (10 args) - 1545 ns/op
DirectScopebind (1 arg)
209.7 ns/op
DirectScopebind (10 args)
1545 ns/op

Add ActiveSpecializer to your project

You can add ActiveSpecializer to your project by importing its Maven repository.
These docs cover the most recent ActiveSpecializer release which is v2.2, published Sep 11, 2020 (see on Github).

Project background

ActiveSpecializer is one of the ActiveJ technologies that also include cloud solutions, powerful DI, lightning-fast serializers, bytecode generators and other standalone solutions that make up the ActiveJ ecosystem. To learn more, please visit the ActiveJ project homepage.