Package randoop.util

Class ReflectionExecutor


  • public final class ReflectionExecutor
    extends Object
    Static methods that executes the code of a ReflectionCode object.

    This class maintains an "executor" thread. Code is executed on that thread. If the code takes longer than the specified timeout, the thread is killed and a TimeoutException exception is reported.

    • Field Detail

      • usethreads

        public static boolean usethreads
        If true, Randoop executes each test in a separate thread and kills tests that take too long to finish, as determined by the --call-timeout command-line argument. Tests killed in this manner are not reported to the user, but are recorded in Randoop's log. Use the --log command-line option to make Randoop produce the log.

        Use this option if Randoop does not terminate, which is usually due to execution of code under test that results in an infinite loop or that waits for user input. The downside of this option is a BIG (order-of-magnitude) decrease in generation speed. The tests are not run in parallel, merely in isolation.

      • CALL_TIMEOUT_MILLIS_DEFAULT

        public static int CALL_TIMEOUT_MILLIS_DEFAULT
        Default for call_timeout, in milliseconds. Should only be accessed by checkOptionsValid().
      • call_timeout

        public static int call_timeout
        After this many milliseconds, a non-returning method call, and its associated test, are stopped forcefully. Only meaningful if --usethreads is also specified.
      • normal_exec_duration_nanos

        private static long normal_exec_duration_nanos
        The sum of durations for normal executions, in nanoseconds.
      • normal_exec_count

        private static int normal_exec_count
        The number of normal executions.
      • excep_exec_duration_nanos

        private static long excep_exec_duration_nanos
        The sum of durations for exceptional executions, in nanoseconds.
      • excep_exec_count

        private static int excep_exec_count
        The number of exceptional executions.
    • Constructor Detail

      • ReflectionExecutor

        private ReflectionExecutor()
    • Method Detail

      • resetStatistics

        public static void resetStatistics()
        Set statistics about normal and exceptional executions to zero.
      • normalExecs

        public static int normalExecs()
      • excepExecs

        public static int excepExecs()
      • normalExecAvgMillis

        public static double normalExecAvgMillis()
        The average normal execution time, in milliseconds.
      • excepExecAvgMillis

        public static double excepExecAvgMillis()
        The average exceptional execution time, in milliseconds.
      • executeReflectionCodeUnThreaded

        private static void executeReflectionCodeUnThreaded​(ReflectionCode code)
        Executes code.runReflectionCode() in the current thread.
        Parameters:
        code - the ReflectionCode to be executed