Hi,
I trace every constructor calls in a simple j3d application.
J3d code :
| import com.sun.j3d.utils.universe.SimpleUniverse;
| public class TestJ3D {
| public TestJ3D() {
| SimpleUniverse universe = new SimpleUniverse();
| }
|
| public static void main(String[] args) {
| new TestJ3D();
| }
| }
|
Aspect code:
| import org.jboss.aop.joinpoint.ConstructorCalledByConstructorInvocation;
| import org.jboss.aop.joinpoint.ConstructorCalledByMethodInvocation;
| public class CallsAspect {
| public Object
constructorCalledByConstructionAdvice(ConstructorCalledByConstructorInvocation
invocation) throws Throwable {
| System.out.println("constructorCalledByConstruction");
| return invocation.invokeNext();
| }
|
| public Object
constructorCalledByMethodAdvice(ConstructorCalledByMethodInvocation invocation)
throws Throwable {
| System.out.println("constructorCalledByMethodAdvice");
| return invocation.invokeNext();
| }
|
jboss-aop.xml file :
| <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
| <aop>
| <aspect class="CallsAspect" scope="PER_VM"/>
| <pointcut name="ConstructorCall" expr="call(*->new(..))"/>
| <pointcut name="CalledByConstructor" expr="withincode(*->new(..))"/>
| <pointcut name="Invocation" expr="within($instanceof{CallsAspect})"/>
|
| <bind pointcut="! Invocation AND ConstructorCall AND CalledByConstructor">
| <advice name="constructorCalledByConstructorAdvice"
aspect="CallsAspect"/>
| </bind>
|
| <bind pointcut="! Invocation AND ConstructorCall AND !
CalledByConstructor">
| <advice name="constructorCalledByMethodAdvice" aspect="CallsAspect"/>
| </bind>
| </aop>
|
But a exception occures during the execution (i'm using the load-time weaving) :
| Exception in thread "main" java.lang.ExceptionInInitializerError
| Caused by: java.lang.RuntimeException: java.lang.RuntimeException:
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
| at
org.jboss.aop.ClassAdvisor.resolveConstructorCallerConstructorInfo(ClassAdvisor.java:1432)
| at TestJ3D.<clinit>(TestJ3D.java)
| Caused by: java.lang.RuntimeException: java.lang.IndexOutOfBoundsException:
Index: 0, Size: 0
| at org.jboss.aop.advice.AdviceFactory.create(AdviceFactory.java:54)
| at org.jboss.aop.Advisor.createInterceptorChain(Advisor.java:531)
| at
org.jboss.aop.ClassAdvisor.bindConCalledByConInterceptorChain(ClassAdvisor.java:763)
| at
org.jboss.aop.ClassAdvisor.resolveConstructorCallerConstructorInfo(ClassAdvisor.java:1427)
| ... 1 more
| Caused by: java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
| at java.util.ArrayList.RangeCheck(ArrayList.java:547)
| at java.util.ArrayList.get(ArrayList.java:322)
| at
org.jboss.aop.advice.PerVmAdvice.generateInterceptor(PerVmAdvice.java:103)
| at
org.jboss.aop.advice.PerVmAdvice.generateOptimized(PerVmAdvice.java:37)
| at org.jboss.aop.advice.AdviceFactory.create(AdviceFactory.java:50)
| ... 4 more
|
I also tried to use the "execution(*->new(..))" statement and
ConstructorInvocation but there is an execption too.
I don't see what is wrong.
Any suggestions are welcome.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3939889#3939889
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3939889
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
JBoss-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jboss-user