[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: Asking our experts on class loading.
From: |
Jeroen Frijters |
Subject: |
RE: Asking our experts on class loading. |
Date: |
Thu, 13 Oct 2005 14:29:18 +0200 |
Audrius Meskauskas wrote:
> However if anybody knows the way to get the loader of the caller
> class (stack trace contains the name only - no use), it would be
> great to know it.
Please add the following method to gnu/classpath/VMStackWalker.java and
use that.
/**
* Returns the first user defined class loader on the call stack, or
* null when no non-null class loader was found.
*/
public static ClassLoader getUserClassLoader()
{
Class[] ctx = getClassContext();
for (int i = 0; i < ctx.length; i++)
{
// Since we live in a class loaded by the bootstrap
// class loader, getClassLoader is safe to call without
// needing to be wrapped in a privileged action.
ClassLoader cl = ctx[i].getClassLoader();
if (cl != null)
return cl;
}
return null;
}
Regards,
Jeroen