Ah, static methods explains something that was confusing me. Stepping through, I saw that the parameter named className was in fact the symbol name used in the policy. I suppose it will be the name of a class when the method is static. Good catch. Thanks. I'll make the change.
I'm not sure what I may have missed, but I updated both invokeMethod() and modifyInstance(). They now do the following: if (instance != null) { c = instance.getClass(); } else if(urlLoader == null) { c = Class.forName(className); } else { c = urlLoader.loadClass(className); } Note also, that for efficiency, I created the URLClassLoader in the constructor, instead of every time we do a class load. David Wood Policy Technologies Group IBM TJ Watson Research Center daw...@us.ibm.com 914-784-5123 (office), 914-396-6515 (mobile) From: Erik Bengtson <e...@jpox.org> To: imperius-dev@incubator.apache.org Date: 03/17/2010 04:06 PM Subject: Re: Unnecessary class load in JavaActuator David, I assume that code used to support static methods invocations, so the instance variable might be null on this scenario. I propose that you check for for null on instance value, then fallback to the Class.forName(className) if its null. Also, your changes missed some of the methods of that class. org.apache.imperius.spl.core.Actuator misses a few javadocs regarding this. On Wed, Mar 17, 2010 at 7:25 PM, David Wood <daw...@us.ibm.com> wrote: > I've changed it to instance.getClass(), passed all tests and checked it > in. > > > David Wood > Policy Technologies Group > IBM TJ Watson Research Center > daw...@us.ibm.com > 914-784-5123 (office), 914-396-6515 (mobile) > > > > > From: > Neeraj Joshi/Durham/i...@ibmus > To: > imperius-dev@incubator.apache.org > Date: > 03/17/2010 02:15 PM > Subject: > Re: Unnecessary class load in JavaActuator > > > > Hey David, > I can't seem to recall any specific reason for the code below. Did you see > > any issues using instance.getClass() ? > > Thanks > Neeraj > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > Neeraj Joshi (knee-rudge) > WebSphere XD - Compute Grid > AIM, IBM > Apache Imperius - http://incubator.apache.org/imperius > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > > > From: > David Wood/Watson/i...@ibmus > To: > imperius-dev@incubator.apache.org > Date: > 03/17/2010 12:41 PM > Subject: > Unnecessary class load in JavaActuator > > > > Hi All, > > I've got a situation in which my Java-bound policy imports an interface, > but the implementation is provided by a class in a package I do not have > access to. This leads to problems in the JavaActuator.invokeMethod() > method which does the following: > > > c = Class.forName(instance.getClass().getName()); > > > Class.forName() is throwing ClassNotFoundException, which on the face of > it seems strange since we already have the class in instance.getClass(). > So, this is my question, "why doesn't this code just do > c=instance.getClass()?' This is probably some subtly of Java that I'm not > > > aware of. Your teachings will be much appreciated. thanks. > > > David Wood > Policy Technologies Group > IBM TJ Watson Research Center > daw...@us.ibm.com > 914-784-5123 (office), 914-396-6515 (mobile) > > > > >