Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
RE: [aspectj-users] staticinitialization, preinitialization, initialization??

Hi Nadia,

 

Static initialization occurs when the type is loaded (i.e., the Java VM loads the resulting class file for Lolo). At that point, the implementation of the before calls the static method aspectOf to access the singleton instance of Lolo. But the initialization code that constructs and assigns this instance hasn’t yet run (it would run during static initialization), hence the exception.

 


From: aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Nadia Guerroumi
Sent: Tuesday, March 29, 2005 10:32 AM
To: aspectj-users@xxxxxxxxxxx
Subject: Re: [aspectj-users] staticinitialization, preinitialization,initialization??

 

HI RON!!

 

You said: your before advice in Lolo was executing on staticinitialization of the Lolo aspect, which failed because the aspect wasn’t yet initialized.

 

At what time the aspect is initialized?? Perhaps it is a silly question but I want to UNDERSTANNNNNNNNNNNNNNDDDDDDDDDDDDDDDDD....

 

 

Thank you very much RON,

 

Nadia.

----- Original Message -----

From: Ron Bodkin

Sent: Tuesday, March 29, 2005 11:55 AM

Subject: RE: [aspectj-users] staticinitialization, preinitialization,initialization??

 

Hi Nadia,

 

The programmer’s guide has a good definition of the different join points, including the various initialization ones: http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj-home/doc/progguide/semantics-joinPoints.html

 

For #2, your before advice in Lolo was executing on staticinitialization of the Lolo aspect, which failed because the aspect wasn’t yet initialized. You already figured out the way to avoid the problem J

 


From: aspectj-users-bounces@xxxxxxxxxxx [mailto:aspectj-users-bounces@xxxxxxxxxxx] On Behalf Of Nadia Guerroumi
Sent: Tuesday, March 29, 2005 6:14 AM
To: aspectj-users@xxxxxxxxxxx
Subject: [aspectj-users] staticinitialization, preinitialization,initialization??

 

Please could you help me, in the two following questions ( Code is at the end)

 

1) Difference between staticinitialization, preinitialization,initialization join points?? They occur between the call to the construcor and the execution of the constructor. I saw that staticinitialization occurs only the first time??

BUt what is the difference in the semantics?

 

 

2) My objective was to capture all the join points !! So in the beginning I put only:

 

pointcut p2():if (true)

 

Why I had the following error at the execution of the main??

 

Exception in thread "main" java.lang.ExceptionInInitializerError
        at Nadia1.<clinit>(Nadia1.java)
Caused by: org.aspectj.lang.NoAspectBoundException: Lolo
        at Lolo.aspectOf(True.java)
        at Lolo.<clinit>(True.java)
        ... 1 more

 

 

It works only if I add ! within(Lolo) in the pcd ??

 

And gives me this execution:

>>Before the join point:staticinitialization(Nadia1.<clinit>)
>>Before the join point:execution(void Nadia1.main(String[]))
>>Before the join point:call(Bank())
>>Before the join point:staticinitialization(Bank.<clinit>)
>>Before the join point:preinitialization(Bank())
>>Before the join point:initialization(Bank())
>>Before the join point:execution(Bank())
>>Before the join point:set(Bank Nadia1.b)
>>Before the join point:call(Bank())
>>Before the join point:preinitialization(Bank())
>>Before the join point:initialization(Bank())
>>Before the join point:execution(Bank())
>>Before the join point:set(Bank Nadia1.c)

 

 

My programs are the following:

/**************************************************/

class Nadia1 {

public static Bank b,c;

public static void main(String[] args) {

b=new Bank();

c=new Bank();}}

/***********************************************/

class Bank {}

/****************************************************/

aspect Lolo

{

pointcut p2():if (true) && !within (Lolo);

before(): p2() {

System.out.println(">>Before the join point:"+thisJoinPoint);

}

}

 

 

Nadia.


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


Back to the top