Fundamental Fields in Expressions

There is a very fundamental class Advice for the expressions used in filtering, tracing or monitoring and other aspects in commands.

public class Advice {

    private final ClassLoader loader;
    private final Class<?> clazz;
    private final ArthasMethod method;
    private final Object target;
    private final Object[] params;
    private final Object returnObj;
    private final Throwable throwExp;
    private final boolean isBefore;
    private final boolean isThrow;
    private final boolean isReturn;

    // getter/setter

Description for the variables in the class Advice:

loaderthe class loader for the current called class
clazzthe reference to the current called class
methodthe reference to the current called method
targetthe instance of the current called class
paramsthe parameters for the current call, which is an array (when there's no parameter, it will be an empty array)
returnObjthe return value from the current call - only available when the method call returns normally (isReturn==true), and null is for void return value
throwExpthe exceptions thrown from the current call - only available when the method call throws exception (isThrow==true)
isBeforeflag to indicate the method is about to execute. isBefore==true but isThrow==false and isReturn==false since it's no way to know how the method call will end
isThrowflag to indicate the method call ends with exception thrown
isReturnflag to indicate the method call ends normally without exception thrown

All variables listed above can be used directly in the OGNL expressionopen in new window. The command will not execute and exit if there's illegal OGNL grammar or unexpected variable in the expression.