Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[aspectj-users] final field access?

Title: final field access?

Just a quick question.  Why can't I have a pointcut declared on a field access joinpoint of a final field?  For example, the code below executes the advice fine when the field is not final, however it doesn't execute in it's current state.  Can anyone shed some light?


package com.test;

public class Test {


        public final String myString = "test";
       
        public Test(){
                System.out.println(myString);
        }
       
        public static void main(String[] args){
                Test t = new Test();
        }
}

package com.test;

public aspect TestAspect {

        pointcut access() : get(public final String com.test.Test.myString);
       
        before() : access() {
                System.out.println("accessing var");
        }
}

Cheers
Adam

Important notice: This message is intended for the individual(s) and entity(s) addressed. The information contained in this transmission and any attached, may be confidential and may also be the subject of legal privilege, public interest immunity or legal professional privilege. Any review, retransmission, dissemination or other use of, taking of any action in reliance upon this information by person or entities other than the recipient is prohibited and requires authorization from the sender. If you are not the addressee indicated in this message (or responsible for delivery of the message to such person) you may not copy or deliver this message to anyone. In such cases you should destroy this message and kindly notify the sender by reply email.

WARNING: Although Infocomp has taken reasonable precautions so that no viruses are present in this e-mail, the company cannot accept responsibility for any loss or damage arising from the use of e-mail attachments.


Back to the top