]> juplo.de Git - website/blob
1a36b67f641e2f00db270b76d4087e0b7b9c09ea
[website] /
1 ---
2 _edit_last: "2"
3 author: kai
4 categories:
5   - java
6   - maven
7 date: "2014-07-18T10:32:21+00:00"
8 guid: http://juplo.de/?p=302
9 parent_post_id: null
10 post_id: "302"
11 title: aspectj-maven-plugin can not compile valid Java-7.0-Code
12 url: /aspectj-maven-plugin-can-not-compile-valid-java-7-0-code/
13
14 ---
15 I stumbled over a valid construction, that can not be compiled by the [aspectj-maven-plugin](http://mojo.codehaus.org/aspectj-maven-plugin/ "Jump to the homepage of the aspectj-maven-plugin"):
16
17 ```java
18
19 class Outer
20 {
21   void outer(Inner inner)
22   {
23   }
24
25   class Inner
26   {
27     Outer outer;
28
29     void inner()
30     {
31       outer.outer(this);
32     }
33   }
34 }
35
36 ```
37
38 This code might look very useless.
39 Originally, it `Inner` was a Thread, that wants to signal its enclosing class, that it has finished some work.
40 I just striped down all other code, that was not needed, to trigger the error.
41
42 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:
43
44 ```
45
46 [ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.6:compile (default-cli) on project shouter: Compiler errors:
47 [ERROR] error at outer.inner(this);
48 [ERROR]
49 [ERROR] /home/kai/juplo/shouter/src/main/java/Outer.java:16:0::0 The method inner(Outer.Inner) is undefined for the type Outer
50 [ERROR] error at queue.done(this, System.currentTimeMillis() - start);
51 [ERROR]
52
53 ```
54
55 The normal compilation works, because the class is syntactically correct Java-7.0-Code.
56 But the AspectJ-Compiler (Version 1.7.4) bundeled with the aspectj-maven-pluign will fail!
57
58 Fortunately, I found out, [how to use the aspectj-maven-plugin with AspectJ 1.8.3](/running-aspectj-maven-plugin-with-the-current-version-1-8-1-of-aspectj/ "Read, how to run the aspectj-maven-plugin with a current version of AspectJ").
59
60 So, if you have a similar problem, [read on...](/running-aspectj-maven-plugin-with-the-current-version-1-8-1-of-aspectj/ "Read, how you can solve this ajc compilation error")