Quote:
Originally Posted by goga_ruler
Hi nev.clark,
Your solution didn't work for me.
It gives me the Java Model Exception [code368] with the Explanation that the resource doesn't exist on this line:
Code:
classFile = fragment.getClassFile(className.substring(className
.lastIndexOf('.') + 1)
+ ".class");
The interesting is, that the project resource is not the full path of my eclipse project, but beginns with "/" and than follows immediatly the name of the project. I think it should show the full path /home/username/eclipse-workspase/Project Name/all../packages../ClassName.class But it doesn't.
Can you please write me, how do you extract the IJavaProject-object from the ISelection in order to call the loadClass()-Method from your own ClassLoader-class?
Does anyone know a solution for this problem?
|
Bing found:
Third party libraries and classloading
Because OSGi makes use of multiple classloaders, the transparent usage of extensible / configurable third party libraries in eclipse requires the usage of an eclipse specific mechanism called "buddy loading". This mechanism allows a bundle to indicate that it needs assistance to load classes or resources when it can not find them among its prerequisites. Note that we call "extensible libraries", libraries that needs to see classes or resources provided by user code (for example log4j logger mechanism, hibernate,...).
To indicate its need for buddy loading, a bundle must modify its manifest and add the following header:
Eclipse-BuddyPolicy: <value>
<value> refers to the policy used to look for the classes. Here are the supported policies:
* registered - indicates that the buddy mechanism will consult bundles that have been registered to it. Bundle willing to be registered to a particular bundle add in their manifest: "Eclipse-RegisterBuddy: <bundleSymbolicName>";
* dependent - indicates that the classes/resources will be looked up transitively in all the dependent of the bundle;
* global - indicates that the classes/resources will be looked up in the global pool of exported package;
* app - indicates that the application classloader will be consulted;
* ext - indicates that the extensiont classloader will be consulted;
* boot - indicates that the boot classloader will be consulted.