[AspectJ Support] ajc ran out of memory

Hi,

I am trying to use the AsepctJ Support Plugin to configure ajc for my project. When compiling, ajc throws always an out of memory error:

"AspectJ 1.6.9 ran out of memory during compilation:"

No matter how much memory I give ajc, the problem always occurs. I tried setting the "-verbose" option in ajc properties, but nothing is logged. Could someone give me a hint, how to get more information out of ajc within IDEA?

Thank you,
Timo

[EDIT]
This evening, I gave Spring Roo a chance, to see how this AsepctJ project is configured in IDEA. A fresh Roo project opened in IDEA leads to the same error. I am using Mac OS X. Any ideas?

Nachricht geändert durch Timo Meinen

21 comments

Timo,

which version of plugin do you use?

0

Hi Roman,

I am using AspectJ Support plugin version 0.5 and AspecJ 1.6.9. But I also tried it with 1.6.7 and it didn't work either. Is there a newer version of the plugin available?

0

Hi Timo,

yes, there is version 0.6 of plugin available, with somewhat better compiler error reporting.
Have you tried to compile Roo project by Maven? Does it leads to the same error?

0

Hi Roman,

today I setup a complete new IDEA-Stack: Newest Maia-EAP, new config directory, AspectJ-Support plugin 0.6.

Unfortunately, it doesn't work:

  • Same error during build: AspectJ 1.6.6 ran out of memory during compilation
  • No error messages, even when I set -verbose in the AJC settings
  • Maven builds everything correctly.


Thanks for any help,
Timo

0

Hi Timo,

Found a bug in compiler parameter setting. Will issue an update soon. Sorry.

0

Hi Roman,

thank you for your fast support and bugfix. Good news: My Roo project is working now. Tomorrow, I will try to use the AspectJ Support plugin in our AspectJ project.

0

Hum, it does not work with community edition now: "Plugin "AspectJ Support" won't be able to load because required plugin "com.intellij.modules.ultimate" is disabled.

0

Hi Roman,

Good news first: Our AspectJ project (including Scala sources) builds now completely with the new version of the plugin. Bad news: It is not usable in daily development process:

  • The speed of the AspectJ compiler is three to five times slower than the Maven build. Maven lets the compiler plugin compile all Java files and then the aspectj-maven-plugin only compiles the aspects and weaves them into the classes.
  • It seems that the AspectJ Support plugin doesn't compile changed files only. Even if I change a single source file, make will compile all files once again, which last long.
  • I couldn't get the -verbose option to work and the weaveinfo, neither.


Is it possible to configure the compilers in a "two-step way"? First, the normal fast Java compile process of IDEA should do all the work it can, and then the AJC should be used to compile the aspects and weave them. I think the workflow should be similar to Mattias Jiderhamn's aspectjweaver plugin, which we are using at the moment. The disadvanteges of the aspectjweaver plugin are, that it can only be used on precompiled aspects.

For our purposes it would be sufficient if the aspectj support plugin compiles and weaves all .aj files and if the aspectpath (I think it's called inpath in AspectJ terminology) would be configurable.

0

Hi Timo,

It's a bit complicated.
On small projects Maven could be faster because it a) doesn't analyze source dependencies, b) starts once and performs all compilation in-process, c) doesn't compile production and test sources in one shot, and d) doesn't build and maintain incremental compilation caches.

How Maven compiles depends on configuration of you project, of course, but in typical setup (e.g. any Spring Roo project) pom.xml contains both "maven-compiler-plugin" and "aspectj-maven-plugin" configured, and fires both: first,  AspectJ compiler is executed to compile both Java and AspectJ files, then Java compiler runs only to find that class files are up to date and it has nothing to do. It is quite clear visible if start Maven with debug output turned on.

There is a strong reason to compile Java sources by AspectJ compiler: ITDs. Java compiler just won't be able to resolve a call for a method introduced in AspectJ file. So at the moment "compile only aspects and weave" mode isn't planned.

IDEA tries its best to compile changed files only. As a quick test you can make a project twice - it should say "Compilation completed successfully" on first time and "All files are up-to-date" on second. If you will find a reproducible case when IDEA compiles unchanged files please post an issue in a tracker.

"-verbose" option is set by IDEA behind a curtains - it's output used by IDEA to monitor compilation progress. But compiler output console isn't a plain text dump: compiler output is parsed and only messages considered important are allowed to it. If you feel the need to see weaver messages in IDEA please create a feature request in tracker.

0

Hi Roman,

thank you for pointing out the differences between Maven and IDEA build. It helped me a lot to understand the problem und find the problem in my build.

In my first try it took over 4 Minutes for a complete build of our project in IDEA (Maven needed 1 Minute for a complete build) and a second hit on "Make" took over 2 Minutes, without a file being touched. Then, after some time testing, the AJC threw OutOfMemoryErrors and I realized that the heap was too low, even it was set to 768m already. However, after pushing the heap up to 1280m, everythings works smoothly. A fresh rebuild of the project takes now only 1:35 minutes, direct make after this is done in no time (everything is up to date, like you said) and if I change a single file IDEA beats Maven (0:17 vs. 0:38). Of course, the times are not representative, but they show, that AJC seems to be very sensitive against the heap size and therefore its performance.

Thanks for your help. We now have a perfect IDE for a mixed Java, AspectJ, Scala project. I hope, the AspectJ support will improve further, because AOP is hard without the ability to debug. And of course it would be great to have some IDE support in writing native AspectJ code, not only for Roo.

Best regards,
Timo

0

Hi Timo,

glad to hear it works.
Debugging support will be added before IDEA X release, full AOP support - in next release.

0

Hi Roman,

that are good news! "next release" means IDEA X?

BTW: Forgot to mention, that I got it to work with the IDEA X EAP and the new plugin version of "AspectJ support".

0

Sorry. I mean that debugging - in IDEA X, AOP - in release after IDEA X.

Separate plugin is needed for IDEA 9 only. In IDEA X it comes bundled in.

0

Hi,

I have tried to evaluate Ultimate Edition of IntelliJ IDEA to see how this plugin works in it as latest versions  require ultimate edition (btw, why it is so, will it be community edition version ever for it?).

Unfortunately, the latest version of AspectJ plugin that is available form my Ultimate Eval is 0.5. I have downloaded the plugin of version 0.61 directly from the plugin page and tried to copy it to plugins/ directory but IDEA does not want to enable it either (marks it with red color). What did I do wrong?
I have also community edition installed, can it interferes with Ultimate for the subject?

0

Hi Nikita,

0.6.1 requires latest Maia EAP.
IDEA X comes with plugin bundled.

At the moment there is no plans for moving plugin to the community edition.

0

Thank you, Roman.

Unfortunately 0.61 version does not solve my initial problem: smart recompilation does not work well with it. If I change one java file that is subject for aspects weaving, not all aspects are actually weaved in "Make Project" mode: some are weaved but not all. I have to say "Rebuild Project" to make things work that is not convenient (full recompilation takes long).
I have tried to make small reproducing example but currently failed with it -- if a sample is small, smart recompilation works.
Would you be interested in such example if I continue with it? Should I create JIRA issue for it? Can this problem be in ajc itself but not in plugin?

0

That's because AspectJ plugin doesn't support AOP statements at the moment - so it is just unable to detect classes affected by changes in aspects. I've created an issue.

0

I meant opposite. I do not change aspects but change a java file that is subject for (not-changed) aspects weaving. Some of the aspects are weaved into changed java class but some of them are not in "Make project" mode.

0

Hi Nikita,

I cannot confirm this. All our aspects are woven into the corresponding Java file after changing the Java file and incremental build.

In our project, we configured the Aspect path with Maven and the aspectj-maven-plugin. The IDEA plugin seems to pick this up, without configuring it in the compiler settings. We are using different modules: one for aspects and one for the Java files. Then, the aspects module is conifgured as aspectpath in Maven like this:

<plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>aspectj-maven-plugin</artifactId>
        <configuration>
          <aspectLibraries>
            <aspectLibrary>
              <groupId>YOUR.GROUP</groupId>
              <artifactId>YOUR.PROJECT-aspects</artifactId>
            </aspectLibrary>

...

This works good in our project.

Like I mentioned earlier in this thread, we had to increase the heap of ajc dramatically to -Xmx1280m, to gain good performance with the compilation process.

0

I cannot confirm this. All our aspects are woven into the corresponding Java file after changing the Java file and incremental build.

You are lucky .

In our project, we configured the Aspect path with Maven and the aspectj-maven-plugin.

We do not use Maven and are not going to use it.

We use AspectJ for unit testing. When I change a test, I would like to immediately run it. If I just click Run button, my test does not pass because some aspects were not woven into the test. If I click "Build/Rebuild Project" and then click "Run" button my test passes. I use Ajc as Java compiler and my JUnit run configuration is configured to do only "Make" before launch.

0

I understood your problem. I would recommend to give module separation a try, as it solved our problems. Package your Aspects as a single module and weave the aspects as ajc compiler option (-inpath).

With Maia release of IDEA, the AspectJ support plugin, doesn't work with our project. Here, we use the AspectJ Weaving plugin from Mattias Jiderhamn and it works quite good. The only backdrafts are, that Aspects have to be precompiled (which is no problem with the above mentioned module solution) or you have to use annotation style syntax, which permits ITDs.mattias.jiderhamn@expertsystems.se

0

Please sign in to leave a comment.