Class Runtime


  • public class Runtime
    extends Object
    Runtime support for Chicory, the Daikon front end for Java. This class is a collection of methods; it should never be instantiated.
    • Field Detail

      • nonce

        public static AtomicInteger nonce
        Unique id for method entry/exit (so they can be matched up)
      • debug

        public static boolean debug
        debug flag
      • in_dtrace

        public static boolean in_dtrace
        Flag indicating that a dtrace record is currently being written used to prevent a call to instrumented code that occurs as part of generating a dtrace record (eg, toArray when processing lists or pure functions) from generating a nested dtrace record.
      • sample_start

        public static int sample_start
        Sample count at a call site to begin sampling. All previous calls will be recorded. Sampling starts at 10% and decreases by a factor of 10 each time another sample_start samples have been recorded. If sample_start is 0, then all calls will be recorded.
    • Method Detail

      • dontProcessPpts

        @Holding("Runtime.class")
        public static boolean dontProcessPpts()
      • startPure

        @Holding("Runtime.class")
        public static void startPure()
      • endPure

        @Holding("Runtime.class")
        public static void endPure()
      • enter

        public static void enter​(@Nullable Object obj,
                                 int nonce,
                                 int mi_index,
                                 Object[] args)
        Called when a method is entered.
        Parameters:
        obj - receiver of the method that was entered, or null if method is static
        nonce - nonce identifying which enter/exit pair this is
        mi_index - index in methods of the MethodInfo for this method
        args - array of arguments to method
      • exit

        public static void exit​(@Nullable Object obj,
                                int nonce,
                                int mi_index,
                                Object[] args,
                                Object ret_val,
                                int exitLineNum)
        Called when a method is exited.
        Parameters:
        obj - receiver of the method that was entered, or null if method is static
        nonce - nonce identifying which enter/exit pair this is
        mi_index - index in methods of the MethodInfo for this method
        args - array of arguments to method
        ret_val - return value of method, or null if method is void
        exitLineNum - the line number at which this method exited
      • initNotify

        public static void initNotify​(String className)
        Called by classes when they have finished initialization (i.e., their static initializer has completed).

        This functionality must be enabled by the flag Chicory.checkStaticInit. When enabled, this method should only be called by the hooks created in the Instrument class.

        Parameters:
        className - fully qualified class name
      • isInitialized

        public static boolean isInitialized​(String className)
        Return true iff the class with fully qualified name className has been initialized.
        Parameters:
        className - fully qualified class name
      • process_new_classes

        @Holding("Runtime.class")
        public static void process_new_classes()
        Writes out decl information for any new classes (those in the new_classes field) and removes them from that list.
      • incrementRecords

        public static void incrementRecords()
        Increment the number of records that have been printed.
      • noMoreOutput

        public static void noMoreOutput()
        Indicates that no more output should be printed to the dtrace file. The file is closed and iff dtraceLimitTerminate is true the program is terminated.
      • setDtraceOnlineMode

        @EnsuresNonNull("dtrace")
        public static void setDtraceOnlineMode​(int port)
      • setDtrace

        @EnsuresNonNull("dtrace")
        public static void setDtrace​(String filename,
                                     boolean append)
        Specify the dtrace file to which to write.
        Parameters:
        filename - to use as the data trace file
        append - whether to open dtrace file in append mode
      • setDtraceMaybe

        public static void setDtraceMaybe​(String default_filename)
        If the current data trace file is not yet set, then set it. The value of the DTRACEFILE environment variable is used; if that environment variable is not set, then the argument to this method is used instead.
        Parameters:
        default_filename - the file to maybe use as the data trace file
      • getClassInfoFromClass

        public static @Nullable ClassInfo getClassInfoFromClass​(Class<?> type)
        Gets the ClassInfo structure corresponding to type. Returns null if the class was not instrumented.
        Parameters:
        type - declaring class
        Returns:
        ClassInfo structure corresponding to type
      • quote

        public static String quote​(String orig)
        Quote \, ", \n, and \r characters in the target; return a new string.
      • fieldDescriptorToBinaryName

        public static String fieldDescriptorToBinaryName​(@FieldDescriptor String classname)
        Convert a classname from JVML format to Java format. For example, convert "[Ljava/lang/Object;" to "java.lang.Object[]".

        If the argument is not a field descriptor, returns it as is. This enables this method to be used on the output of Class.getName().