The Java language was designed with the explicit goal of excluding all troublesome features that can be found in C++, by disregarding some of them (e.g. globals), and disciplining other ones (e.g. pointers). For several companies the migration to Java is not strategically feasible. Nevertheless, the adoption of its philosophy within C++
code could help improve the quality of the software. Cjj is defined a subset
of C++, which is compliant with Java, in that it
enforces a Java-like programming style, while forbidding all C++ constructs
that are in contrast with it. The rules which define ithis mapping are stated in the paper by
Paolo Tonella and Alessandra Potrich.
The following figure depicts the relationship between Cjj, C++ and Java.
Mapping Java to C++
Constraint Verification tool:
A tool, called RuleChecker, was developed for the verification of the compliance of an input source with Cjj [Sugandh Mittal]. It verifies if any of the
constraints defining Cjj is violated. RuleChecker parses an input C++ program and builds a net of objects
associated with syntactic entities and relations encountered in the
code. Such analysis is based on a very general model of the C++
language, that can be easily extended in an incremental way. If the given input source does not violate any of the rules, then it is valid Cjj, otherwise the source has to modified to make it compliant with the violated rules.
Constraint Verification Process
Utility Classes:
A set of utility classes should
be available in a realistic Cjj programming environment. They represent a
minimal library replacing or wrapping the main C++ facilities and core
functions that are not adherent to Cjj. They are derived from the Java
library, so that additional details on their expected interface and
organization can be found in the literature about Java.
Utility libraries provided in a working Cjj
framework are not required to preserve the names and organization of the
classes and methods described in Java.
Installation/Execution:
The jar files containing the RuleChecker tool(Cjj.jar), some basic utility classes (lib.tgz) and a Binary Tree example of a valid Cjj code(bnt.tgz) are available for download.(Right click on the above links and click "Save Link As")
After downloading the files, the classpath needs to set to the path where Cjj.jar is stored. Foe example, if Cjj.jar is stored in /max/arbit/my/ then the following command sets the classpath in linux: setenv CLASSPATH /max/arbit/my/Cjj.jar/
Before running the tool, the given input source is compiled and then preprocessed. If the given input is Sugs.cpp, then it is compiled and preprocessed by the following commands: c++ -c Sugs.cpp c++ -E Sugs.cpp > Sugs.i
This .i file is then passed as a parameter to the tool. It is run in the same directory in which Sugs.cpp and Sugs.i are, by the following line command: java rules.RuleChecker Sugs.i
The output of this command specifies which rules are being violated by the current Sugs.cpp code, which should be modified accordingly then, and the RuleChecker should be executed again(See the above figure).
Registration:
This CJJ software can be freely distributed and is a public domain code. Kindly register yourself by clicking HERE, if you are interested in the CJJ software.
To submit any bugs or features mail at: tonella@itc.it
Thanks very much!