libgcj merging and VMStackWalker

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

 



Hi there,

Am Dienstag, den 16.05.2006, 09:29 +0200 schrieb Jeroen Frijters:
> Bryce McKinlay wrote:
> > GetCallingClass(Class) is intended for situations where you 
> > really want the caller of an external API into the class,
> > but due to overloaded methods or inlining may have an
> > indeterminate number of frames between the external method
> > and the site at which GetCallingClass() is called. 
> > java.lang.reflect and ResourceBundle are two examples where 
> > it is useful - we never want ResourceBundle.class or
> > Field.class, for example, to be returned there.
> 
> None of the above really applies to VMStackWalker.getCallingClass(). It
> has well defined semantics and requires no hacks or workarounds, only a
> VM that can reliably walk the stack (i.e. know which frames are non-Java
> and prevent inlining from losing frames).
> 
> If gcj cannot reliably walk the stack at the moment, I suggest modifying
> the code generator to add the class argument to the
> VMStackWalker.getCallingClass(), instead of muddling up the VM interface
> with that.

Here (@Aicas) we faced a similar problem as described by Tom. We came up
with another possible (but similar) solution, which doesn't 'muddle up'
the VM interface (ok, depends on your meaning of 'muddle up', it adds a
new method with -IMO - also clearly defined semantics). It has the added
advantage that it also returns the method name, which is very useful in
the logging API.

For now I send the signature and description of the new method, if there
is interest, I'll post a complete patch:

/**
 * Gets the class and method name of the first method outside the class
that 
   * actually called this method. This method skips over all methods in
the 
   * direct calling class. The basic idea is to start at the first entry
in the
   * class context and to walk up the stack until a class is found that
is 
   * different from the class in the first entry. 
   * NOTE: The class that is returned may not be the same class as the
class returned by 
   *       getCallingClass().
   *
   * @return the class and method name of the first method outside the
class that actually called this method
   */
  public static VMStackFrameInfo getCallingFrameInfo()

With VMStackFrameInfo beeing a simple class:
class VMStackFrameInfo
{
  public final Class frameClass;
  public final String frameMethodName;
  // Constructor comes here.
}

Any opinions about that approach?

/Roman

-- 
?Improvement makes straight roads, but the crooked roads, without
Improvement, are roads of Genius.? - William Blake
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 191 bytes
Desc: Dies ist ein digital signierter Nachrichtenteil
Url : http://developer.classpath.org/pipermail/classpath/attachments/20060516/7684ba5c/attachment.pgp

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

  Powered by Linux