cclass = env->FindClass(demoflashplugin/views/Objfactory");
Yes this was a typo , make that
cclass = env->FindClass("demoflashplugin/views/Objfactory");
Sorry my mistake .
For some reason I cannot find the class from the thread . Inside Java
code my classpath is a .jar file . I would assume that the same
environment would be passed to the thread when i cache the JVM pointer
. Looks like i ve really hit a stone and am not able to root cause
this . Really need some inputs for this . i still believe its some
kinda classpath issue but am not able to resolve it
> actually this does compile and I am able to verify the same by stepping
> inside
[quoted text clipped - 14 lines]
> >
> > -- chris
Chris Uppal - 18 Jul 2006 10:57 GMT
> For some reason I cannot find the class from the thread . Inside Java
> code my classpath is a .jar file . I would assume that the same
> environment would be passed to the thread when i cache the JVM pointer
The JVM's classpath will be the same in all threads.
The only possibility that I can suggest is that the Java thread where the
FindClass() works is running with a custom classloader, not the primordial or
the application classloader. That would happen if a custom classloader is used
to load the class from which the DLL is initially loaded (probably in its class
initialisation). If that happened then that classloader might be able to find
Objfactory.class but the application classloader (which would be used by the
new thread's FindClass() as far as I understand this) would not be able to find
it (or worse, would find another version).
If that is the problem, then the simple solution would be to get references to
the classes you need in the DLL main(), convert them to "global" references (so
they can be used from any thread), and store them there.
If that's too inflexible, then I would be tempted to change the design a bit --
create a Java object (of a new class written for this purpose) who's job it is
to find your classes. It's class would be loaded by the custom classloader,
and so that classloader would be used whenever it used Class.byName(). You
would then initialise your DLL with a (global) instance of that class, and
would use its findClass() method instead of the JNI FindClass().
-- chris