TJC is a Tcl to Java converter and compiler. TJC accepts Tcl source
code and translates
proc declarations to Java source
code. Generated Java source is then compiled to Java bytecode.
The TJC compiler supports two operational modes, batch mode and runtime
In batch mode, a user invokes the
on the command line and passes a
.tjc module file name.
TJC scans a set of
.tcl files looking for proc declarations
and then converts the discovered Tcl procs to Java source code
that implements the equivalent operations. Generated Java source code is
javac, then both the generated source code and
bytecode are stored in a JAR file.
tjc module.tjc ?module.tjc ...?
The TJC compiler loads JDK configuration information from a file named
jdk.cfg. This JDK configuration file must be saved in the
bin/ directory where tjc executable is installed.
See JDK Config File for more info about
the contents of a JDK config file.
Processing a module file generates a pair of JAR
files. The first JAR file contains compiled Java class files and
modified Tcl scripts. The second JAR file contains generated
Java source code and unmodified Tcl scripts.
For example, a module file
xyz.tjc will generate
xyz.jar. A TJC module
file indicates which Tcl source files will be read and compiled
tjc. See Module File
for more info about the contents of a module file.
A set of Tcl scripts and compiled proc implementations packaged inside
a JAR file is known as a tjc package. A tjc package is loaded into
Jacl by adding a generated JAR file to the
and then invoking the
TJC::package Tcl command to load compiled commands
into the shell. See TJC package manual for more info.
The TJC compiler supports a runtime mode that makes it easy to
define a Tcl
proc in an interpreter and compile
directly to Java bytecode. The TJC compiler runs in a second
thread, waiting for compile requests from the
command. When a Tcl proc has been compiled, the original
proc is relaced with the compiled implementation.
TJC makes use of the excellent
embedded Java compiler to convert generated Java source code
to Java bytecode.
In most cases, runtime mode is easier to use
since one need not create a module file
or modify the
mode may be preferrable when a large number of
Tcl procs need to be compiled, since compiling
a lot of Tcl procs can take some time.
Users should note that Jacl does not compile
Tcl procs into Java bytecode by default, the user must
explicitly indicate which procs should be compiled.
See the TJC package manual
for more info.
See Simple Example for a step by step walk
through of using the TJC executable and TJC package to compile and load
a compiled Tcl
See Generated Code Example for examples of Java source generated by the TJC compiler.
See Writing Optimal Code for some general Tcl optimization tips and preferred command usages.
See Future Improvements for a description of features that could be implemented in a future release.