Skip to main content

AspectJ

Simple Story

AspectJ covers every place in the room where a forbidden request could be written down, so the teacher is already standing there when it is.

That works for the parts of the room you set out yourself. It cannot help where the request is written somewhere you never set out, such as deep inside Java itself.

What it is

AspectJ is the aspect-oriented programming (AOP) extension of Java: a language for aspects, plus a compiler and a weaver that place advice into bytecode.

How Ares 2 uses it

AspectJ is one of the two runtime enforcement backends, selected by the ASPECTJ half of the programming language configuration. The Ares JAR goes on the aspect path so its aspects are woven into the exercise.

What follows from call-site weaving

AspectJ intercepts at the call, not at the target. It rewrites the place where the call is written, which means coverage is an enumerated list of call sites the weaver could see:

  • a call made from inside the Java Development Kit (JDK) has no woven call site;
  • a reflective or library-mediated call reaches the target without passing a woven site;
  • coverage grows only by naming more call sites.

The repository documents this in detail, including the one case where AspectJ is stronger than instrumentation, in AspectJ versus Instrumentation.

Further reading