Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Why are base types required in classpath for ajc?

Hi,

I have an aspect for the "onCreate" method of an Android Activity class. 
  aspect OnCreate {
      pointcut captureOnCreate() : (execution(* onCreate(Bundle)));
      //...
  }

I also have an android app with a subclass of android.app.Activity (the
MainActivity class).
  public class MainActivity extends Activity {
      public void onCreate(Bundle savedInstanceState) {
          //...
      }
  }

I build the aspects and my app separately, and then use ajc to build the
final product and weave the aspects.

java -classpath
"aspectjtools.jar;aspectjrt.jar;%JAVA_HOME%\lib\tools.jar;C:\ADT\sdk\platfor
ms\android-17\android.jar"
   -Xmx64M org.aspectj.tools.ajc.Main -nowarn -Xlint:ignore 
   -inpath "myapp.jar;myaspects.jar;aspectjrt.jar" 
   -outjar "myinstrumentedapp.jar"

(some paths omitted for brevity)

This works fine, the aspects are woven, and my app is now "instrumented"
with my aspect.

My question is around the inclusion of android.jar on the ajc classpath.
This library is NOT required here to successfully build (assemble) the final
jar file; I can omit it and the app is built correctly and runs OK, but the
aspects are not woven.

What is it from the android.jar library that ajc requires?  I am guessing
the base-most declaration of the onCreate method?
Is there a way around this?

Would it be possible to make a "fake" android.jar with the correct
declarations; such that I could distribute the fake android.jar and
myaspects.jar to a 3rd party, and have them (with no jdk or android sdk,
only a jre & ajc) re-assemble one of their own apps to include the aspects?

Thanks,
Mike.




Back to the top