Class BytecodeResult


  • public final class BytecodeResult
    extends Object
    Immutable outcome of a bytecode execution: terminal status, return value or exception, and optional statistics.
    • 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 object
        trace - 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 executed
        nanos - 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
      • 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
      • getStackTrace

        public List<String> getStackTrace()
        Returns:
        the stack trace