Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Using the -injar compiler option

I'm trying to write some unit tests which invoke code which references some Java classes directly. As such, it is hard to use a Mock object implementation to allow the test case to run without accessing the real Java class. I notice that the AspectJ compiler has an option called 'injars' whose description seems to imply that aspects can be woven into classes found in the 'injar' files. I figured I would try using ajc on the Java rt.jar file to see if I could generate a new version of the jar file which had the hooks I needed to support my unit testing. Unfortunately things didn't work out and I'm wondering if this is because of a bug, or because I'm trying to do something that ajc isn't really designed to handle. What I did was the following:

1. Generate a 'unitTestAspects.jar' file from ajc by compiling my aspect and using the -outjar option to put the compiled aspect into a jar.

2. Ran the ajc compiler as follows:

  ajc -injars rt.jar -aspectpath unitTestAspects.jar -outjar rt_aj.jar

After fixing an OutOfMemory error by increasing the memory available to ajc, I ran the compiler once again. After a period of time the compiler aborted with the following:

java.lang.StackOverflowError
       at org.aspectj.weaver.bcel.Utility.getSourceLine(Utility.java:436)
       at org.aspectj.weaver.bcel.Utility.getSourceLine(Utility.java:436)
       ...

I'm running with AspectJ 1.1rc2 on Windows XP with JDK 1.4.01.

Thanks.

--
James Howe


Back to the top