Version 12 of Jacl

Updated 2002-12-11 20:47:12

http://sf.net/projects/tcljava is the home for TclBlend as well as Jacl. Jacl is an alternate implementation of Tcl, this time written entirely in Java.

There is an active mailing list at the web site which provides support for Jacl [L1 ].


As of September 2001, Neil Madden has what he calls a rudimentary implementation of socket.


Several Jacl-oriented stories have been published through the years, including "Extending XML tools with Jacl scripts" [L2 ].


CL occasionally updates a page [L3 ] of information related to Jacl.


Swank is an interesting extension to Jacl.


Neil Madden writes, "To try out Jacl, make sure jacl.jar is in your classpath (it should be from what you say), and then open a command line and type:

    java tcl.lang.Shell

after a second or so you should see the familiar % Tcl prompt and you can fire away. If you want to extend your Java application using Jacl, then just import tcl.lang.* and look at the docs which come with Jacl for some pointers at how to use the APIs."


Martin Lemburg I'm experimenting the first time with Jacl and have following problem.

I evaluate a tcl script inside the Jacl interpreter and the result is following:

    {"" "platform information:" {os {Windows 2000}} ...}

I want to test if an object inside the list is a list or something else by this:

  1    TclObject     result, element;
  2    TclList       list, subList;
  3    ReflectObject reflectObj;
  4
  5    result     = ip.getResult();
  6    element    = null;
  7    list       = (TclList) result.getInternalRep();
  8    subList    = null;
  9    reflectObj = null;
 10
 11    for ( int idx = 0 ; idx < list.getLength( ip, result ) ; ++idx )
 12    {
 13        element    = list.index( ip, result, idx );
 14        reflectObj = (ReflectObject) element.getInternalRep();
 15
 16        if ( reflectObj.getClass == TclList.class )
 17        {
 18            // ... use as list ...
 19        }
 20        else
 21        {
 22            // ... use as "not" list ...
 23        }
 24    }

When casting from the internal representation of the first element of the list - here an empty string - to the ReflectObject type (in line 14) I get the exception "java.lang.ClassCastException" (detailMessage: "tcl.lang.TclString")

So I experimented a bit and I tried just to get the ReflectObject of the internal representation of the interpreter result and I got the same exception "java.lang.ClassCastException", but with the detailMessage: "tcl.lang.TclList".

I used the verbose option of javac ... javac loaded the class tcl.lang.ReflectObject. I used the verbose option of java ... java didn't loaded the class tcl.lang.ReflectObject.

So what can I do? What goes wrong?

Thanks for any hints, suggestions!

Best regards

Martin Lemburg


Martin Lemburg again ... I found the errors, many errors. Here my "new" and working version:

  1    TclObject     result, element;
  2
  3    result     = ip.getResult();
  4    element    = null;
  5
  6    for ( int idx = 0 ; idx < TclList.getLength( ip, result ) ; ++idx )
  7    {
  8        element    = TclList.index( ip, result, idx );
  9
 10        if ( (element.getInternalRep()).getClass() == TclList.class )
 11        {
 12            // ... use as list ...
 13        }
 14        else
 15        {
 16            // ... use as "not" list ...
 17        }
 18    }

See also Java.


At http://www.javaworld.com/javaworld/jw-04-2002/jw-0405-scripts_p.html is an article comparing Jacl with several other scripting environments for Java.


Category Language