Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
gnu.classpath.VMStackWalker
public final class VMStackWalker
extends Object
This class is only available to privileged code (i.e., code loaded by the bootstrap loader).
Method Summary | |
static ClassLoader |
|
static Class<T> |
|
static ClassLoader |
|
static Class<T>[] |
|
static ClassLoader |
|
Methods inherited from class java.lang.Object | |
clone , equals , extends Object> getClass , finalize , hashCode , notify , notifyAll , toString , wait , wait , wait |
public static ClassLoader firstNonNullClassLoader()
Walk up the stack and return the first non-null class loader. If there aren't any non-null class loaders on the stack, return null.
public static Class<T> getCallingClass()
Get the class associated with the method invoking the method invoking this method, ornull
if the stack is not that deep (e.g., invoked via JNI invocation API). This method is an optimization for the expressiongetClassContext()[1]
and should return the same result.When compiling to native code gcj translates calls to this method into calls to
getCallingClass(addr)
, withaddr
being the address of the method calling this method.getCallingClass(addr)
does not unwind the stack, so is therefore more efficient.
public static ClassLoader getCallingClassLoader()
Get the class loader associated with the Class returned bygetCallingClass()
, ornull
if no such class exists or it is the boot loader. This method is an optimization for the expressionVMStackWalker.getClassLoader(getClassContext()[1])
and should return the same result.When compiling to native code gcj translates calls to this method into calls to
getCallingClassLoader(addr)
, withaddr
being the address of the method calling this method.getCallingClassLoader(addr)
does not unwind the stack, so is therefore more efficient.
public static Class<T>[] getClassContext()
Get a list of all the classes currently executing methods on the Java stack.getClassContext()[0]
is the class associated with the currently executing method, i.e., the method that calledVMStackWalker.getClassContext()
(possibly through reflection). So you may need to pop off these stack frames from the top of the stack:
VMStackWalker.getClassContext()
Method.invoke()
- Returns:
- an array of the declaring classes of each stack frame
public static ClassLoader getClassLoader(Class<T> cl)
Retrieve the class's ClassLoader, ornull
if loaded by the bootstrap loader. I.e., this should return the same thing asjava.lang.VMClass.getClassLoader
. This duplicate version is here to work around access permissions.