Trying to load classes from a plugin with PluginClassLoader

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Trying to load classes from a plugin with PluginClassLoader

Peter Sebastian Masny
Hi all,

I'm working on an app that will have its own "plugins", basically a simple class
and some extensions.  My file structure is like this

plugins/Census_  : the actual plugin
plugins/census/CensusObject   : the basic object class
plugins/census/ExampleExtension1 (of many) : A "user-written" extension of the
CensusObject class

The idea is that a user could write a single method or two in a new extension
and have a new function within the plugin.

My problem:
I have tried to use the PluginClassLoader, but it seems to die on the
  result = defineClass(className, classBytes, 0, classBytes.length);

line.  I am invoking it in my plugin by doing (short version):

  PluginClassLoader breedLoader = (PluginClassLoader)IJ.getClassLoader();
  Class theClass = breedLoader.loadClass("CensusObject");
  Vector breedClasses.add(breedLoader.loadClass("ExampleExtension1"));

Later I would invoke
  breedClasses[i].newInstance()

The uncommented line:
  IJ.log("loadClass: "+ className + "  "+
(classBytes!=null?""+classBytes.length:"null"));
Shows the class is being found and has reasonable byte values, but then nothing
happens as it enters defineClass.

I am at a standstill now.  I can't seem to get the classes to load.
Am I approaching this all wrong trying to use PluginClassLoader?  Any hints?

Thanks,
Peter Masny

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.
Reply | Threaded
Open this post in threaded view
|

Re: Trying to load classes from a plugin with PluginClassLoader

dscho
Hi,

On Tue, 20 Jun 2006, Peter Sebastian Masny wrote:

> I have tried to use the PluginClassLoader, but it seems to die on the
>   result = defineClass(className, classBytes, 0, classBytes.length);

How does it die? Does it throw an exception? If yes, which one?

Hth,
Dscho
Reply | Threaded
Open this post in threaded view
|

Re: Trying to load classes from a plugin with PluginClassLoader

Peter Sebastian Masny
Quoting Johannes Schindelin <[hidden email]>:

> Hi,
>
> On Tue, 20 Jun 2006, Peter Sebastian Masny wrote:
>
> > I have tried to use the PluginClassLoader, but it seems to die on the
> >   result = defineClass(className, classBytes, 0, classBytes.length);
>
> How does it die? Does it throw an exception? If yes, which one?

It doesn't throw an exception that shows up.  The thread just never completes.
I put IJ.log's on each side of the defineClass call, and the one after the
method call never shows up in the log window.

A different longstanding issue for me is that I haven't get netbeans set up
right so that I can step through threads.  Ideally that way I could see where
it blows up.

This help identify the problem at all?  Is my approach sensible?
Thank you _very_ much for looking at this,
Peter

----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.