Search⌘ K
AI Features

Extension of Java Compiler With JastAdd

Explore how to extend the Java compiler using JastAdd by defining aspects, pointcuts, and attributes. Learn to instrument methods for execution time measurement with synthesized attributes and advice, integrating this functionality seamlessly into the Java compilation process.

Syntax of JastAdd

The syntax involves defining aspects, introducing attributes, and specifying how these aspects interact with the existing codebase. Below is an overview of the key syntax elements:

Aspect definition

An aspect in JastAdd is defined using the aspect keyword and stored in a jrag file format. It encapsulates specific functionalities and modifications to the compiler:

aspect MyAspect {
// Aspect-specific code and declarations
}

Attribute declaration

Attributes in JastAdd are declared using the syn (synthesized) or inh (inherited) keywords:

aspect MyAspect {
syn String MyAttribute(); // Syntax for synthesized attributes
inh int InheritedAttribute(); // Syntax for inherited attributes
}

Synthesized and inherited attributes are used to propagate information ...