java2tcl - Java to Tcl/XOTcl source code transformation

java2tcl transforms Java source file to Tcl source file. XOTcl object system is used for class/object transformations. The main application is developed in the TXL programming language.

Sample Java to Tcl transformations are available to see how it works.


23.03.2009 Project is now hosted at (files and sources)

12.01.2009 Source code is available

26.12.2008 Windows version broken binary bug fixed

Installation and usage


OS: Linux, Windows

To launch transformed source you will need a fresh Tcl with XOTcl extension installed. If you are not familiar with Tcl ActiveTcl might be a good choice for you.

Important: Line feeds of input files have to correspond to your platform. E.g. <OA> for Linux. Input files should not contain unicode or other strange symbols.


java2tcl package version 1.1 is available at:


Use demo mode to see how it works.

Demo mode

Launch demo.tcl

Single file mode

java2tcl JavaSourceFile

Conversion notes

Java 1.5 grammar used for parsing input files. In the most cases it will fail to convert a complex Java source completely and correctly. Manual fixes will be required almost always to make the output working.


Constructors are converted to class procedures with name ClassName{_ParamType}. E.g. for MyClass(String a, DB db) constructor will have the name MyClass_String_DB. Type is ignore for literals.


Unary operations ++,--

Pre- operations are converted to post- operations. E.g. ++i becomes i++.

Arithmetic operations

Arithmetic expression are converted with expr. String concatenations are also converted with expr. Arithmetics in println is converted to string with concat.

Assignment arithmetics

Only += -= /= *= %= are processed in the form of a += b; becomes a = a + (b);

Naming conventions

Identifiers within a method/constructor body if they are not class members are considered to be local variables if start from lower case letter and class name in other case.


Java exceptions are converted to Tcl's catch/error. XOException seems to be a good candidate for Java exceptions conversion, but the situation with garbage collection is not easy for this approach - counted failed on simple tests. finally is ignore, all catch bodies are put into one block.


In some cases deep inclusive dot operations might be misconverted, e.g. obj.getEntry().fetch().name = fill().getFirst;

Conditional choice

Works correctly only for a single operation

Missing features

Garbage collection

counted is a good candidate to be used. It worked fine on small tests. -volatile option may be used also

Methods polymorphism

Currently if you have several same name methods (except constructors) with different types you will get the same in Tcl.

Many more

A lot of missing features are available

transformation/java2tcl/start.txt · Last modified: 2009/06/07 12:54 by Mykhaylo Sorochan
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Share Alike 3.0 Unported
Recent changes RSS feed Driven by DokuWiki