0

I am using aspectj-maven-plugin to generate loggers in methods, and the approach is annotation driven.

Upon compiling, for every method the annotation is defined, I can see a ***$AjcClosure*.class file getting generated in my respective target class file folder.

Issues :

  1. Although this is a compile time activity, is there any way I can avoid having these classes sitting in my class file folder once compilation is over?

  2. If not, what is the purpose of these classes and won't they affect the size of the jar/war file getting created, and thus an overall overhead for every single annotation being added in the application?

Java Version : 1.7 & AspectJ Maven Plugin current configuration :

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>aspectj-maven-plugin</artifactId>
    <version>1.5</version>
    <configuration>
        <source>${java.version}</source>
        <target>${java.version}</target>
        <complianceLevel>1.7</complianceLevel>
    </configuration>
    <executions>
        <execution>
            <goals>
                <goal>compile</goal>
            </goals>
        </execution>
    </executions>
</plugin>
coretechie
  • 1,050
  • 16
  • 38
  • Why is the presence of those classes an issue? They are needed for AspectJ to work correctly. – Tunaki Feb 06 '17 at 09:31
  • Hi Tunaki, upon decompiling I can see that these classes are empty. `class{}` only this much is the code available. What could be the need of such a class? Also when I am running the project build through command prompt, these classes are not generated then.. – coretechie Feb 06 '17 at 09:57
  • Perhaps you're being fooled by the decompiler... – Tunaki Feb 06 '17 at 09:59
  • Well, what can I say to this comment :) I run on proofs! – coretechie Feb 06 '17 at 10:36
  • Also, I am repeating the point 2 here that, is creating one file for each annotation added in the source code - for whatever purpose it may be, a good code/idea at all? – coretechie Feb 06 '17 at 10:59

1 Answers1

0

After doing several trials and errors I figured that @Around advice is causing these classes to be created. Please refer White paper on optimizing Aspects for more details.

Now, I am using @Before & @After advices to achieve the purpose of logging, before and after the method.

I may be wrong, but this worked for me. Please feel free to post your comments.

coretechie
  • 1,050
  • 16
  • 38