Re: [abc-users] Capturing synchronized blocks - StmtShadowMatch or BodyShadowMatch

From: Ganesh Sittampalam <ganesh@earth.li>
Date: Thu Mar 31 2005 - 09:22:22 BST

Hi,

On Mon, 28 Mar 2005, Eric Bodden wrote:

> My problem at the moment is the ShadowMatch: As I understood from the
> turorial there are matches on statements and bodies. I, however, want
> to match on only a part of the body, being the synchronized block. So
> what ShadowMatch should I extend?

As Bruno said, the logical thing would be to extend StmtShadowMatch. You
will also probably need to make yourself a new kind of MethodPosition, and
override AbcExtension.findMethodShadows to handle this. If you need more
explanation of this, just ask - I'd rather not spend time explaining
something that you actually find obvious from the code :-)

I'd also welcome suggestions/opinions from anyone about how to improve the
design of this area. The whole MethodPosition thing feels a bit
heavyweight, but I wanted to avoid a situation where every single
kind of StmtShadowMatch has to iterate through the method body.

> Identifying this block is one task. This seems quite tedious because
> of exception handling and rethrowing in monitor regions, so the end
> of the block seems to be hard to identify. However I think this is
> necessary, in order to allow around() to work, is that right?

As Laurie has pointed out, the end point can't be identified
unambiguously, so you will either have to guess and make it clear to users
that this will happen, or to disable after/around advice in the same was
as is done for exception handler join points.

Cheers,

Ganesh
Received on Thu Mar 31 09:30:19 2005

This archive was generated by hypermail 2.1.8 : Thu Mar 31 2005 - 23:50:05 BST