Sorry to rehash this subject, but apparently my previous post didn't
make it.

Euxx suggested a "safe" approach to discover the calling class:

public class ClassLocator extends SecurityManager {
  public static Class getCallerClass() {
    return new ClassLocator().getClassContext()[2];
  }
}

Quoting from [1]:

protected Class[] getClassContext()

Returns the current execution stack as an array of classes.

The length of the array is the number of methods on the execution stack.
The element at index 0 is the class of the currently executing method,
the element at index 1 is the class of that method's caller, and so on.

[1]
http://java.sun.com/j2se/1.5.0/docs/api/java/lang/SecurityManager.html#getClassContext()


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to