On Wed, 28 Jun 2000, Dr Wes Munsil wrote:

> Am I missing something? I do not see this behavior in the 8.2.3 Tcl shell:
> 
> % proc fern {} {
> set x [java::new String foo]
> after 10000 "$x toString"
> unset x
> update
> }
> % fern
> bgerror failed to handle background error.
>     Original error: invalid command name "java0x1"
>     Error in bgerror: invalid command name "bgerror"

The above code should not work, when you unset x you
are dropping the last ref to the object, so the
object should get removed from the reflect table.
The above code worked in Tcl 8.2?

> % proc fern2 {} {
> set x [java::new String foo]
> after 10000 [list eval $x toString]
> unset x
> update
> }
> % fern2
> bgerror failed to handle background error.
>     Original error: invalid command name "java0x2"
>     Error in bgerror: invalid command name "bgerror"

I think the above code would work if you removed the
eval from that list you pass to the after command.

after 10000 [list $x toString]

That should incr the ref count of x and not let it go
until the list itself is released (which I assume
would happen after the after command is finished).

The eval command will convert its arguments to strings.
This has the effect of removing the Java object from
the reflect table right before you invoke the Java cmd.

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/tcljava@scriptics.com

Reply via email to