Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Weaving AspectJ aspects included in an Eclipse 3.7 plugin project

Goal

I am building an Eclipse plugin targeting the 3.7 environment and would like to include an aspect in the plugin that provides advice on code that is also in the plugin.

Setup

I have been trying to follow along with the spirit of these guidelines as best I can considering the apparent differences between 3.4 and 3.7: http://www.eclipse.org/equinox/incubator/aspects/equinox-aspects-quick-start.php

Here is what I have so far:

  1. A plugin project with the aspect and some source.
  2. The plugin project has been converted to an AspectJ project, which triggered Eclipse to automatically add org.aspectj.runtime (1.6.12) to the plugin's dependencies.
  3. I checked "Reexport this dependency" on the org.aspectj.runtime dependency in my plugin configuration.
  4. I defined the aspect in an aop.xml in my META-INF directory.
  5. My MANIFEST.MF has an Export-Package entry on the package that the aspect is in.
  6. My run configuration includes the following plugins and start levels:
    • org.eclipse.equinox.weaving.aspectj (start level of 1)
    • org.eclipse.equinox.weaving.hook (start level of default which is 4)
    • org.aspectj.runtime (start level of 1)
    • org.aspectj.weaver (start level of 1)

Current results

I see lines in the console that look like this, but it appears that this processing occurs the first time each class is classloaded.

[com.my.traceeditor] info processing reweavable type com.my.util.ByteUtil: com\my\util\ByteUtil.java

No advice is being applied. Is it possible the weaver isn't weaving early enough? What to do?

like image 234
Jonathan Schneider Avatar asked Nov 04 '22 22:11

Jonathan Schneider


1 Answers

When you are writing an aspect that is only to be applied in the same bundle, then you don't need equinox weaving. That is only for cross-bundle weaving. You can remove the dependency on the weaving plugins as long as you make sure that your bundle is using compile-time weaving.

like image 110
Andrew Eisenberg Avatar answered Nov 12 '22 19:11

Andrew Eisenberg