Fully featured low overhead profiler for Java EE and Java SE platforms.
Monitoring and profiling solution for Gradle, Maven, Ant, JUnit and TestNG.
Easy to use performance and memory profiler for .NET framework.

Callback method parameter annotation @ReturnValue

Callback parameter annotated with @ReturnValue provides the instrumented method's return value.

In which callbacks can be used

Parameter annotated with @ReturnValue can be used in onReturn() only.

Declaration type

Parameter annotated with @ReturnValue can be declared as a reference type or as a primitive type.

If the callback parameter is declared as java.lang.Object, it will be assigned with object reference as is if the actual parameter type is a reference type, or with a boxed value if the actual parameter type is primitive.

If the callback parameter is declared as some reference type other than java.lang.Object, it will be assigned with the actual method parameter value only if it is declared as strictly the same type. Otherwise the callback parameter value will be null.

If the callback parameter is declared as a primitive type, it will be assigned with the actual method parameter value only if it is declared as strictly the same type. Otherwise it will be assigned with 0; no type conversions will be performed. For example, int will not be cast to long.

Type of callback parameter annotated with @ReturnValue Actual instrumented method return value type Resulting value of the callback parameter
java.lang.Object any reference type the value as is
any primitive type a boxed value
void null
some reference type T1 other than java.lang.Object same reference type T1 the value as is
any reference or primitive type T2 != T1 null
void null
some primitive type T1 same primitive type T1 the value as is
any reference or primitive type T2 != T1 0
void 0

Note: The type matching rules for @ReturnValue are similar to ones for @Param and differ from the rules for @This