[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:       Thomas Kuhn <t_kuhn () gmx ! de>
Date:       2001-08-23 13:57:03
[Download RAW message or body]

Am Donnerstag, 23. August 2001 12:52 schrieb Richard Dale:
> > 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;
> }

That was one of the first things I did, but it didn't help. I rewrote parts 
of JavaSlot  and QtSupport to use CNI. and removed QtSupport:GetEnv() 
completly. Now it's working fine with gcj. Later I had to add 2 static 
methods and a hashtable to Invocation.java - gcj seems to have some problems 
with java objects that are created with the new operator from c++, so I added 
a factory that creates and deletes them for me. The modified qt bindings are 
currenty working fine with gcj here, so I think there are some bugs with 
GetJavaVM etc. in the jni interface. Now I'll write a makefile and put the 
gcj files (only four and about six header files, most were generated with 
gcjh) in a seperate directory because they compile only with gcj. If you are 
interested I'll mail you the changes I've made. Pherhaps we could put up a 
configure script that let anyone choose whether to build for generic java or 
for gcj using cni for the callback parts. I'll change the kdebindings as well 
in the next days to work with gcj and try to write a configure script that 
can to that (I'm not too experienced with that automake/autoconf stuff :-)) 
). Anyway, I think there will be much interest in a qt that is usable with 
gcj.

> 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...
Well I think if a native method is invoked from java everything is ok, the 
other way makes IMHO trouble with jni. 

Greetings - Thomas
_______________________________________________
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