Skip to main content

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

Hmmm, where did you read this:

> Now every documentation I read states that my aspect should only affect proccesPW()
> because hashPW() is private and thous not visible for normal weaving.

It isn't the case I'm afraid.  All join points are always visible to
be advised.  If you don't want to advise private methods, you use the
modifier support in the pointcut: execution(!private * *(..))

Privileged aspects are something different, if that is what you are
thinking of.  Privileged aspects can contain code that can access and
call members that they wouldn't normally be able to see - but it
doesn't relate to join point visibility.

Andy.

2008/6/17 Pascal Flach <p_flach@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>:
> 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
> _______________________________________________
> aspectj-users mailing list
> aspectj-users@xxxxxxxxxxx
> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>


Back to the top