gnu.classpath
Class VMStackWalker

java.lang.Object
  extended by gnu.classpath.VMStackWalker

public final class VMStackWalker
extends Object


Constructor Summary
VMStackWalker()
           
 
Method Summary
static ClassLoader firstNonNullClassLoader()
          Walk up the stack and return the first non-null class loader.
static Class<?> getCallingClass()
          Classpath's Javadoc for this method is: Get the class associated with the method invoking the method invoking this method, or null if the stack is not that deep (e.g., invoked via JNI invocation API).
static Class<?> getCallingClass(int skip)
           
static ClassLoader getCallingClassLoader()
          Classpath's Javadoc for this method is: Get the class loader associated with the Class returned by getCallingClass(), or null if no such class exists or it is the boot loader.
static Class<?>[] getClassContext()
          Classpath's Javadoc for this method says: Get a list of all the classes currently executing methods on the Java stack.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VMStackWalker

public VMStackWalker()
Method Detail

firstNonNullClassLoader

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.

Returns:
the first non-null classloader on stack or null

getClassContext

public static Class<?>[] getClassContext()
Classpath's Javadoc for this method says:
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 called VMStackWalker.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

getCallingClass

public static Class<?> getCallingClass()
Classpath's Javadoc for this method is:
Get the class associated with the method invoking the method invoking this method, or null if the stack is not that deep (e.g., invoked via JNI invocation API). This method is an optimization for the expression getClassContext()[1] and should return the same result.

VM implementers are encouraged to provide a more efficient version of this method.


getCallingClass

public static Class<?> getCallingClass(int skip)

getCallingClassLoader

public static ClassLoader getCallingClassLoader()
Classpath's Javadoc for this method is:
Get the class loader associated with the Class returned by getCallingClass(), or null if no such class exists or it is the boot loader. This method is an optimization for the expression getClassContext()[1].getClassLoader() and should return the same result.