ClassLoader question

This is not OpenAPI-specific, but it is an attempt to allow my plugin to see jars located in IDEA/lib/ant.


I suspect that AntConsole class has been already loaded and cached by some of classLoader's parents, with antConsole.class.getClassLoader() == this parent ClassLoader. As far as this parent loader doesn't see Locator class, I'm getting an exception. But is there some way to overcome this?

3 comments
Comment actions Permalink

Hello, Konstantin!
You wrote on Wed, 7 Jul 2004 12:55:43 +0400 (MSD):


KS> //now some checking:
KS> classLoader.loadClass("org.apache.tools.ant.launch.Locator"); //<--
KS> works
KS> consoleClass.getClassLoader().loadClass("org.apache.tools.ant.launch.
KS> Locator"); //<-- throws NoClassDefFound

Since 2008 build IDEA have dedicated classloaders for plugin. Plugin can see
classes of IDEA/lib, plugin can see classes of pluginHome/lib, but IDEA will
not know about plugin classes.

Mistake as in this sample, then you try to load clases from plugins lib by
ClassLoader from IDEA/lib, it will not work. But plugin classloader will
success work with IDEA/lib.

WBR,
--
Alexey Efimov, Java Developer
Tops-BI
http://www.topsbi.ru


0
Comment actions Permalink

I'm working in the context of this plugin classloader and classes from idea/lib can be seen. But I'm trying to make classes from idea/lib/ant to be accessible. Feel the difference :)

0
Comment actions Permalink

Alexey Efimov wrote:

Since 2008 build IDEA have dedicated classloaders for plugin. Plugin can see
classes of IDEA/lib, plugin can see classes of pluginHome/lib, but IDEA will
not know about plugin classes.


It may see them, but it sure as hell has issues loading alot of them. I
have to bastardized jdom.jar to include parts of xpath in my plugin just
so I can use it now :(

0

Please sign in to leave a comment.