Skip to main content

Command Palette

Search for a command to run...

ajc - The AspectJ compiler/weaver

Published
2 min read
ajc - The AspectJ compiler/weaver

Introduction

The AspectJ compiler, named ajc, is a specialized compiler that extends the functionality of a standard Java compiler to support Aspect-Oriented Programming (AOP) with AspectJ.

Key characteristics and functions of ajc:

  • Extension of Java:

    AspectJ is a seamless extension to the Java programming language. ajc adheres to the Java Language Specification and the Java Virtual Machine Specification.

  • Compilation and Weaving:

    ajc compiles both Java source code and AspectJ aspects. Its core function is "weaving," which involves modifying Java bytecode by inserting aspect code at specific "join points" (execution points in the program). This weaving can occur at compile time (Compile-Time Weaving - CTW) or load time (Load-Time Weaving - LTW) with the help of a weaving agent.

  • Aspect-Oriented Constructs:

    ajc understands and processes AspectJ-specific constructs such as pointcuts, advice, inter-type declarations, and aspects, which are used to define and apply cross-cutting concerns.

  • Output:

    ajc produces standard Java .class files that can run on any Java Virtual Machine (JVM) compatible with Java 1.1 or later, although the compiler itself requires Java 8 or later to run.

  • Compatibility:

    ajc is based on the Eclipse JDT compiler, ensuring compatibility with standard Java compilation.

  • Integration:

    ajc can be used directly from the command line or integrated into build tools like Maven through the AspectJ Maven Plugin.

Conclusion

In essence, ajc enables developers to implement AOP concepts in Java by providing the necessary compilation and weaving capabilities to integrate aspects into their applications.

More from this blog

Cloud Tuned

628 posts

Your starting point for anything cloud: AWS, Azure, GCP, Serverless, Architecture, Hybrid Cloud, Systems Design and other Information Technology topics.