[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-java
Subject:    Re: [Kde-java] Qt bindings hang with gcj
From:       Richard Dale <Richard_Dale () tipitina ! demon ! co ! uk>
Date:       2001-08-23 10:52:01
[Download RAW message or body]

On Thu, 23 Aug 2001, Richard Dale wrote:
> On Wed, 22 Aug 2001, Thomas Kuhn wrote:
> > I rechecked that this morning, if the events reach java they are handled 
> > correctly. The hang occours when calling QtSupport::evevtxxxDelegate or any 
> > similar function. When doing a callback from c++ to java using 
> > QtSupport::GetEnv sometimes (not always) this hang occours. Usually it works 
> > about 20-40 times so I think it's some bug in gjc's jni implementation. I'll 
> > try to rewrite the callback parts of QtSupport with cni - as far as I see its 
> > the only class that does callbacks from c++ to java - am I correct here ? 
> > At least GetEnv isn't called from any other c++ function. Jni seems to be 
> > working when the JNIEnv is passed as parameter to the native function so I 
> > hope the bindings will work when the callback stuff in QtSupport is cni. I 
> > don't think I have to change anything in Invocation.java because when the 
> > callback reached the java part everything worked fine.
> The env pointer returned by QtSupport::GetEnv(), should be set up correctly as
> long as QtSupport::registerJVM() has been called. And that method gets called
> via a native method from the static initialization of qtjava.java:
> 
> 	static {
> 		System.loadLibrary("qtjava");
> 		qtjava.registerJVM();
> 		qtjava.setJavaSlotFactory();
> 		qtKeyToJavaMap = new WeakValueMap();
> 		qtSignalDictionary = new HashMap();
> 		qtSlotDictionary = new HashMap();
> 
> 	}
> 
> The JavaSlot.h/cpp code also calls Invocation.java to invoke a slot.
Further to this, you could try caching the current JNIEnv in '_env' in
registerJVM(), as well as the jvm pointer.

static JNIEnv *	_env;

... 

void
QtSupport::registerJVM(JNIEnv * env)
{
	jstring	testString;
	const jchar * _jchar_str;

	env->GetJavaVM((JavaVM **) &_jvm);
	_env = env;
	...

And then change QtSupport::GetEnv() to return the _env variable:

JNIEnv *
QtSupport::GetEnv()
{
	return _env;
}

Whether or not this fixes the problem would depend on what bug there is in gcj
- it could be that just GetJavaVM() is broken and everything else is ok. Or
not...

 -- Richard
_______________________________________________
Kde-java mailing list
Kde-java@mail.kde.org
http://mail.kde.org/mailman/listinfo/kde-java

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic