Class BytecodeResult
- java.lang.Object
-
- com.tonic.analysis.execution.core.BytecodeResult
-
public final class BytecodeResult extends Object
Immutable outcome of a bytecode execution: terminal status, return value or exception, and optional statistics.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classBytecodeResult.StatusTerminal condition of an execution.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static BytecodeResultcompleted(ConcreteValue value)Creates a result for an execution that completed normally.static BytecodeResultdepthLimit(int depth)Creates a result for an execution aborted by the call depth limit.static BytecodeResultexception(ObjectInstance ex, List<String> trace)Creates a result for an execution that ended with an unhandled exception.ObjectInstancegetException()longgetExecutionTimeNanos()longgetInstructionsExecuted()ConcreteValuegetReturnValue()List<String>getStackTrace()BytecodeResult.StatusgetStatus()booleanhasException()static BytecodeResultinstructionLimit(long count)Creates a result for an execution aborted by the instruction budget.static BytecodeResultinterrupted()Creates a result for an execution stopped by an interrupt request.booleanisSuccess()StringtoString()BytecodeResultwithStatistics(long instructions, long nanos)Copies this result with execution statistics attached.
-
-
-
Method Detail
-
completed
public static BytecodeResult completed(ConcreteValue value)
Creates a result for an execution that completed normally.- Parameters:
value- the return value- Returns:
- the completed result
-
exception
public static BytecodeResult exception(ObjectInstance ex, List<String> trace)
Creates a result for an execution that ended with an unhandled exception.- Parameters:
ex- the thrown exception objecttrace- stack trace lines, may be null- Returns:
- the exception result
- Throws:
IllegalArgumentException- if ex is null
-
interrupted
public static BytecodeResult interrupted()
Creates a result for an execution stopped by an interrupt request.- Returns:
- the interrupted result
-
instructionLimit
public static BytecodeResult instructionLimit(long count)
Creates a result for an execution aborted by the instruction budget.- Parameters:
count- the number of instructions executed- Returns:
- the instruction-limit result
-
depthLimit
public static BytecodeResult depthLimit(int depth)
Creates a result for an execution aborted by the call depth limit.- Parameters:
depth- the depth at which execution stopped- Returns:
- the depth-limit result
-
withStatistics
public BytecodeResult withStatistics(long instructions, long nanos)
Copies this result with execution statistics attached.- Parameters:
instructions- number of instructions executednanos- elapsed execution time in nanoseconds- Returns:
- a new result carrying the statistics
-
isSuccess
public boolean isSuccess()
- Returns:
- true if the status is COMPLETED
-
hasException
public boolean hasException()
- Returns:
- true if an exception was recorded
-
getStatus
public BytecodeResult.Status getStatus()
- Returns:
- the status
-
getReturnValue
public ConcreteValue getReturnValue()
- Returns:
- the return value
-
getException
public ObjectInstance getException()
- Returns:
- the exception
-
getInstructionsExecuted
public long getInstructionsExecuted()
- Returns:
- the instructions executed
-
getExecutionTimeNanos
public long getExecutionTimeNanos()
- Returns:
- the execution time nanos
-
-