Package dalvik.system
Class VMStack
java.lang.Object
dalvik.system.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 Summary
Constructors Constructor Description VMStack() -
Method Summary
Modifier and Type Method Description static intfillStackTraceElements(Thread t, StackTraceElement[] stackTraceElements)Retrieves a partial stack trace from the specified thread into the provided array.static ClassLoadergetCallingClassLoader()Returns the defining class loader of the caller's caller.static Class<?>[]getClasses(int maxDepth)Creates an array of classes from the methods at the top of the stack.static ClassLoadergetClosestUserClassLoader(ClassLoader bootstrap, ClassLoader system)Returns the first ClassLoader on the call stack that isn't either of the passed-in ClassLoaders.static Class<?>getStackClass2()Returns the class of the caller's caller's caller.static StackTraceElement[]getThreadStackTrace(Thread t)Retrieves the stack trace from the specified thread.
-
Constructor Details
-
VMStack
public VMStack()
-
-
Method Details
-
getCallingClassLoader
Returns the defining class loader of the caller's caller.- Returns:
- the requested class loader, or
nullif this is the bootstrap class loader.
-
getStackClass2
Returns the class of the caller's caller's caller.- Returns:
- the requested class, or
null.
-
getClasses
Creates an array of classes from the methods at the top of the stack. We continue until we reach the bottom of the stack or exceed the specified maximum depth.The topmost stack frame (this method) and the one above that (the caller) are excluded from the array. Frames with java.lang.reflect classes are skipped over.
The classes in the array are the defining classes of the methods.
This is similar to Harmony's VMStack.getClasses, except that this implementation doesn't have a concept of "privileged" frames.
- Parameters:
maxDepth- maximum number of classes to return, or -1 for all- Returns:
- an array with classes for the most-recent methods on the stack
-
getClosestUserClassLoader
Returns the first ClassLoader on the call stack that isn't either of the passed-in ClassLoaders. -
getThreadStackTrace
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
Retrieves a partial stack trace from the specified thread into the provided array.- Parameters:
t- thread of intereststackTraceElements- 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
-