<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">
<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>
                                <td>
                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>
                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px; -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
Constructor Execution Pointcut Causing ArrayOutOfBounds
</h3>
<span style="margin-bottom: 10px;">
created by <a href="http://community.jboss.org/people/nwhitehead">Nicholas Whitehead</a> in <i>JBoss AOP</i> - <a href="http://community.jboss.org/message/564607#564607">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">
<div class="jive-rendered-content"><p>Hello;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Java 1.6</p><p>JBoss AOP 2.1.8.GA</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>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 <strong>@EntityTXAttribute</strong>. 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.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The pointcut expression is:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p><strong style="font-family: courier new,courier; "> execution(public !static * @entitypojo.annotations.EntityTXAttribute->*(..)) <br/></strong></p><p><strong style="font-family: courier new,courier; "> OR execution(protected !static * @entitypojo.annotations.EntityTXAttribute->*(..)) <br/></strong></p><p><strong style="font-family: courier new,courier; "> OR execution(private @entitypojo.annotations.EntityTXAttribute->new(..)) </strong></p><p><strong><br/></strong></p><p>or <em><strong>all public non-static methods in annotated classes, and all private constructors</strong>.</em></p><p>The method invocation interceptions work perfectly, btw.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>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.</p><p>What I see is this:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The instance has an array called <strong>constructors</strong> which has 4 constructors in it, 2 of which I defined and 2 of which appear to be synthetic. They broadly look like this:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><ol><li>private Bean()   (mine)</li><li>Bean(javassist.runtime.Inner)   (synthetic)</li><li>private Bean(String, String)     (mine)</li><li>Bean(String, String, javassist.runtime.Inner)   (synthetic)</li></ol><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>However, the array of <strong>constructorInfos</strong> only has 2 entries in it which are</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><ol><li>private Bean()   (mine)</li><li>private Bean(String, String)     (mine)</li></ol><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>The method code looks like this:</p><p><span style="font-family: courier new,courier;"><br/></span></p><p><strong style="font-family: courier new,courier; ">protected void resolveConstructorPointcut(AdviceBinding binding)<br/>   {<br/>      for (int i = 0; i < constructors.length; i++)<br/>      {<br/>         Constructor<?> constructor = constructors[i];<br/>         if (binding.getPointcut().matchesExecution(this, constructor))<br/>         {<br/>            if (AspectManager.verbose) logger.debug("constructor matched binding: " + constructor);<br/>            adviceBindings.add(binding);<br/>            binding.addAdvisor(this);</strong></p><p><strong style="font-family: courier new,courier; "> <span style="color: #ff0000;">           // this is where the error occurs. Line 1870.</span><br/>            <span style="color: #ff0000;">pointcutResolved(constructorInfos[i], binding, new ConstructorJoinpoint(constructor));</span><br/>            // if we must keep track of deprecated fields and the field is already initialized<br/>            if (AspectManager.maintainAdvisorMethodInterceptors && constructorInterceptors != null)<br/>            {<br/>               constructorInterceptors[i] = constructorInfos[i].getInterceptors();<br/>            }<br/>         }<br/>      }<br/>   }</strong></p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>This code assumes the number of <strong>constructorInfos</strong> is at least the same as the number of <strong>constructors</strong>, but since it is not, it throws an array out of bounds exception.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Am I doing something wrong here, or is it a bug ?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>Much appreciated.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p>//Nicholas</p></div>
<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
<p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/564607#564607">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JBoss AOP at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2027">Community</a></p>
</div></td>
</tr>
</tbody>
</table>
</td>
</tr>
</tbody>
</table>
</div>
</body>
</html>