gnu.classpath.VMStackWalker

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The current gnu.classpath.VMStackWalker interface is inefficient.

Sun provide:

  sun.reflect.reflection.getCallerClass(int depth)

and for the same function we would do

  VMStackWalker.getClassContext()[depth];

You see the difference: Classpath's VMStackWalker enumerates the whole
stack, whereas Sun's only has to enumerate a few stack frames.  

I would like to add a new method to VMStackWalker that has exactly the
same interface as sun.reflect.reflection.getCallerClass.

This is an obvious reference implementation:

  static Class getCallerClass(int depth)
  {
    Class[] stack = getClassContext();
    if (depth < stack.length)
      return stack[depth];
    else
      return null;
  }

If we had this interface, it would reduce the number of places where
libgcj diverges from classpath, because in gcj we would be able to use
VMStackWalker rather than gcj's internal stacktrace machinery.  It
wouldn't work everywhere, but it woud be useful in a number of places.

Andrew.


[Index of Archives]     [Linux Kernel]     [Linux Cryptography]     [Fedora]     [Fedora Directory]     [Red Hat Development]

  Powered by Linux