Skip to main content

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

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