[jboss-user] [JBoss AOP] - Constructor Execution Pointcut Causing ArrayOutOfBounds

Nicholas Whitehead do-not-reply at jboss.com
Fri Oct 1 13:48:34 EDT 2010


Nicholas Whitehead [http://community.jboss.org/people/nwhitehead] created the discussion

"Constructor Execution Pointcut Causing ArrayOutOfBounds"

To view the discussion, visit: http://community.jboss.org/message/564607#564607

--------------------------------------------------------------
Hello;

Java 1.6
JBoss AOP 2.1.8.GA

I have been wrestling with this for a while now. I have defined a pointcut for the execution of private constructors on classes annotated with *@EntityTXAttribute*. However, while the weaving is going on, an ArrayOutOfBounds exception occurs, and having run it through the debugger, it seems to make sense why, but I am noit sure how to fix it.

The pointcut expression is:

 *execution(public !static * @entitypojo.annotations.EntityTXAttribute->*(..)) 
*
 *OR execution(protected !static * @entitypojo.annotations.EntityTXAttribute->*(..)) 
*
 *OR execution(private @entitypojo.annotations.EntityTXAttribute->new(..))* 
*
*
or +*all public non-static methods in annotated classes, and all private constructors*.+
The method invocation interceptions work perfectly, btw.

My bean has 2 ctors, on parameterized and one not. I set a debugger break point on org.jboss.aop.Advisor line 1870 where the error occurs.
What I see is this:

The instance has an array called *constructors* which has 4 constructors in it, 2 of which I defined and 2 of which appear to be synthetic. They broadly look like this:

1. private Bean()   (mine)
2. Bean(javassist.runtime.Inner)   (synthetic)
3. private Bean(String, String)     (mine)
4. Bean(String, String, javassist.runtime.Inner)   (synthetic)

However, the array of *constructorInfos* only has 2 entries in it which are

1. private Bean()   (mine)
2. private Bean(String, String)     (mine)


The method code looks like this:


*protected void resolveConstructorPointcut(AdviceBinding binding)
   {
      for (int i = 0; i < constructors.length; i++)
      {
         Constructor<?> constructor = constructors[i];
         if (binding.getPointcut().matchesExecution(this, constructor))
         {
            if (AspectManager.verbose) logger.debug("constructor matched binding: " + constructor);
            adviceBindings.add(binding);
            binding.addAdvisor(this);*
*            // this is where the error occurs. Line 1870.
            pointcutResolved(constructorInfos[i], binding, new ConstructorJoinpoint(constructor));
            // if we must keep track of deprecated fields and the field is already initialized
            if (AspectManager.maintainAdvisorMethodInterceptors && constructorInterceptors != null)
            {
               constructorInterceptors[i] = constructorInfos[i].getInterceptors();
            }
         }
      }
   }*

This code assumes the number of *constructorInfos* is at least the same as the number of *constructors*, but since it is not, it throws an array out of bounds exception.

Am I doing something wrong here, or is it a bug ?

Much appreciated.

//Nicholas
--------------------------------------------------------------

Reply to this message by going to Community
[http://community.jboss.org/message/564607#564607]

Start a new discussion in JBoss AOP at Community
[http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2027]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20101001/0d6a0a55/attachment.html 


More information about the jboss-user mailing list