aspectj-maven-plugin can not compile valid Java-7.0-Code
I stumbled over a valid construction, that can not be compiled by the aspectj-maven-plugin:
class Outer
{
void outer(Inner inner)
{
}
class Inner
{
Outer outer;
void inner()
{
outer.outer(this);
}
}
}
This code might look very useless.
Originally, it Inner
was a Thread, that wants to signal its enclosing class, that it has finished some work.
I just striped down all other code, that was not needed, to trigger the error.
If you put the class Outer
in a maven-project and configure the aspectj-maven-plugin to weave this class with compliance-level 1.6, you will get the following error:
[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.6:compile (default-cli) on project shouter: Compiler errors:
[ERROR] error at outer.inner(this);
[ERROR]
[ERROR] /home/kai/juplo/shouter/src/main/java/Outer.java:16:0::0 The method inner(Outer.Inner) is undefined for the type Outer
[ERROR] error at queue.done(this, System.currentTimeMillis() - start);
[ERROR]
The normal compilation works, because the class is syntactically correct Java-7.0-Code. But the AspectJ-Compiler (Version 1.7.4) bundeled with the aspectj-maven-pluign will fail!
Fortunately, I found out, how to use the aspectj-maven-plugin with AspectJ 1.8.3.
So, if you have a similar problem, read on…