Re: Classloading and ArgoUML
Roy Feldman <[email protected]> 04 Jul 2003 12:03:41 -0400
| Newsgroups | gmane.comp.java.netbeans.modules.mdr.devel |
|---|---|
| Message-ID | <1057334620.2522.20.camel@blamange> |
Hi Anders,
On Thu, 2003-07-03 at 05:02, Anders W. Tell wrote:
> Hi,
>
> Im having some trouble using ArgoUML and MDR together, for some reason I
> get a classcast exception when refering to generated Java API/JMI files.
> It seems that MDR and ArgoUML is using different classloaders or Im I
> wrong ?
>
> Im sure that ArgoUML got its own classloader but how is this loader
> related to the automatically generated internal implementation of the
> metamodel used internally in MDR ?
>
>
> Has anyone had a similar problem and solved it ?
Martin, feel free to correct me if I'm wrong, but I think the answer to
your problem lies in recent answer I got from Martin when I was trying
to use MDR inside of a Java Interpreter (DrJava), which has its own
ClassLoader.
On Tue, 2003-07-01 at 06:30, Martin Matula wrote:
> > Anyway, what you need to do to make this work is probably to implement
> > org.netbeans.mdr.handlers.ClassLoaderProvider interface and set it to
> > MDR by calling
> > org.netbeans.mdr.handlers.BaseObjectHandler.setClassLoaderProvider
> > before you start accessing the repository.
> > You will need to implement the ClassLoaderProvider so that it properly
> > loads the classes using the DrJava's classloader. To see how this is
> > done for NetBeans and DJava, see
> > org.netbeans.mdrshell.DJava.CLProviderImpl and
> > org.netbeans.modules.mdr.MDRManagerImpl.CLProviderImpl.
Basically, you just need to get the ClassLoader for ArgoUML and create a ClassLoaderProvider
for MDR that returns the ArgoUML classloader for the method
- public ClassLoader getClassLoader()
and implements the method
- public Class defineClass(String className, byte[] classFile)
In this case, I think you can do what I did, which is to simply implement defineClass as follows:
{
return this.getClassLoader().defineClass(className, classFile, 0, classFile.length);
}
Let me know if that works for you.
cheers,
roy