- 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
Callbacks onUncaughtException() and onUncaughtExceptionExt()
To execute a code when method terminates because of an uncaught exception (a throwable),
define callback method onUncaughtException()
or onUncaughtExceptionExt()
in probe class.
You can omit these callback methods if uncaught exception handling is not needed for your probe.
Only one method named onUncaughtException()
, onUncaughtExceptionExt()
or onExit()
can exist in a probe class.
Difference between onUncaughtException() and onUncaughtExceptionExt()
onUncaughtException()
is intended to monitor possible uncaught exceptions
without changing the logic of instrumented code.
After the callback returns, the exception will be automatically re-thrown.
onUncaughtExceptionExt()
does not automatically re-throw
the original exception.
This provides an opportunity to alter instrumented code behavior
by suppressing the exception and, for a non-void method,
returning a value instead.
The capabilities provided with onUncaughtExceptionExt()
have more to do with debugging than with monitoring or profiling,
as they affect application logic.
Be very careful: inappropriate use can break the application.
Parameters
The callback can have any number of parameters, including zero.
Each of the parameters must be annotated with one of the following annotations:
- @Param
- @Params
- @This
- @ClassRef
- @MethodName
- @MethodParameterTypes
- @MethodSignature
- @OnEnterResult
- @ThrownException
Return type of onUncaughtException
onUncaughtException()
must be void.
Technically, onUncaughtException()
is called inside
try/finally block surrounding instrumented method body:
-
After
onUncaughtException()
returns, the exception will be automatically re-thrown -
If an uncaught exception happens inside
onUncaughtException()
body, it will be thrown instead of the original exception
The following pseudocode demonstrates how the callback works:
Before instrumentation:
ReturnType foo() {
bar(); // do something
return result;
}
After instrumentation with onUncaughtException()
:
ReturnType foo() {
try {
bar(); // do something
return result;
}
catch (Throwable e) {
SomeProbeClass.onUncaughtException(...);
throw e; // automatically re-throw original exception
}
}
Return type of onUncaughtExceptionExt
onUncaughtExceptionExt()
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.
The following pseudocode demonstrates how the callback works:
Before instrumentation:
ReturnType foo() {
bar(); // do something
return result;
}
After instrumentation with onUncaughtExceptionExt()
:
ReturnType foo() {
try {
bar(); // do something
return result;
}
catch (Throwable e) {
// may throw exception or return a value
return SomeProbeClass.onUncaughtExceptionExt(...); // return value must be ReturnType
}
}