Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] Re: Error with perthis (java.lang.NoSuchMethod)

Dope forgot to pass my aspects jar through the weaver. And now my
stupidity is immortalized

-Bhaskar

On Wed, May 19, 2010 at 5:34 PM, Bhaskar Maddala <maddalab@xxxxxxxxx> wrote:
> I should probably add that I am compiling my annotated aspects with
> sun java compiler
>
> On Wed, May 19, 2010 at 5:23 PM, Bhaskar Maddala <maddalab@xxxxxxxxx> wrote:
>> Hello,
>>
>> I am quite certainly being dense here, however after having spent 4
>> hrs I figured it would be easier to ask on the list. I have the
>> following main class
>>
>> public class Main {
>>    private void dos() {
>>        System.out.println("Executing dos");
>>    }
>>
>>    public static void main(String[] args) {
>>        for (int i = 0; i < 10; i++) {
>>            Main m = new Main();
>>            m.dos();
>>        }
>>    }
>> }
>>
>> and an aspect
>>
>> @Aspect("perthis(initialization(Main.new(..)))")
>> public class MainReporter2 {
>>    MainReporter2() {
>>        System.out.println("Executing Main Reporter");
>>    }
>>
>>    @Around("execution(* Main.dos(..))")
>>    public void aroundDos() {
>>        System.out.println("Overriding Dos");
>>    }
>> }
>>
>> I build using the iajc ant task
>>
>> <iajc inpath="${tmp-build.jar}" classpath="${AspectJTools.classpath}"
>> aspectPath="${aspects.jar}" outJar="${build.jar}"/>
>>
>> tmp-build.jar contains main, aspects.jar contain MainReporter, the
>> resulting build.jar contain the weaved classes
>>
>> However when I run (include my aspects jar, build jar and aspectrt jar in cp)
>>
>> java -cp aspectjrt.jar:build.jar:aspects.jar Main
>>
>> I get the following
>>
>> Exception in thread "main" java.lang.NoSuchMethodError:
>> MainReporter2.ajc$perObjectBind(Ljava/lang/Object;)V
>>        at Main.<init>(Main.java:3)
>>        at Main.main(Main.java:10)
>>
>> I did verify that MainReporter2 does not have the method
>>
>> Compiled from "MainReporter2.java"
>> public class MainReporter2 extends java.lang.Object{
>>    MainReporter2();
>>    public void aroundDos();
>> }
>>
>> Which step during my build process am I going wrong?
>>
>> Thanks
>> Bhaskar
>>
>


Back to the top