incubator-yoko-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dain Sundstrom <d...@iq80.com>
Subject Re: Class loading issues
Date Tue, 20 Jun 2006 22:31:27 GMT
On Jun 15, 2006, at 1:48 AM, Rick McGuire wrote:

> Anders Hessellund Jensen wrote:
>> The RMI test fail due to some class loading issues.
>>
>> The problematic code is during marshalling of RMI values, where we  
>> obtain the helper class:
>>
>> String name = value.getClass().getName() + "Helper";
>> // get the appropriate class for the loading.
>> ClassLoader loader = value.getClass().getClassLoader();
>> Class c = loader.loadClass(name);
>>
>> Unfortunately, this fails. value may be any type, include e.g.  
>> String, in which case value.getClass().getClassLoader() returns null.
>>
>> I'm wondering how to fix this. I suppose falling back to the ORBs  
>> classloader would work. Finally, the system class loader could be  
>> used.
> The starting point should probably be the thread context class  
> loader.  By default, this will be the system loader, but it allows  
> appropriate application overrides.

+1

>> String name = value.getClass().getName() + "Helper";
>> // get the appropriate class for the loading.
>> ClassLoader loader = value.getClass().getClassLoader();
>> if(loader == null) {
>>     loader = ORB.class.getClassLoader();
>> }
>> if(loader == null) {
>>     loader = ClassLoader.getSystemClassLoader();
>> }
>> Class c = loader.loadClass(name);
>>
>> Perhaps someone with indsight into Geronimo class loading could  
>> comment on this?

The null class loader means it was loaded by the primordial class  
loader, so using SystemClassLoader is a good choice.

I'm not sure where this code is located, but normally we try to keep  
this type of locate the class loader code to a minimum.  In places  
where it is possible, we explicitly pass the class loader around, but  
protocol code usually requires passing the class loader on the thread.

Just something to think about.

-dain

Mime
View raw message