Re: question about class loading

Archie Cobbs <[email protected]> Sun, 16 Jan 2005 11:24:32 -0600
Newsgroups gmane.comp.java.vm.sablevm.devel
Message-ID <[email protected]>
David Bélanger wrote:
> Consider this code:
> cl = new UserClassLoader();
> cl.loadClass("SomeClass").getDeclaredMethods()[0].getParameterTypes();
> 
> And the class corresponding to one of the parameter of the method
> accessed through reflection has not been loaded when getParameterTypes()
> is invoked.  Which class loader
> initiates the class loading?
> 
> I would say UserClassLoader?  Is that right?

Yes... Java classes contain symbolic references to other classes.
When those references need to be resolved, they are supposed to
be resolved using the same class loader that loaded the class.

Note, this doesn't imply that the resolved class will be defined
by the same class loader (it could be defined by a parent, e.g.,
"Ljava/lang/String;") but it must be initiated by the same class loader.

-Archie

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