...
> I am encountering this problem right now in a different form. I am
> constructing an asynchronous callback function inside Java using a TclList
> object, {command_name java_obj_1 java_obj_2}. The list contains some Java
> objects, which are the arguments to the callback function. However, when
> the callback function is invoked, the function is getting the string
> representation of the argument rather than the real Java objects. This is
> not good because you can't easily find your Java object given a string
> representation.
You mentioned that doing an after with a list object solved the problem,
but here you are using a TclList so it should incr the ref counts of
the objects in the list. Seems like that should work, I guess I
do not understand why your method arguments would be getting converted
to strings instead of TclObjects. Is this something that Interp.eval()
is doing?
> I wonder if similar problem happens in the C world. But a C object can
> always use a pointer address as its string representation. Then, given the
> string representation, a valid C object can be found.
The problem is the mixing of GC and a type that can not be converted to
a string. You can not convert a Java reference into a string because
the GC system does not see that as a valid reference. You could convert
a C pointer into a string and then back to a pointer but you would
need to manage that memory on your own. In fact, Tcl Blend does this
sort of thing behind the scenes, it stores a C pointer inside a Java
long. It then converts this back to a pointer that is uses to find
the actual object (yes it is scary and wrong, but JNI sucks so we
are stuck with it).
Also, that convert a pointer to a string and back again trick
would not work if you were using a GC for your C code.
Mo DeJong
Red Hat Inc
----------------------------------------------------------------
The TclJava mailing list is sponsored by Scriptics Corporation.
To subscribe: send mail to [EMAIL PROTECTED]
with the word SUBSCRIBE as the subject.
To unsubscribe: send mail to [EMAIL PROTECTED]
with the word UNSUBSCRIBE as the subject.
To send to the list, send email to '[EMAIL PROTECTED]'.
An archive is available at http://www.mail-archive.com/[email protected]