Ajmlc: The First RAC compiler with Client Verification CapabilityHenrique Rebêlo, Ricardo Lima, Gary T. Leavens
Motivation
The current implementation of the JML (RAC) compiler does not catch some contract violations
that are detectable by the static checker ESC/Java2 and now by ajmlc (since version 2.1).
Since the precondition that is checked on a method call is based on the method dynamic's
type [2]. For example, an error can be introduced if the precondition declared for the static type
is violated whereas the dynamic type's when weaken such a precondition is not. In this case the current
jml compiler [2] does not catch such a precondition violation, whereas the static checker ESC/Java2 does detect.
The goals of the ajml tool with call site verification are
|
Getting StartedAfter you have successfully downloaded AJML tools, you are ready to start using it. Follow the following steps to get started with AJML.
1) Unpacking the zip fileUnpack the zip file in a folder which its path is c:\JMLAfter unpack, you see c:\JML\AJML-2.4Note that you can unpack in another folder, but if you want to keep the default configuration of the .bat files, which are part of the AJML release, you should keep the standard folder.
2) Running the toolsTo run the ajml checker, from a command prompt, execute ajml file1.java file2.jml To use the AspectJ runtime assertion checker compiler, use the ajmlc .bat script, for example: ajmlc file1.java Note that the default weaver (AspectJ compiler) of ajmlc is the ajc, if you want to compile JML features using another weaver, use the following: ajmlc -aspectJCompiler "abc" file1.java To use the AspectJ runtime assertion checker compiler with both client and server side verification, use the ajmlc .bat script, for example: ajmlc file1.java -callSiteInstrumentation To use the AspectJ runtime assertion checker compiler with only client side verification, use the ajmlc .bat script, for example: ajmlc file1.java -onlyCallSiteInstrumentation 3) Running programs compiled with ajmlcTo run Java programs where some (or all) of the class files have been compiled with the AJML compiler (ajmlc), you will need to have the classes compiled in your Java "CLASSPATH". However, just having these classes in your "CLASSPATH" is not enough. In addition to the compiled class files, you have to run a ajmlc-compiled program with AJML/bin/ajmlrt2.4.jar in your "CLASSPATH". There is a .bat file for doing all of this easily. This script is called "ajmlrac". You would use it instead of the normal Java virtual machine ("java" command), as follows: ajmlrac my.package.name.ClassnameOfMain where "ClassnameOfMain" is the class name of the class containing your program's main method, and "my.package.name" stands for the name of the package where "ClassnameOfMain" is found. |
Getting Started using EclipseAfter you have successfully downloaded AJML tools, you are ready to start using it. Follow the following steps to get started with AJML within Eclipse platform.
Warning: this is not an Eclipse-based plugin for ajmlc. However, you can easily use ajmlc
within Eclipse by using a custom Ant task, which is a part of the AJML release.
1) Demo Project
2) Copying the AJML stuffAfter you have successfully downloaded AJML tools, you should copy the jar files inside the "bin" folder and all AJML libraries contained into "ajml-lib" folder to a new folder named "lib-ajmlc2.4" within your DemoCallSiteVerification project. Afterwards, your project structure should look like as the figure below:
3) Compiling and Running the Demo program with AJMLTo compile and run the Demo program using AJML, you need only to set some properties in "build.xml" file (you can see such a file in the project structure depicted above). (see details in the figure below). In order to enable the client side verification, you should set on of the options illustrated in the figure below. If both options are false, the ajmlc only performs server side verification. If the first one (callsiteinstrumentation) is enabled to true, then the ajmlc performs both client and server side verification. To perform just client side verification, the second option illustrated (onlycallsiteinstrumentation) must be set to true (as in the figure below). In addition, you can see the AJML tasks in the ANT editor. First of all, open the ANT view in Eclipse as following: Window -> Show View -> Ant Then in order to view the ant tasks provided by the "build.xml" file, you should drag and drop it in this view. Afterwards, you will see the main tasks as illustrated in figure below. Now you are able to run AJML tools using ANT task. Click twice in the "ajmlc" task and then twice in the customized "ajmlrac" task (e.g., ajmlrac-PointClient1). We create customized tasks to run each client in this demo project. The results is illustrated in figure below Note: each client presented in the above buiding file, presents a specific result due to its visibility rules, even if the call is the same for all of them. References
|