classpath
[Top][All Lists]
Advanced

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

Re: Loading native libraries


From: Archie Cobbs
Subject: Re: Loading native libraries
Date: Fri, 4 Jun 2004 10:28:40 -0500 (CDT)

Dalibor Topic wrote:
> > But what about:
> > 
> >  
> > Foo.method()->Method.invoke()->Runtime.loadLibrary()->getCallerClassLoader()
> > 
> > Is the "caller's" class supposed to be "Foo" or "Method" ? This is something
> > that is not made clear in the documentation to getClassContext().
> 
> Foo, I believe.
> 
> Otherwise all reflection would happen with the security credentials of 
> java,lang.reflect, and that would be a bad thing, I guess.

Thanks.. we should document this in VMSecurityManager.getClassContext().
In fact, we should document the correct algorithm to use, because it's
somewhat tricky (please verify that this is correct!):

  1. Compute the current execution stack as an array where the top
     of the stack is the first element in the array.

  2. Delete from the *beginning* of the array all stack frames associated
     with java.lang.SecurityManager, java.lang.VMSecurityManager,
     java.lang.reflect.Method, and java.lang.reflect.Constructor.

  3. Return the resulting remainder of the array. So the original
     "true caller" class will be the first element in the array.

Note: there could be multiple consecutive stack frames from Method.invoke()
on the stack, which this algorithm will properly handle.

-Archie

__________________________________________________________________________
Archie Cobbs      *        CTO, Awarix        *      http://www.awarix.com




reply via email to

[Prev in Thread] Current Thread [Next in Thread]