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


_______________________________________________
Classpath mailing list
[email protected]
http://lists.gnu.org/mailman/listinfo/classpath

Reply via email to