You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@felix.apache.org by Sahoo <Sa...@Sun.COM> on 2008/03/31 20:10:53 UTC

Parent class loader of bundle class loader

I was under the impression that the parent class loader of a bundle 
class loader is the class loader that was used to launch Felix. Looks 
like this is not true. Felix is setting the system class loader as the 
parent class loader. Can I change this behavior? If yes, how? I am using 
1.0.3 version.

Thanks,
Sahoo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Parent class loader of bundle class loader

Posted by Sahoo <Sa...@Sun.COM>.
Yes, it is configurable, but not totally configurable. What if one does 
not Felix to delegate to the class loader that loaded Felix?
Secondly, I totally agree with you about the confusion that current 
settings create. Having a parent different from the one that's used for 
delegation is simply confusing.

Thanks,
Sahoo

Karl Pauls wrote:
> The idea is that Felix can be loaded in different classloaders (and
> that works just fine). So for a given value the classloader is
> configurable.
>
> I think what we could do is set the parent classloader of bundle
> classloaders to be the classloader that loaded felix. Then at least we
> are consistent...
>
> regards,
>
> Karl
>
>
> On Tue, Apr 1, 2008 at 2:26 PM, Stuart McCulloch
> <st...@jayway.net> wrote:
>   
>> On 01/04/2008, Sahoo <Sa...@sun.com> wrote:
>>  >
>>  > Stuart McCulloch wrote:
>>  > > On 01/04/2008, Sahoo <Sa...@sun.com> wrote:
>>  > >
>>  > >> Richard S. Hall wrote:
>>  > >>
>>  > >>> Sahoo wrote:
>>  > >>>
>>  > >>>> I would have to agree that the spec does not mandate this, but won't
>>  > >>>> it be nice to allow users to set the parent class loader as per their
>>  > >>>> requirement? Defaulting to system classloader can be very dangerous
>>  > >>>> at times. More over, ability to specify this is better, I believe.
>>  > >>>> Equinox allows users to configure the parent [1].
>>  > >>>>
>>  > >>> Yes, I agree it might be nice to make this configurable.
>>  > >>>
>>  > >>>
>>  > >>>
>>  > >> What is confusing is that although the parent is automatically set to
>>  > >> "system class loader," it is not used for any kind of delegation.
>>  > >> Instead, Felix delegates to the class loader that loaded Felix
>>  > framework
>>  > >> classes for any kind of class loading delegation. I am saying this
>>  > based
>>  > >> on the following code that I see in R4SearchPolicyCore.java:
>>  > >>                        result = (isClass)
>>  > >>                             ? (Object)
>>  > >> getClass().getClassLoader().loadClass(name)
>>  > >>                             : (Object)
>>  > >> getClass().getClassLoader().getResource(name);
>>  > >>
>>  > >> If this is the only delegation point, then it should not be that
>>  > >> difficult to provide a configuration point to user, should it?
>>  > >>
>>  > >
>>  > >
>>  > > FYI, remember OSGi doesn't follow the classic parent
>>  > > classloader delegation model, which is why I think the
>>  > > setting of the parent loader is really only of interest to
>>  > > code that explicitly uses the ClassLoader.getParent()
>>  > > method
>>  > >
>>  > > but it would still be useful to make this configurable
>>  > > (ie. the setting of the parent loader, not the above
>>  > >  search policy which I believe follows the spec...)
>>  > >
>>  > >
>>  >
>>  > The search policy is delegating to getClass().getClassLoader(). Where
>>  > does the spec mandate it to delegate to the class loader that loads the
>>  > framework? Can you please send a pointer to the spec?
>>
>>
>>  sorry, that last bit wasn't clear - at the moment Felix is
>>  delegating to the classloader that loaded the framework
>>  so the actual parent loader is never used during bundle
>>  classloader (only by code that explicitly calls getParent)
>>
>>  if we want to make this configurable then I think we'd
>>  need to set the parent loader according to the settings
>>  and then always use the parent loader in the above
>>  search in place of the framework delegation*
>>
>>  we shouldn't just change the search policy but leave
>>  the bundle's parent loader set to the system loader,
>>  as that would keep the inconsistency
>>
>>  (* the current search policy doesn't break the spec
>>    because the spec doesn't mandate what parent is
>>    used or where that parent comes from )
>>
>>
>>
>>  Thanks,
>>  > Sahoo
>>  >
>>  > ---------------------------------------------------------------------
>>  > To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>>  > For additional commands, e-mail: users-help@felix.apache.org
>>  >
>>  >
>>
>>
>>  --
>>  Cheers, Stuart
>>
>>     
>
>
>
>   

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Parent class loader of bundle class loader

Posted by Karl Pauls <ka...@gmail.com>.
The idea is that Felix can be loaded in different classloaders (and
that works just fine). So for a given value the classloader is
configurable.

I think what we could do is set the parent classloader of bundle
classloaders to be the classloader that loaded felix. Then at least we
are consistent...

regards,

Karl


On Tue, Apr 1, 2008 at 2:26 PM, Stuart McCulloch
<st...@jayway.net> wrote:
>
> On 01/04/2008, Sahoo <Sa...@sun.com> wrote:
>  >
>  > Stuart McCulloch wrote:
>  > > On 01/04/2008, Sahoo <Sa...@sun.com> wrote:
>  > >
>  > >> Richard S. Hall wrote:
>  > >>
>  > >>> Sahoo wrote:
>  > >>>
>  > >>>> I would have to agree that the spec does not mandate this, but won't
>  > >>>> it be nice to allow users to set the parent class loader as per their
>  > >>>> requirement? Defaulting to system classloader can be very dangerous
>  > >>>> at times. More over, ability to specify this is better, I believe.
>  > >>>> Equinox allows users to configure the parent [1].
>  > >>>>
>  > >>> Yes, I agree it might be nice to make this configurable.
>  > >>>
>  > >>>
>  > >>>
>  > >> What is confusing is that although the parent is automatically set to
>  > >> "system class loader," it is not used for any kind of delegation.
>  > >> Instead, Felix delegates to the class loader that loaded Felix
>  > framework
>  > >> classes for any kind of class loading delegation. I am saying this
>  > based
>  > >> on the following code that I see in R4SearchPolicyCore.java:
>  > >>                        result = (isClass)
>  > >>                             ? (Object)
>  > >> getClass().getClassLoader().loadClass(name)
>  > >>                             : (Object)
>  > >> getClass().getClassLoader().getResource(name);
>  > >>
>  > >> If this is the only delegation point, then it should not be that
>  > >> difficult to provide a configuration point to user, should it?
>  > >>
>  > >
>  > >
>  > > FYI, remember OSGi doesn't follow the classic parent
>  > > classloader delegation model, which is why I think the
>  > > setting of the parent loader is really only of interest to
>  > > code that explicitly uses the ClassLoader.getParent()
>  > > method
>  > >
>  > > but it would still be useful to make this configurable
>  > > (ie. the setting of the parent loader, not the above
>  > >  search policy which I believe follows the spec...)
>  > >
>  > >
>  >
>  > The search policy is delegating to getClass().getClassLoader(). Where
>  > does the spec mandate it to delegate to the class loader that loads the
>  > framework? Can you please send a pointer to the spec?
>
>
>  sorry, that last bit wasn't clear - at the moment Felix is
>  delegating to the classloader that loaded the framework
>  so the actual parent loader is never used during bundle
>  classloader (only by code that explicitly calls getParent)
>
>  if we want to make this configurable then I think we'd
>  need to set the parent loader according to the settings
>  and then always use the parent loader in the above
>  search in place of the framework delegation*
>
>  we shouldn't just change the search policy but leave
>  the bundle's parent loader set to the system loader,
>  as that would keep the inconsistency
>
>  (* the current search policy doesn't break the spec
>    because the spec doesn't mandate what parent is
>    used or where that parent comes from )
>
>
>
>  Thanks,
>  > Sahoo
>  >
>  > ---------------------------------------------------------------------
>  > To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
>  > For additional commands, e-mail: users-help@felix.apache.org
>  >
>  >
>
>
>  --
>  Cheers, Stuart
>



-- 
Karl Pauls
karlpauls@gmail.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Parent class loader of bundle class loader

Posted by Stuart McCulloch <st...@jayway.net>.
On 01/04/2008, Sahoo <Sa...@sun.com> wrote:
>
> Stuart McCulloch wrote:
> > On 01/04/2008, Sahoo <Sa...@sun.com> wrote:
> >
> >> Richard S. Hall wrote:
> >>
> >>> Sahoo wrote:
> >>>
> >>>> I would have to agree that the spec does not mandate this, but won't
> >>>> it be nice to allow users to set the parent class loader as per their
> >>>> requirement? Defaulting to system classloader can be very dangerous
> >>>> at times. More over, ability to specify this is better, I believe.
> >>>> Equinox allows users to configure the parent [1].
> >>>>
> >>> Yes, I agree it might be nice to make this configurable.
> >>>
> >>>
> >>>
> >> What is confusing is that although the parent is automatically set to
> >> "system class loader," it is not used for any kind of delegation.
> >> Instead, Felix delegates to the class loader that loaded Felix
> framework
> >> classes for any kind of class loading delegation. I am saying this
> based
> >> on the following code that I see in R4SearchPolicyCore.java:
> >>                        result = (isClass)
> >>                             ? (Object)
> >> getClass().getClassLoader().loadClass(name)
> >>                             : (Object)
> >> getClass().getClassLoader().getResource(name);
> >>
> >> If this is the only delegation point, then it should not be that
> >> difficult to provide a configuration point to user, should it?
> >>
> >
> >
> > FYI, remember OSGi doesn't follow the classic parent
> > classloader delegation model, which is why I think the
> > setting of the parent loader is really only of interest to
> > code that explicitly uses the ClassLoader.getParent()
> > method
> >
> > but it would still be useful to make this configurable
> > (ie. the setting of the parent loader, not the above
> >  search policy which I believe follows the spec...)
> >
> >
>
> The search policy is delegating to getClass().getClassLoader(). Where
> does the spec mandate it to delegate to the class loader that loads the
> framework? Can you please send a pointer to the spec?


sorry, that last bit wasn't clear - at the moment Felix is
delegating to the classloader that loaded the framework
so the actual parent loader is never used during bundle
classloader (only by code that explicitly calls getParent)

if we want to make this configurable then I think we'd
need to set the parent loader according to the settings
and then always use the parent loader in the above
search in place of the framework delegation*

we shouldn't just change the search policy but leave
the bundle's parent loader set to the system loader,
as that would keep the inconsistency

(* the current search policy doesn't break the spec
   because the spec doesn't mandate what parent is
   used or where that parent comes from )

Thanks,
> Sahoo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
>


-- 
Cheers, Stuart

Re: Parent class loader of bundle class loader

Posted by Sahoo <Sa...@Sun.COM>.
Stuart McCulloch wrote:
> On 01/04/2008, Sahoo <Sa...@sun.com> wrote:
>   
>> Richard S. Hall wrote:
>>     
>>> Sahoo wrote:
>>>       
>>>> I would have to agree that the spec does not mandate this, but won't
>>>> it be nice to allow users to set the parent class loader as per their
>>>> requirement? Defaulting to system classloader can be very dangerous
>>>> at times. More over, ability to specify this is better, I believe.
>>>> Equinox allows users to configure the parent [1].
>>>>         
>>> Yes, I agree it might be nice to make this configurable.
>>>
>>>
>>>       
>> What is confusing is that although the parent is automatically set to
>> "system class loader," it is not used for any kind of delegation.
>> Instead, Felix delegates to the class loader that loaded Felix framework
>> classes for any kind of class loading delegation. I am saying this based
>> on the following code that I see in R4SearchPolicyCore.java:
>>                        result = (isClass)
>>                             ? (Object)
>> getClass().getClassLoader().loadClass(name)
>>                             : (Object)
>> getClass().getClassLoader().getResource(name);
>>
>> If this is the only delegation point, then it should not be that
>> difficult to provide a configuration point to user, should it?
>>     
>
>
> FYI, remember OSGi doesn't follow the classic parent
> classloader delegation model, which is why I think the
> setting of the parent loader is really only of interest to
> code that explicitly uses the ClassLoader.getParent()
> method
>
> but it would still be useful to make this configurable
> (ie. the setting of the parent loader, not the above
>  search policy which I believe follows the spec...)
>
>   
The search policy is delegating to getClass().getClassLoader(). Where 
does the spec mandate it to delegate to the class loader that loads the 
framework? Can you please send a pointer to the spec?

Thanks,
Sahoo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Parent class loader of bundle class loader

Posted by Stuart McCulloch <st...@jayway.net>.
On 01/04/2008, Sahoo <Sa...@sun.com> wrote:
>
> Richard S. Hall wrote:
> > Sahoo wrote:
> >> I would have to agree that the spec does not mandate this, but won't
> >> it be nice to allow users to set the parent class loader as per their
> >> requirement? Defaulting to system classloader can be very dangerous
> >> at times. More over, ability to specify this is better, I believe.
> >> Equinox allows users to configure the parent [1].
> >
> > Yes, I agree it might be nice to make this configurable.
> >
> >
>
> What is confusing is that although the parent is automatically set to
> "system class loader," it is not used for any kind of delegation.
> Instead, Felix delegates to the class loader that loaded Felix framework
> classes for any kind of class loading delegation. I am saying this based
> on the following code that I see in R4SearchPolicyCore.java:
>                        result = (isClass)
>                             ? (Object)
> getClass().getClassLoader().loadClass(name)
>                             : (Object)
> getClass().getClassLoader().getResource(name);
>
> If this is the only delegation point, then it should not be that
> difficult to provide a configuration point to user, should it?


FYI, remember OSGi doesn't follow the classic parent
classloader delegation model, which is why I think the
setting of the parent loader is really only of interest to
code that explicitly uses the ClassLoader.getParent()
method

but it would still be useful to make this configurable
(ie. the setting of the parent loader, not the above
 search policy which I believe follows the spec...)

Thanks,
>
> Sahoo
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>
> --
Cheers, Stuart

Re: Parent class loader of bundle class loader

Posted by Sahoo <Sa...@Sun.COM>.
Richard S. Hall wrote:
> Sahoo wrote:
>> I would have to agree that the spec does not mandate this, but won't 
>> it be nice to allow users to set the parent class loader as per their 
>> requirement? Defaulting to system classloader can be very dangerous 
>> at times. More over, ability to specify this is better, I believe. 
>> Equinox allows users to configure the parent [1].
>
> Yes, I agree it might be nice to make this configurable.
>
>
What is confusing is that although the parent is automatically set to 
"system class loader," it is not used for any kind of delegation. 
Instead, Felix delegates to the class loader that loaded Felix framework 
classes for any kind of class loading delegation. I am saying this based 
on the following code that I see in R4SearchPolicyCore.java:
                       result = (isClass)
                            ? (Object) 
getClass().getClassLoader().loadClass(name)
                            : (Object) 
getClass().getClassLoader().getResource(name);

If this is the only delegation point, then it should not be that 
difficult to provide a configuration point to user, should it?

Thanks,
Sahoo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Parent class loader of bundle class loader

Posted by "Richard S. Hall" <he...@ungoverned.org>.
Sahoo wrote:
> I would have to agree that the spec does not mandate this, but won't 
> it be nice to allow users to set the parent class loader as per their 
> requirement? Defaulting to system classloader can be very dangerous at 
> times. More over, ability to specify this is better, I believe. 
> Equinox allows users to configure the parent [1].

Yes, I agree it might be nice to make this configurable.

-> richard
>
> Thanks,
> Sahoo
> http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/runtime-options.html 
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Parent class loader of bundle class loader

Posted by Sahoo <sa...@sun.com>.
Richard S. Hall wrote:
> Sahoo wrote:
>> I was under the impression that the parent class loader of a bundle 
>> class loader is the class loader that was used to launch Felix. Looks 
>> like this is not true. Felix is setting the system class loader as 
>> the parent class loader. Can I change this behavior? If yes, how? I 
>> am using 1.0.3 version.
>
> Felix doesn't appear to set it at all, which means it uses the default 
> value for parent, which is the system class loader. There is no way to 
> change this behavior. I don't believe that the spec says which class 
> loader should be used as the parent.
>
> -> richard
>
I would have to agree that the spec does not mandate this, but won't it 
be nice to allow users to set the parent class loader as per their 
requirement? Defaulting to system classloader can be very dangerous at 
times. More over, ability to specify this is better, I believe. Equinox 
allows users to configure the parent [1].

Thanks,
Sahoo
http://help.eclipse.org/help33/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/runtime-options.html

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org


Re: Parent class loader of bundle class loader

Posted by "Richard S. Hall" <he...@ungoverned.org>.
Sahoo wrote:
> I was under the impression that the parent class loader of a bundle 
> class loader is the class loader that was used to launch Felix. Looks 
> like this is not true. Felix is setting the system class loader as the 
> parent class loader. Can I change this behavior? If yes, how? I am 
> using 1.0.3 version.

Felix doesn't appear to set it at all, which means it uses the default 
value for parent, which is the system class loader. There is no way to 
change this behavior. I don't believe that the spec says which class 
loader should be used as the parent.

-> richard

>
> Thanks,
> Sahoo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
> For additional commands, e-mail: users-help@felix.apache.org
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@felix.apache.org
For additional commands, e-mail: users-help@felix.apache.org