Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] unmodified aspect advicing private field and method

Good Morning

I am writing a seminar paper about some facets of aspect weaving with aspectJ. To present an example I wrote the following class and aspect.

package aplication;

public class Authentification {
	
	private String pw = "spaceballs";
	static public void main(String[] args){
		if (new Authentification().processPW()){
			System.out.println("true");
		}else{
			System.out.println("false");
		}
	}

	public boolean processPW(){
		boolean result = false;
		//setup
		pw +=" the actionfigures";
		String hash = hashPW(pw);
		System.out.println(hash);
		//processing
		return result;
	}
	
	private String hashPW(String pw){
		//secure hashfunction
		return "12345";
	}
}
--------------------
package aspects;

public aspect SimpleAspect {
	
	private pointcut auth():execution(* *PW(..));

	after():auth(){
		System.out.println("logentry");
		//return null;
	}
	
	private pointcut tst(String p):set(String pw) && args(p);
	
	before(String pw):tst(pw){
		System.out.println("pw found");
	}
}

Now every documentation I read states that my aspect should only affect proccesPW() because hashPW() is private and thous not visible for normal weaving. Unfortunatly running the code abouth or inspecting the bytecode revells that both advices are woven into the private parts.
It would be nice, if anybody could explaine what I missed here.

Thanks
Pascal


Back to the top