Package dalvik.system

Class VMStack


  • public final class VMStack
    extends Object
    Provides a limited interface to the Dalvik VM stack. This class is mostly used for implementing security checks.
    • Constructor Detail

      • VMStack

        public VMStack()
    • Method Detail

      • getCallingClassLoader

        public static ClassLoader getCallingClassLoader()
        Returns the defining class loader of the caller's caller.
        Returns:
        the requested class loader, or null if this is the bootstrap class loader.
      • getStackClass1

        public static Class<?> getStackClass1()
        Returns the class of the caller's caller.
        Returns:
        the requested class, or null.
      • getStackClass2

        public static Class<?> getStackClass2()
        Returns the class of the caller's caller's caller.
        Returns:
        the requested class, or null.
      • getClosestUserClassLoader

        public static ClassLoader getClosestUserClassLoader()
        Returns the first ClassLoader on the call stack that isn't the bootstrap class loader.
      • getThreadStackTrace

        public static StackTraceElement[] getThreadStackTrace​(Thread t)
        Retrieves the stack trace from the specified thread.
        Parameters:
        t - thread of interest
        Returns:
        an array of stack trace elements, or null if the thread doesn't have a stack trace (e.g. because it exited)
      • fillStackTraceElements

        public static int fillStackTraceElements​(Thread t,
                                                 StackTraceElement[] stackTraceElements)
        Retrieves a partial stack trace from the specified thread into the provided array.
        Parameters:
        t - thread of interest
        stackTraceElements - preallocated array for use when only the top of stack is desired. Unused elements will be filled with null values.
        Returns:
        the number of elements filled