Trying to load classes from a plugin with PluginClassLoader

Posted by Peter Sebastian Masny on
URL: http://imagej.273.s1.nabble.com/Trying-to-load-classes-from-a-plugin-with-PluginClassLoader-tp3702425.html

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.