You may have noticed that the wiki is rather detailed in describing the
buddy class loading design.  This was because the Equinox team prepared the
design as input for a future OSGi specification.  The design works for
about 80% of the cases, but it does have some disadvantages.

1) There is no good way to force the ContextFinder across all threads in
the system.  If some code unsets the context class loader for a thread then
the context finder will no longer take effect..
2) ContextFinder has issues when used with Class.forName(String, boolean,
ClassLoader).  Class.forName will cause the specified class loader to be
the initiating class loader.  The VM will cache all Class objects for the
initiating class loader, any time that class loader is asked for a
particular class name again it must return the same Class object as
previously returned.  This causes issues if multiple versions of a package
need to be supported.
3) There were other issues, but they are not fresh in my mind ;-)

At any rate, this proposal fell out of the specification for OSGi R4 V4.2
core specification.  OSGi could decide to tackle this issue again in the
next specification, but I am not confident the solution will end up being
buddy class loading.

Tom




|------------>
| From:      |
|------------>
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
  |"Michael Furtak" <[email protected]>                                           
                                                                     |
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| To:        |
|------------>
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
  |"Equinox development mailing list" <[email protected]>                 
                                                                     |
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Date:      |
|------------>
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
  |10/06/2009 02:00 PM                                                          
                                                                     |
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Subject:   |
|------------>
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|
  |RE: [equinox-dev] Use of Thread Context ClassLoader consideredharmful?       
                                                                     |
  
>--------------------------------------------------------------------------------------------------------------------------------------------------|





Hi Tom,

The Buddy manifest adjustments do indeed resolve the issue. Thank you for
that excellent link.

Out of curiosity, are you aware of any effort to make this solution a part
of the OSGi spec?

Thanks again,
-Mike








THIS MESSAGE IS INTENDED FOR THE USE OF THE PERSON TO WHOM IT IS ADDRESSED.
IT MAY CONTAIN INFORMATION THAT IS PRIVILEGED, CONFIDENTIAL AND EXEMPT FROM
DISCLOSURE UNDER APPLICABLE LAW. If you are not the intended recipient,
your use of this message for any purpose is strictly prohibited. If you
have received this communication in error, please delete the message and
notify the sender so that we may correct our records.




From: [email protected] [
mailto:[email protected]] On Behalf Of Thomas Watson
Sent: Tuesday, October 06, 2009 2:14 PM.
To: Equinox development mailing list
Subject: Re: [equinox-dev] Use of Thread Context ClassLoader
consideredharmful?



In Equinox we have something called buddy class loading (not OSGi
specified). It may be used to help your situation. See
http://wiki.eclipse.org/index.php/Context_Class_Loader_Enhancements

HTH

Tom



Inactive hide details for "Michael Furtak" ---10/06/2009 12:53:27 PM---Hi
all,"Michael Furtak" ---10/06/2009 12:53:27 PM---Hi all,


                                                                       
                                                                       
 From:           "Michael Furtak" <[email protected]>                    
                                                                       
                                                                       
 To:             "Equinox development mailing list"                    
                 <[email protected]>                             
                                                                       
                                                                       
 Date:           10/06/2009 12:53 PM                                   
                                                                       
                                                                       
 Subject:        [equinox-dev] Use of Thread Context ClassLoader       
                 considered harmful?                                   
                                                                       






Hi all,

I am using Apache XMLBeans 2.4 within Equinox 3.5, and am running into
problems. Specifically, I (and others [1,2] - references at bottom) have
noticed that a specific part of the type resolution process breaks when
run in an OSGi environment.

After some investigation, I have found that XMLBeans is creating its
SchemaTypeLoader objects with the current thread's context
classloader[3]. My experience has been that any time a library does this
and then needs to load classes that are in a different OSGi bundle, the
classes can not be resolved.

So I suppose my questions are: Could Equinox do more to prevent this
kind of use-case from breaking down? Alternatively, for compatibility
with an OSGi environment, is using a TCCL considered harmful? If so,
what should I suggest in my XMLBeans ticket as an OSGi-compatible
alternative?


Thanks,
-Mike Furtak


1)
http://markmail.org/message/vx2vdg7yhb4l3ej6#query:+page:1+mid:vx2vdg7yh
b4l3ej6+state:results

2)
http://mail-archives.apache.org/mod_mbox/ws-axis-user/200701.mbox/%3C8d2
[email protected]%3e

3)
http://grepcode.com/file/[email protected]$xmlb
[email protected]@org$apache$xmlbeans$impl$schema$SchemaTypeLoaderImpl.java#Sch
emaTypeLoaderImpl.getContextTypeLoader%28%29 (Line 131)




THIS MESSAGE IS INTENDED FOR THE USE OF THE PERSON TO WHOM IT IS ADDRESSED.
IT MAY CONTAIN INFORMATION THAT IS PRIVILEGED, CONFIDENTIAL AND EXEMPT FROM
DISCLOSURE UNDER APPLICABLE LAW. If you are not the intended recipient,
your use of this message for any purpose is strictly prohibited. If you
have received this communication in error, please delete the message and
notify the sender so that we may correct our records.
_______________________________________________
equinox-dev mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/equinox-dev
_______________________________________________
equinox-dev mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/equinox-dev

<<inline: graycol.gif>>

<<inline: ecblank.gif>>

<<inline: 2B816409.gif>>

<<inline: 2B501474.gif>>

_______________________________________________
equinox-dev mailing list
[email protected]
https://dev.eclipse.org/mailman/listinfo/equinox-dev

Reply via email to