[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] Eclipse and AspectJ

On the problem with 1.6 compliance, are you able to share the code for that with me as well?

Andy.

2009/3/3 Alejandro Garcia <garciaal@xxxxxxxxxxx>
Hello Andy,

On Mar 3, 2009, at 4:39 PM, Andy Clement wrote:

Hi Alejandro,

Compliance 1.6 in Eclipse 3.4.2 should be fine.  I just created the AspectJ Bean example project (File>New>AspectJ Examples>Bean Example) and changed the compliance to 1.6 and it was ok.  What happens to you when it doesn't work - do you get an error?


I don't have any error, it runs normally but without any output in the console. I tried it once again but no luck.

> Also, I tried some examples and sometimes I've got that some advices are not being apply (raised a warning!). I checked it with an experienced
> aspect user (not in eclipse) and there is no reason not to be working (the aspect and the example class are very simple).

If compliance level is 1.5 or above, you will get warnings when advice does not match - are those the warnings you see?  To comment on why i isn't matching, I would need to see the code - are you able to post any of it here?


I see the warnings....I also attached the code... as I said is very simple and is from a book. the warning is in MinimumBalanceRuleAspect.

Thanks a lot for your help, I really appreciated.

Alejandro

public class Account {


private float balance;
private final int accountNumber;


public Account(final int accountNumber) {
this.accountNumber = accountNumber;
}


public void credit(final float credit) {
this.balance = credit + balance;
}


public void debit(final float debit) throws InsufficientBalanceException{
if(this.balance < debit) {
new InsufficientBalanceException("Not enough money in the account");
}else {
this.balance -= debit;
}
}


public void setBalance(final float balance) {
this.balance = balance;
}


public float getBalance() {
return balance;
}
}

public final class InsufficientBalanceException extends Exception {

public InsufficientBalanceException(final String mssg) {
super(mssg);
}
}

public final aspect MinimumBalanceRuleAspect {

private float Account.minimumBalance;


public float Account.getAvailableBalance() {
return getBalance() - minimumBalance;
}

after(final Account a) : execution(Account.new(..)) && this(a){
a.minimumBalance = 25;
}

//ADVICE WITH WARNING!!!!!!
before(final Account account, final float amount) throws InsufficientBalanceException : 
execution(* Account.debit()) && this(account) && args(amount){
if(account.getAvailableBalance() < amount) {
throw new InsufficientBalanceException("----- Insufficient funds -----");
}
}
}

public final class TestAccount {

public static void main(final String[] args) throws InsufficientBalanceException{
final Account account = new Account(1234);
account.credit(1000);
account.debit(500);
}
}

cheers,
Andy.


2009/3/3 Alejandro Garcia <garciaal@xxxxxxxxxxx>
Hello I'm Alejandro and also a newbie in this area.
I have the following problems: I've been trying to use Java JRE 1.6 and Compiler compliance level 1.6 in Eclipse 3.4.2  with AspectJ but it seems not to be working. If I change it to JRE 1.5 and compiler 1.5 works fine.
Is this correct? Could you point me to any place where I can find this information?

Also, I tried some examples and sometimes I've got that some advices are not being apply (raised a warning!). I checked it with an experienced aspect user (not in eclipse) and there is no reason not to be working (the aspect and the example class are very simple).
Any idea?

Thank you very much in advance for any help,

Alejandro Garcia
Email: garciaal@xxxxxxxxxxx
Website: www.atelier.inf.unisi.ch/~garciaal


_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users

<ATT00001.txt>


_______________________________________________
aspectj-users mailing list
aspectj-users@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/aspectj-users