- System requirements
- Profiler architecture
- Profiler installation
- Uninstall profiler
- Running the profiler
- Profiler activation
- Welcome screen
- Start profiling
- Profiling overhead
- Snapshots
- Solving performance problems
- CPU profiling
- Thread profiling
- Virtual threads support
- Object allocation profiling
- Memory profiling
- Monitor profiling
- Exception profiling
- Telemetry
- Probes: monitor events of various kinds
- Events in user interface
- Event inspections
- Built-in probes
- Probe classes
- Monitoring method invocation events
- Probe class annotation @MethodPattern
- Callback onEnter()
- Callback onReturn()
- Callback onExit()
- Callbacks onUncaughtException() and onUncaughtExceptionExt()
- Parameter annotation @Param
- Parameter annotation @Params
- Parameter annotation @This
- Parameter annotation @ClassRef
- Parameter annotation @MethodName
- Parameter annotation @MethodTimeMs
- Parameter annotation @MethodTimeNs
- Parameter annotation @MethodParameterTypes
- Parameter annotation @MethodSignature
- Parameter annotation @OnEnterResult
- Parameter annotation @ReturnValue
- Parameter annotation @ThrownException
- Probe application rules
- Data storage
- Inspections: automatic recognition of typical problems
- Automatically trigger actions on event
- Automatic deobfuscation
- Summary
- Filters
- Profiler command line
- Export of profiling results to external formats
- Profiler Java API
- Profiler HTTP API
- Settings
- Troubleshooting and FAQ
Callback onReturn()
To execute a code when method normally exits
(i.e. via return
or when a void method body execution completes),
define callback method onReturn()
in probe class.
You can omit onReturn()
method if it is not needed for your probe.
Only one method named onReturn()
or onExit()
can exist in a probe class.
Parameters
The callback can have any number of parameters, including zero.
Each of the parameters must be annotated with one of the following annotations:
- @ClassRef
- @MethodName
- @MethodParameterTypes
- @MethodSignature
- @MethodTimeMs
- @MethodTimeNs
- @OnEnterResult
- @Param
- @Params
- @ReturnValue
- @This
Return type
onReturn()
can be void or return a value.
If onReturn()
is void, the original return value will be returned.
The following pseudocode demonstrates how the callback works:
Before instrumentation:
ReturnType foo() {
bar(); // do something
return result;
}
After instrumentation with void onReturn()
:
ReturnType foo() {
bar(); // do something
SomeProbeClass.onReturn(...);
return result;
}
Declare onReturn()
as non-void to change the value
returned from the instrumented method.
If onReturn()
is non-void, its return type must
be the same as the return type of method to be instrumented.
If the types mismatch, the probe will not be applied to the method.
If needed, access the original return value with the help of @ReturnValue
annotated parameter, and optionally return the original return value or a different value.
The capability to change return value has more to do with debugging than with monitoring or profiling, as it affects application logic. Be very careful: inappropriate use can break the application.
After instrumentation with ReturnType onReturn()
:
ReturnType foo() {
bar(); // do something
return SomeProbeClass.onReturn(...); // return value must be ReturnType
}