Hi Alan,
Thanks for your interest in tracematches!
Indeed your tracematch declaration looks OK. The problem isn't there, but in
your runtime classpath. The instrumentation generated by the tracematch
implementation relies on a number of utility classes, which are packaged in
the abc-runtime.jar (they are also in abc-complete.jar). Thus, if you make
sure one of these jars is on your classpath when you run the compiled
classes, it should work:
java -cp abc-runtime.jar:$CLASSPATH Account
Please let us know if this resolves your issue.
Best wishes,
- Pavel
On Wednesday 13 February 2008 11:15:31 Alan Teoh wrote:
> Hi there,
>
> I am a student who is currently doing research on aspect oriented
> programming. I am new to tracematches, and I was trying to write an
> example of my own and run it to observe their behaviour.
>
> Source code are as follows:
> class Account {
> private int type; // Integer to determine account type
>
> public Account(int t) {
> this.type = t;
> }
>
> public void withdraw() {
> System.out.println("Withdraw");
> }
>
> public void deposit() {
> System.out.println("Deposit");
> }
> public static void main(String[] args) {
> Account a = new Account(1);
> Account a2 = new Account(1);
>
> a.withdraw();
> a.deposit();
> a2.deposit();
> }
> }
>
> public aspect AccountTM {
> tracematch (Account a) {
> sym wd after:
> call (* Account.withdraw(..)) && target(a);
> sym dp after:
> call (* Account.deposit(..)) && target(a);
>
> wd dp[2]
> {
> System.out.println("1 withdraw and 2 deposit method calls
> made by " + a);
> }
> }
> }
>
> I compiled them using the tracematch extension for abc via the following
> command: "abc -ext abc.tm Account.java AccountTM.aj" (Without quotes)
> When I try to run Account.java, I get the following output:
> H:\java Account
> Withdraw
> Exception in thread "main" org.aspectj.lang.NoAspectBoundException:
> Exception while initializing AccountTM: java.lang.NoClassDefFoundError:
> org/aspect
> bench/tm/runtime/internal/Lock
> at AccountTM.aspectOf(AccountTM.aj)
> at Account.main(Account.java:19)
> Caused by: java.lang.NoClassDefFoundError:
> org/aspectbench/tm/runtime/internal/Lock
> at AccountTM.<init>(AccountTM.aj:1)
> at AccountTM.abc$postClinit(AccountTM.aj)
> at AccountTM.<clinit>(AccountTM.aj)
> ... 1 more
>
> It seems like after the withraw() method call, an exception was thrown.
> I have no clue as to what that error exactly means but it looks like it
> has got something to do with the aspect itself. I have read papers on
> tracematches and it seemed that my tracematch declaration looked OK
> according to its syntax. Could anyone shed a light as to where I have
> gone wrong?
>
> I am using the *Complete compiler jar* (abc-complete.jar) package to
> compile my tracematch.
>
> Thanks.
Received on Wed Feb 13 2008 - 11:20:40 GMT
This archive was generated by hypermail 2.2.0 : Wed Feb 13 2008 - 11:50:10 GMT