Updated 2016-08-09 20:00:57 by ABU

http://tcljava.sourceforge.net/ is the home of Tcl Blend. Tcl Blend is a Tcl package that provides access to Java classes from Tcl. Tcl Blend is implemented using JNI. Tcl Blend is production ready software, it is stable enough to be used in production systems on a daily basis.

Jacl and TclBlend are both implementations that make it easy to use Tcl scripting on the Java platform. The Tcl/Java project provides mailing lists [1], online documentation [2], and a bug reporting interface [3].

Links to a number of Jacl and Tcl Blend related articles are also available [4].

For help building Jacl under Windows, see Building TclBlend with msys_mingw.

LV The notes that reside in the tclblend cvs repository seem to indicate that the current incarnation of tclblend works with Tcl 8.4.13, Thread 2.6.3 or greater and JDK 1.4 .

During April 2008, an announcement was made that the TclBlend 1.4.1 release was available online at the sf.net project sight..

Ed Hume I've been able to build tclblend 1.4.1 on a 32bit Linux system with "make test" results as follows (all builds using Thread 2.6.5):
Tcl version jdkresult
8.4.18 1.5ok
8.4.18 1.6only one test failure, JavaImportCmd-2.8 but the test commands work if entered
interactively so this is likely timing and thread related
(there are other test failures that are explained by jdk changes and are not errors) case case

Something is very wrong with using Tcl 8.5 and Tclblend - the first tests to fail are related to setting errorCode or errorInfo results in the interpreter, but there are many errors and segfaults. I am hoping someone who is familiar with TclBlend and 8.4 to 8.5 internal changes may shed some light on the subject.

I test TclBlend 1.4.1 and Tcl 8.6.x on 32-bit Windows platform, and apply patch Compile/Run against Tcl 8.6 . Using Building TclBlend with msys_mingw to build TclBlend and test.

For TIP 330, I also modified src\native\javaInterp.c:
        #if TCL_MAJOR_VERSION > 8 || \
           (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 5)
            ckalloc((unsigned) (strlen(Tcl_GetStringResult(interp)) + 1));
            ckalloc((unsigned) (strlen(interp->result) + 1));
        #if TCL_MAJOR_VERSION > 8 || \
           (TCL_MAJOR_VERSION == 8 && TCL_MINOR_VERSION > 5)
        strcpy(tPtr->errMsg, Tcl_GetStringResult(interp));
        strcpy(tPtr->errMsg, interp->result);

Test script:
package require java
java::import java.net.InetAddress
puts "My IP Address is: [ [ java::call InetAddress getLocalHost ] getHostAddress ] "

Tcl 8.6.0 can execute test script correctly. However, Tcl 8.6.1 or above version fail when TclBlend try to invoke a Java method.
Note: I also test Tcl 8.5.18, can execute test script correctly.

ABU 24-02-2016

I experienced the same fatal errors .. tclblend worked with Tcl 8.4.x, 8.5.x, 8.6.0 and then stopped working.

Here is even a simpler way to get a crash (with tcl > 8.6.0)
package require java
set jObj [java::new java.lang.Object]
puts "jObj is $jObj"                       ;# -->  jObj is java0x1
puts "jObj value is [$jObj toString]"      ;# -->  jobj value is java.lang.Object@123456   (CRASH with TCL > 8.6.0)

I may be wrong, but my guess is that Tcl 8.6.1 introduced a major change with the Non-Recursive Engine (it was not present in (8.6beta)), so all the intricated (to me) stuff about the reference-counting should be reviewed ... WRONG !! NRE was in 8.6beta and 8.6.0

It's a pity; I have a 'stubbed' tclblend that can work from Tcl 8.4 to Tcl 8.6.0 . I know that 'stubbed' TclBlend can be used only in one way (from Tcl to Java and not in the opposite direction), and this worked perfectly for calling complex Java packages (itextPdf, BouncyCastle crypto, ...) .. up to Tcl 8.6.0.

Up to now, my only solution is to distribute my apps with an old TclKit support. Does anyone knows some alternatives for connecting a Tcl interpreter to a JavaMachine ( .. I don't need the opposite direction) ?

ABU 9-04-2016

I submitted a bug (with a fix proposal) to the Tcl-core

See https://core.tcl.tk/tcl/tktview?name=07d13d99b0 for details.

I believe that the crash is due to a change in tclObj.c introduced in 8.6.1. My patched Tcl-8.6.1 (.. 8.6.4) seems to work but of course changes in Tcl-core require a lot of attention.

ABU 9-08-2016 * Restored support for TclBlend.

Tcl 8.6.6, released on late July 2016, restored support for tclblend. Great !

See also