What I need to know is if it is possible to obtain a java.lang.Class instance from the Jython class upon which we can invoke newInstance in the Java code that is being executed when I pass the class as a parameter.

I tried myobject.loadNewClass(MyNewClass.NAME, MyNewClass.__name__) and __name__ is returning just the class name (MyNewClass).

As the loadNewClass method also accepts the class object itself instead of the fully qualified name of the class, I tried

myobject.loadNewClass(MyNewClass.NAME, MyNewClass.__class__)

but it fails because the java code is trying to instantiate org.python.core.PyClass


On Dec 18, 2007 12:48 AM, Charlie Groves < charlie.groves@gmail.com> wrote:
On Dec 17, 2007 8:52 PM, Teresa Van Dusen <trvd1707@gmail.com> wrote:
> class MyNewClass ()  extends AbstractAction {
> // at some point it has an attribute
> public static final String Name="MyNewClass";
> // here goes the code of the class
> ...
>
> }
>
> On the calling code I have:
>
> myobject.loadNewClass(MyNewClass.NAME, MyNewclass.class.getName());
>
>
> I was able to create MyNewClass in jython, but when I call
>
> myobject.loadNewClass(MyNewClass.NAME, MyNewClass.__name__)
>
> It returns an error in java.lang.reflect.Method.invoke saying Unable to load
> class - MyNewClass:MyNewClass
>
> How can I obtain the fully qualified name of the Jython class MyNewClass
> that I created? How can it be made available while I'm executing the calling
> code?

What does print MyNewClass.__name__ yield?  Is it not the fully
qualified name?  Both MyNewClass.__name__ and MyNewClass.getName()
should yield the full class name.  If they don't, could you post
enough code to reproduce the problem?  I can't get __name__ to be
anything other than the full class name here.

Charlie