Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] What is the definition of "initialization" designator?

Taking your questions out of order...

> In the following sample code:

Your code has no aspects, so it can't be debugged.

> [...] Is there any difference between initialization( Class.new())
> and execution( Class.new()) ?

From the programming guide:

----
Constructor execution
When the body of code for an actual constructor executes,
after its this or super constructor call. The object
being constructed is the currently executing object, and
so may be accessed with the this pointcut. The constructor
execution join point for a constructor that calls a super
constructor also includes any non-static initializers of
enclosing class. No value is returned from a constructor
execution join point, so its return type is considered
to be void.

Object initialization
When the object initialization code for a particular class
runs. This encompasses the time between the return of its
parent's constructor and the return of its first called
constructor. It includes all the dynamic initializers and
constructors used to create the object. The object being
constructed is the currently executing object, and so may
be accessed with the this pointcut. No value is returned
from a constructor execution join point, so its return
type is considered to be void.
...

----


> ... got the following error message under AspectJ 1.1.1:
> ...
> Caused by: org.aspectj.lang.NoAspectBoundException

From the API docs for NoAspectBoundException:
----
Thrown by the aspectOf(..) special method on aspect types
when there is no aspect of that type currently bound
----

From the FAQ entry "When I run, I get a NoAspectBoundException":

----
You can get a NoAspectBoundException when there is a cycle
in aspect initialization or static initialization, most
commonly when an aspect advises its own initializer
----
http://dev.eclipse.org/viewcvs/indextech.cgi/~checkout~/aspectj-home/doc/faq.html#q:noaspectbound

I hope this helps...

Wes

Yongsheng Yin wrote:
Hi,

	I am an AspectJ newbie. The initialization designator really
confused me.  Is there any difference between initialization( Class.new())
and execution( Class.new()) ?

In the following sample code:

public class Picture {

	private Vector graphs;
	static private Picture pic = null;

	private Picture(){
		this.graphs = new Vector();
	}


	public static Picture instanceOf(){

		if ( pic == null ){
			pic = new Picture();
			return pic;
		}
		else
			return pic;

	}

	public static void main( String [] args ){

		Picture p = Picture.instanceOf();
        }
}

Both initialization( new()) and execution( new()) worked well under
AspectJ 1.06 but got the following error message under AspectJ 1.1.1:

java.lang.ExceptionInInitializerError
	at Picture.<init>(Picture.java:23)
	at Picture.instanceOf(Picture.java:29)
	at Picture.main(Picture.java:39)
Caused by: org.aspectj.lang.NoAspectBoundException
	at Asp.aspectOf(Asp.java)
	at Asp.<init>(Asp.java:14)
	at Asp.ajc$postClinit(Asp.java)
	at Asp.<clinit>(Asp.java:14)
	... 3 more
Exception in thread "main"

Anybody can help to explain this? Thanks.

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




Back to the top