5

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?

Jonathan Schneider
  • 26,852
  • 13
  • 75
  • 99
  • I should also mention that a JUnit test written in the same project that is designed to test the aspect works as expected -- advice is applied. The pointcut definition is definitely not the problem. – Jonathan Schneider Jun 14 '12 at 20:02
  • Thanks a lot! I was trying to advise methods using Equinox AspectJ from aspects in another bundle and somehow the aspects were not being honored. Having a run configuration as described in #6 help fixed my problem – Vikram Feb 05 '13 at 19:15

1 Answers1

2

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.

Andrew Eisenberg
  • 28,387
  • 9
  • 92
  • 148