[jboss-dev-forums] [Design of AOP on JBoss (Aspects/JBoss)] - Re: MethodInvocation.getArguments return value for 0 argumen

flavia.rainone@jboss.com do-not-reply at jboss.com
Fri Mar 23 22:18:26 EDT 2007


Hi!

I changed that in version 2.0, and I added a javadoc documenting the rules related to getArguments():


  | /**
  |     * Returns a non-null array containing all method arguments.
  |     * <p>
  |     * The returned array can be changed by the advice or interceptor accordingly. All
  |     * changes are reflected on joinpoint execution, and are noticed as well by
  |     * other advices and interceptors that are executed after the current one.
  |     * <br>
  |     * However, changes to this array are limited to the scope of current advice
  |     * execution, and must be performed before execution of {@link #invokeNext()},
  |     * {@link #invokeNext(Interceptor[])}, or {@link #invokeTarget()} method.
  |     * Otherwise, inconsistency on joinpoint argument values may be noticed.
  |     *
  |     * @return the method arguments
  |     */
  |    public Object[] getArguments()
  | 

The main cause of this was the use of annotated arguments on before/after advices (new feature of JBoss AOP 2.0). A before/after advice can receive the arguments array as a parameter:

  | public void beforeAdvice(@Args Object[] arguments)
  | {
  |     // do something before joinpoint execution
  | }
  | 

Kabir and I decided that an advice that receives arguments would be called to intercept all types of joinpoint, even though arguments array would be null during a field read joinpoint.

Given that, and considering I couldn't find a documentation on getArguments method returning a null value (please, Kabir, let me know if there is one), I thought that the arguments array should be a non-null value during the interception of other joinpoint types (hence, for methods with no arguments, the arguments array should be an empty array).

Since the intention is to make @Args annotated parameters consistent with [InvocationType].getArguments() and [InvocationType].setArguments() methods, I changed getArguments method to return always a non-null value, as you can see on the javadoc comments (notice that these methods are available only on Invocation classes that are equivalent to joinpoints with a valid arguments list, which excludes the FieldReadInvocation class).

So, this is the reason for which I changed that. I apologize for causing any trouble.

Now, I think we need to decide whether we keep things this way, or we make arguments array null on methods and constructors with an empty argument list.

Any thoughts? Kabir? Clebert?



View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4031255#4031255

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4031255



More information about the jboss-dev-forums mailing list