Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] LTW, javaagent, JUnit and ANT integration

Hello Alexandre, thanks for your answer.

Alexandre Vasseur :
"-javaagent:externals/aspectjweaver.jar"
corrected this one.
If you do weave with ajc
what else could I use to weave ?
 and are planning to use LTW, you must use the
-Xreweavable option 
  
i followed your suggestion: i compiled the aspects with ajc -Xreweavable -source 1.5 MyAspect.aj

-verbose  and -showWeaveInfo should print something with LTW
Another option that can help is a -Daj.weaving.verbose=true on the
command line to see some lines of log before we actually figure that
you asked for -verbose in the aop.xml file(s).
now when i launch junit test i got a long log,which looks like the following:

 [junit] Running org.aormf.tests.AllTests
 [junit] error can't find type sun.reflect.GeneratedConstructorAccessor1
 [junit] WeavingAdaptor.weaveClass sun/reflect/GeneratedConstructorAccessor1
 [junit] WeavingAdaptor.weaveClass org/apache/tools/ant/taskdefs/optional/junit/JUnitTestRunner
 [junit] WeavingAdaptor.weaveClass junit/framework/TestListener
 % ------------ CUT----------------%
 [junit] error can't find type org.objectweb.fractal.julia.generated.C15a8d50e_0
[junit] WeavingAdaptor.weaveClass org/objectweb/fractal/julia/generated/C3bbeabff_0


So, i suppose that LTW is turned on.

Why do i get those can't find type ? I have an idea about the second one, but what about the first ?

For the first one, here is the scenario: the C15a8d50e_0 is generated at runtime (its bytecode is generated using ASM): this class is a subclass of a given interface, which also contains a marker annotation on the class header.
My aspect is defined so that it should intercept any class where an annotation is present:

public aspect ExecutionMonitorAspect {

                /* intercept a call to an managed resource */
        pointcut annotatedResourceInvocation():
                        call(* *(..)) && @annotation(MemberOfMonitoredSet);

        before(): annotatedResourceInvocation(){
        System.out.println("EMAspect: before advice executed");
        }
}

Which is also the same one declared as concrete aspect in the aop.xml.

As far as other generated classes are being "wrapped" by the LTW mechanism, i can't imagine why i'm getting that error.

One more issue: when compiling my aspect in console, i get this warning:

ajc -source 1.5 -Xreweavable -classpath ../../../../externals/aspectjrt.jar:../../../../output/build/org/aormf/util/:. ExecutionMonitorAspect.aj

$~/workspace/aormf/src/org/aormf/aspects/ExecutionMonitorAspect.aj:11 [warning] advice defined in org.aormf.aspects.ExecutionMonitorAspect has not been applied [Xlint:adviceDidNotMatch]
before(): annotatedResourceInvocation(){
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1 warning

Which i suppose it is normal to get when not doing compile-time weaving...

I hope i explained the situation clearly enough.

Thanks for any help,
Valerio


Back to the top