Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [aspectj-users] names in args() pointcut

Ciao Mauro,
as Eric pointed out that is not possible right now.

Parameters names are actually preserved in bytecode as part of the
debugging information, which also contains line numbers and local
variables names. If the code is compiled without debugging information,
then names are not available. So, AspectJ can not add such a pointcut
cause it would work sometimes and would not work some other times.

There has been a discussion about wether to include parameter names in
standard class files in Java 1.6, basically always adding that piece of
debug informations. The problem was that since parameter names are not
part of the formal signature (they conceptually are local variables
inside the method), offering them thru reflection could make people
relay on some given parameter names, which are not part of the contract,
and create more problems than it would eventually solve.

Also, since parameters can be annotated, and an annotation is more
explicitly an information targeted "outside" the method (while the name
is valid only inside the method), in most cases an annotation can be
used as a more reliable alternative to conventions over parameter names.
AspectJ can match methods having annotated parameters.

So, AFAIK, they have not been included in Java 1.6 and the feature has
been postponed for future versions of Java. I can't remember nor find
the JSR about this, but there is one I'm pretty sure.

Hope this helps clarify,
Simone





Eric Bodden wrote:
> No, this isn't really possible I believe. You may be able to solve
> this by checking on thisJoinpointStaticPart inside the advice but I am
> not quite sure if that information is preserved. As far as I remember
> it's also not generally true that bytecode contains this information.
>
> Eric
>
> 2008/10/4 Mauro Baluda <mauro@xxxxxxxx>:
>   
>> I haven't found any documentation about matching methods by the names
>> of their parameters, is it possible?
>> I think the names are conserved in the bytecode...
>>
>> Mauro
>> _______________________________________________
>> aspectj-users mailing list
>> aspectj-users@xxxxxxxxxxx
>> https://dev.eclipse.org/mailman/listinfo/aspectj-users
>>
>>     
>
>
>
>   


-- 
Simone Gianni            CEO Semeru s.r.l.           Apache Committer
MALE human being programming a computer   http://www.simonegianni.it/



Back to the top