Chapter 7. Java Compiler for WCET Annotations

Table of Contents

Annotation Data Format
Dump Annotations Utility

Volta is certainly not the first set of tools for WCET analysis for Java. Several such prototypes have been created, and more are under development. Unfortunately, each relies on a competing and incompatible convention for annotations, resulting in portability problems and duplication of effort. For example, the Skånerost tool uses annotations that look like /*$ loop-bound 10 */, while the annotations in JOP's WCA tool look like //@WCA loop=10. Each tool requires custom parsers for these annotations, and source code written for one tool cannot be analyzed by the other without a rewrite.

Java's own annotation mechanism could solve these problems. The standard annotations in Java would provide a common platform for WCET analysis, improving portability and reducing the effort necessary to create analysis tools. However, Java annotations cannot be placed on critical source code statements such as loops, rendering the mechanism useless for WCET annotations.

The JSR-308 committee is currently investigating the possibility of removing this restriction, as discussed in the JSR-308 Statements document. In the meantime, the Volta tool suite includes a modified version of the standard Java compiler that allows annotations on loops. It parses the annotations for correctness and creates a representation of them in the Java class output. Tools such as Clepsydra can obtain the annotation parameters by loading the class attributes using BCEL or a similar tool.

To use this customized Java compiler, simply build and run it as you would the standard javac compiler. Instructions are available at the OpenJDK web site.

Annotation Data Format

The modified compiler writes annotation data to class files as method attributes called RuntimeVisibleStatementAnnotations and RuntimeInvisibleStatementAnnotations. The format of these attributes is identical to the existing RuntimeVisibleAnnotations and RuntimeInvisibleAnnotations attributes (described in the Java 5 update to the Java Virtual Machine Specification) except that an additional field has been added following u2 type_index:

u4 pc;

This field holds the bytecode offset of the start of the loop.